Skip to content

Commit

Permalink
Attempt to deflake Device list doesn't change if remote server is down
Browse files Browse the repository at this point in the history
Hopefully closes #1136
  • Loading branch information
David Robertson committed Sep 14, 2021
1 parent 2a62988 commit d70e06a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/50federation/40devicelists.pl
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@
})
);

# First we succesfully request the remote user's keys while the remote server is up.
# First we successfully request the remote user's keys while the remote server is up.
# We do this once they share a room.
matrix_create_room(
matrix_create_room_synced(
$local_user,
preset => "public_chat",
)->then( sub {
Expand All @@ -576,6 +576,14 @@
room_id => $room_id,
user_id => $outbound_client_user,
)
# Wait for the user to see the join.
})->then( sub {
matrix_sync($local_user)
})->then( sub {
sync_until_user_in_device_list(
$local_user,
new_User(server_name => "", http => "", user_id => $outbound_client_user)
)
})->then( sub {
do_request_json_for( $local_user,
method => "POST",
Expand All @@ -589,8 +597,17 @@
})->then( sub {
( $first_keys_query_body ) = @_;
map {$_->cancel} @respond_with_keys;
log_if_fail "first_keys_query_body";
log_if_fail (Dumper $first_keys_query_body);

})->then( sub {
# Need to ensure the local server has enough time to cache/store our response.
# This will definitely have happened when the user's sync result sees
# $outbound_client_user in the list of changes for a second time)
sync_until_user_in_device_list(
$local_user,
new_User(server_name => "", http => "", user_id => $outbound_client_user)
)
})->then( sub {
# We take the remote server 'offline' and then make the same request
# for the users keys. We expect no change in the keys. We respond with
# 400 instead of 503 to avoid the server being marked as down.
Expand Down Expand Up @@ -629,6 +646,7 @@
}
};

log_if_fail "second_keys_query_body";
log_if_fail (Dumper $second_keys_query_body);
assert_deeply_eq( $second_keys_query_body->{ device_keys }, $first_keys_query_body->{ device_keys }, "Query matches while federation server is down." );
Future->done(1)
Expand Down

0 comments on commit d70e06a

Please sign in to comment.