{"action":"created","comment":{"url":"https://api.github.com/repos/matrix-org/sytest/pulls/comments/48163236","id":48163236,"diff_hunk":"@@ -0,0 +1,168 @@\n+use Future::Utils qw( repeat );\n+\n+test \"Outbound federation can backfill events\",\n+   requires => [ local_user_fixture(), $main::INBOUND_SERVER, federation_user_id_fixture() ],\n+\n+   do => sub {\n+      my ( $user, $inbound_server, $creator_id ) = @_;\n+\n+      my $local_server_name = $inbound_server->server_name;\n+      my $datastore         = $inbound_server->datastore;\n+\n+      my $room_alias = \"#50fed-31backfill:$local_server_name\";\n+\n+      my $room = $datastore->create_room(\n+         creator => $creator_id,\n+         alias   => $room_alias,\n+      );\n+\n+      # Create some past messages to backfill from\n+      $room->create_event(\n+         type => \"m.room.message\",\n+\n+         sender  => $creator_id,\n+         content => {\n+            msgtype => \"m.text\",\n+            body    => \"Message $_ here\",\n+         },\n+      ) for 1 .. 10;\n+\n+      Future->needs_all(\n+         $inbound_server->await_backfill( $room->room_id )->then( sub {\n+            my ( $req ) = @_;\n+\n+            my $v     = $req->query_param( 'v' );\n+            my $limit = $req->query_param( 'limit' );\n+\n+            my @events = $datastore->get_backfill_events(\n+               start_at => [ $v ],\n+               limit    => $limit,\n+            );\n+\n+            $req->respond_json( {\n+               origin           => $inbound_server->server_name,\n+               origin_server_ts => $inbound_server->time_ms,\n+               pdus             => \\@events,\n+            } );\n+\n+            Future->done;\n+         }),\n+\n+         do_request_json_for( $user,\n+            method => \"POST\",\n+            uri    => \"/api/v1/join/$room_alias\",\n+\n+            content => {},\n+         )->then( sub {\n+            my ( $body ) = @_;\n+\n+            my $room_id = $body->{room_id};\n+\n+            # 10 m.room.message events + my own m.room.member\n+            my $want_count = 11;\n+\n+            # We may have to get more than once to have all 11 events\n+\n+            my $token;\n+            my @events;\n+            ( repeat {\n+               matrix_get_room_messages( $user, $room_id,\n+                  limit => $want_count - scalar(@events),\n+                  from  => $token,\n+               )->then( sub {\n+                  my ( $body ) = @_;\n+                  push @events, @{ $body->{chunk} };\n+\n+                  $token = $body->{end};\n+                  Future->done;\n+               });\n+            } while => sub { !shift->failure and @events < $want_count } )->then( sub {","path":"tests/50federation/34room-backfill.pl","position":79,"original_position":79,"commit_id":"6c660cda25b567c028d4fe8e7bdc447f2fa4fc82","original_commit_id":"6c660cda25b567c028d4fe8e7bdc447f2fa4fc82","user":{"login":"illicitonion","id":1131704,"avatar_url":"https://avatars.githubusercontent.com/u/1131704?v=3","gravatar_id":"","url":"https://api.github.com/users/illicitonion","html_url":"https://github.com/illicitonion","followers_url":"https://api.github.com/users/illicitonion/followers","following_url":"https://api.github.com/users/illicitonion/following{/other_user}","gists_url":"https://api.github.com/users/illicitonion/gists{/gist_id}","starred_url":"https://api.github.com/users/illicitonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/illicitonion/subscriptions","organizations_url":"https://api.github.com/users/illicitonion/orgs","repos_url":"https://api.github.com/users/illicitonion/repos","events_url":"https://api.github.com/users/illicitonion/events{/privacy}","received_events_url":"https://api.github.com/users/illicitonion/received_events","type":"User","site_admin":false},"body":"Match close paren with open paren, for ease of reading","created_at":"2015-12-21T16:36:18Z","updated_at":"2015-12-21T16:36:18Z","html_url":"https://github.com/matrix-org/sytest/pull/120#discussion_r48163236","pull_request_url":"https://api.github.com/repos/matrix-org/sytest/pulls/120","_links":{"self":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/comments/48163236"},"html":{"href":"https://github.com/matrix-org/sytest/pull/120#discussion_r48163236"},"pull_request":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/120"}}},"pull_request":{"url":"https://api.github.com/repos/matrix-org/sytest/pulls/120","id":54274388,"html_url":"https://github.com/matrix-org/sytest/pull/120","diff_url":"https://github.com/matrix-org/sytest/pull/120.diff","patch_url":"https://github.com/matrix-org/sytest/pull/120.patch","issue_url":"https://api.github.com/repos/matrix-org/sytest/issues/120","number":120,"state":"open","locked":false,"title":"Test the federation `/backfill` API","user":{"login":"leonerd","id":350941,"avatar_url":"https://avatars.githubusercontent.com/u/350941?v=3","gravatar_id":"","url":"https://api.github.com/users/leonerd","html_url":"https://github.com/leonerd","followers_url":"https://api.github.com/users/leonerd/followers","following_url":"https://api.github.com/users/leonerd/following{/other_user}","gists_url":"https://api.github.com/users/leonerd/gists{/gist_id}","starred_url":"https://api.github.com/users/leonerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonerd/subscriptions","organizations_url":"https://api.github.com/users/leonerd/orgs","repos_url":"https://api.github.com/users/leonerd/repos","events_url":"https://api.github.com/users/leonerd/events{/privacy}","received_events_url":"https://api.github.com/users/leonerd/received_events","type":"User","site_admin":false},"body":"Oops. This is the correct title for this PR; not the last one. :)","created_at":"2015-12-21T16:21:05Z","updated_at":"2015-12-21T16:36:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"010235e889abb5d9913f48a29d2f713dcbe99c82","assignee":{"login":"illicitonion","id":1131704,"avatar_url":"https://avatars.githubusercontent.com/u/1131704?v=3","gravatar_id":"","url":"https://api.github.com/users/illicitonion","html_url":"https://github.com/illicitonion","followers_url":"https://api.github.com/users/illicitonion/followers","following_url":"https://api.github.com/users/illicitonion/following{/other_user}","gists_url":"https://api.github.com/users/illicitonion/gists{/gist_id}","starred_url":"https://api.github.com/users/illicitonion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/illicitonion/subscriptions","organizations_url":"https://api.github.com/users/illicitonion/orgs","repos_url":"https://api.github.com/users/illicitonion/repos","events_url":"https://api.github.com/users/illicitonion/events{/privacy}","received_events_url":"https://api.github.com/users/illicitonion/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/matrix-org/sytest/pulls/120/commits","review_comments_url":"https://api.github.com/repos/matrix-org/sytest/pulls/120/comments","review_comment_url":"https://api.github.com/repos/matrix-org/sytest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matrix-org/sytest/issues/120/comments","statuses_url":"https://api.github.com/repos/matrix-org/sytest/statuses/6c660cda25b567c028d4fe8e7bdc447f2fa4fc82","head":{"label":"matrix-org:paul/federation","ref":"paul/federation","sha":"6c660cda25b567c028d4fe8e7bdc447f2fa4fc82","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":23436169,"name":"sytest","full_name":"matrix-org/sytest","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/sytest","description":"Black-box integration testing for Matrix homeservers","fork":false,"url":"https://api.github.com/repos/matrix-org/sytest","forks_url":"https://api.github.com/repos/matrix-org/sytest/forks","keys_url":"https://api.github.com/repos/matrix-org/sytest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/sytest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/sytest/teams","hooks_url":"https://api.github.com/repos/matrix-org/sytest/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/sytest/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/sytest/events","assignees_url":"https://api.github.com/repos/matrix-org/sytest/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/sytest/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/sytest/tags","blobs_url":"https://api.github.com/repos/matrix-org/sytest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/sytest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/sytest/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/sytest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/sytest/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/sytest/languages","stargazers_url":"https://api.github.com/repos/matrix-org/sytest/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/sytest/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/sytest/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/sytest/subscription","commits_url":"https://api.github.com/repos/matrix-org/sytest/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/sytest/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/sytest/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/sytest/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/sytest/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/sytest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/sytest/merges","archive_url":"https://api.github.com/repos/matrix-org/sytest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/sytest/downloads","issues_url":"https://api.github.com/repos/matrix-org/sytest/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/sytest/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/sytest/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/sytest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/sytest/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/sytest/releases{/id}","created_at":"2014-08-28T17:05:43Z","updated_at":"2015-05-26T09:36:45Z","pushed_at":"2015-12-21T16:21:05Z","git_url":"git://github.com/matrix-org/sytest.git","ssh_url":"git@github.com:matrix-org/sytest.git","clone_url":"https://github.com/matrix-org/sytest.git","svn_url":"https://github.com/matrix-org/sytest","homepage":"","size":1288,"stargazers_count":2,"watchers_count":2,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"develop"}},"base":{"label":"matrix-org:develop","ref":"develop","sha":"dc3f02f043dbbfbfab5f0fb7afac60333c466230","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":23436169,"name":"sytest","full_name":"matrix-org/sytest","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/sytest","description":"Black-box integration testing for Matrix homeservers","fork":false,"url":"https://api.github.com/repos/matrix-org/sytest","forks_url":"https://api.github.com/repos/matrix-org/sytest/forks","keys_url":"https://api.github.com/repos/matrix-org/sytest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/sytest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/sytest/teams","hooks_url":"https://api.github.com/repos/matrix-org/sytest/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/sytest/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/sytest/events","assignees_url":"https://api.github.com/repos/matrix-org/sytest/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/sytest/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/sytest/tags","blobs_url":"https://api.github.com/repos/matrix-org/sytest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/sytest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/sytest/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/sytest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/sytest/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/sytest/languages","stargazers_url":"https://api.github.com/repos/matrix-org/sytest/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/sytest/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/sytest/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/sytest/subscription","commits_url":"https://api.github.com/repos/matrix-org/sytest/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/sytest/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/sytest/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/sytest/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/sytest/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/sytest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/sytest/merges","archive_url":"https://api.github.com/repos/matrix-org/sytest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/sytest/downloads","issues_url":"https://api.github.com/repos/matrix-org/sytest/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/sytest/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/sytest/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/sytest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/sytest/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/sytest/releases{/id}","created_at":"2014-08-28T17:05:43Z","updated_at":"2015-05-26T09:36:45Z","pushed_at":"2015-12-21T16:21:05Z","git_url":"git://github.com/matrix-org/sytest.git","ssh_url":"git@github.com:matrix-org/sytest.git","clone_url":"https://github.com/matrix-org/sytest.git","svn_url":"https://github.com/matrix-org/sytest","homepage":"","size":1288,"stargazers_count":2,"watchers_count":2,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/120"},"html":{"href":"https://github.com/matrix-org/sytest/pull/120"},"issue":{"href":"https://api.github.com/repos/matrix-org/sytest/issues/120"},"comments":{"href":"https://api.github.com/repos/matrix-org/sytest/issues/120/comments"},"review_comments":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/120/comments"},"review_comment":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matrix-org/sytest/pulls/120/commits"},"statuses":{"href":"https://api.github.com/repos/matrix-org/sytest/statuses/6c660cda25b567c028d4fe8e7bdc447f2fa4fc82"}}}}