Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that remote device list is refetched on leave/rejoin #793

Merged
merged 6 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix federation tests
  • Loading branch information
erikjohnston committed Jan 30, 2020
commit afe2ddd3da1b92ec816c8fc06b3bb27d06ab64f3
66 changes: 31 additions & 35 deletions tests/50federation/30room-join.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,14 @@ sub assert_is_valid_pdu {
my $local_server_name = $inbound_server->server_name;
my $datastore = $inbound_server->datastore;

my $room = SyTest::Federation::Room->new(
datastore => $datastore,
);

$room->create_initial_events(
server => $inbound_server,
my $room_alias = "#50fed-room-alias:$local_server_name";
my $room = $datastore->create_room(
creator => $creator_id,
alias => $room_alias,
);

my $room_id = $room->room_id;

my $room_alias = "#50fed-room-alias:$local_server_name";
$datastore->{room_aliases}{$room_alias} = $room_id;

my $await_request_send_join;

if( $versionprefix eq "v1" ) {
Expand All @@ -86,7 +80,18 @@ sub assert_is_valid_pdu {
# that 404 response from SyTest and that fallback mechanism to test that the
# homeserver can query the v1 endpoint, and correctly handles responses from
# it.
$await_request_send_join = $inbound_server->await_request_v1_send_join( $room_id );
$await_request_send_join = Future->needs_all(
$inbound_server->await_request_v2_send_join( $room_id )
->then( sub {
my ( $req, $room_id, $event_id ) = @_;
$req->respond( HTTP::Response->new(
404, "Not found", [ Content_length => 0 ], "",
) );

Future->done
}),
$inbound_server->await_request_v1_send_join( $room_id )
);
}
elsif( $versionprefix eq "v2" ) {
$await_request_send_join = $inbound_server->await_request_v2_send_join( $room_id );
Expand Down Expand Up @@ -811,19 +816,14 @@ sub assert_is_valid_pdu {
my $local_server_name = $inbound_server->server_name;
my $datastore = $inbound_server->datastore;

my $room = SyTest::Federation::Room->new(
datastore => $datastore,
);

$room->create_initial_events(
my $room_alias = "#no_create_event:$local_server_name";
my $room = $datastore->create_room(
creator => $creator_id,
alias => $room_alias,
);

my $room_id = $room->room_id;

my $room_alias = "#no_create_event:$local_server_name";
$datastore->{room_aliases}{$room_alias} = $room_id;

Future->needs_all(
$inbound_server->await_request_make_join( $room_id, $user->user_id )->then( sub {
my ( $req, $room_id, $user_id ) = @_;
Expand All @@ -839,10 +839,12 @@ sub assert_is_valid_pdu {
event => $proto,
} );

log_if_fail "make_join resp", $proto;

Future->done;
}),

$inbound_server->await_request_send_join( $room_id )->then( sub {
$inbound_server->await_request_v2_send_join( $room_id )->then( sub {
my ( $req, $room_id, $event_id ) = @_;

$req->method eq "PUT" or
Expand All @@ -859,11 +861,10 @@ sub assert_is_valid_pdu {
@auth_chain = grep { $_->{type} ne 'm.room.create' } @auth_chain;

$req->respond_json(
# /v1/send_join has an extraneous [200, ...] wrapper (see MSC1802)
my $response = [ 200, {
my $response = {
auth_chain => \@auth_chain,
state => [ $room->current_state_events ],
} ]
}
);

log_if_fail "send_join response", $response;
Expand Down Expand Up @@ -901,20 +902,16 @@ sub assert_is_valid_pdu {
my $local_server_name = $inbound_server->server_name;
my $datastore = $inbound_server->datastore;

my $room = SyTest::Federation::Room->new(
datastore => $datastore,
);

$room->create_initial_events(
my $room_alias = "#no_create_event:$local_server_name";
my $room = $datastore->create_room(
creator => $creator_id,
alias => $room_alias,

room_version => 'sytest-room-ver',
);

my $room_id = $room->room_id;

my $room_alias = "#inconsistent-room-ver:$local_server_name";
$datastore->{room_aliases}{$room_alias} = $room_id;

Future->needs_all(
$inbound_server->await_request_make_join( $room_id, $user->user_id )->then( sub {
my ( $req, $room_id, $user_id ) = @_;
Expand All @@ -933,7 +930,7 @@ sub assert_is_valid_pdu {
Future->done;
}),

$inbound_server->await_request_send_join( $room_id )->then( sub {
$inbound_server->await_request_v2_send_join( $room_id )->then( sub {
my ( $req, $room_id, $event_id ) = @_;

$req->method eq "PUT" or
Expand All @@ -943,15 +940,14 @@ sub assert_is_valid_pdu {
log_if_fail "send_join event", $event;

my @auth_chain = $datastore->get_auth_chain_events(
map { $_->[0] } @{ $event->{auth_events} }
@{ $room->event_ids_from_refs( $event->{auth_events} ) }
);

$req->respond_json(
# /v1/send_join has an extraneous [200, ...] wrapper (see MSC1802)
my $response = [ 200, {
my $response = {
auth_chain => \@auth_chain,
state => [ $room->current_state_events ],
} ]
}
);

log_if_fail "send_join response", $response;
Expand Down
1 change: 0 additions & 1 deletion tests/50federation/50no-deextrem-outliers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
->on_done( sub {
my ( $pl_event_b ) = @_;
$pl_event_b_id = $room->id_for_event( $pl_event_b );
$room->insert_event( $pl_event_b );
}),
)->then( sub {
my %state_before_c = %{ $room->{current_state} };
Expand Down