From b699f7e93d0c7b986e723f455138cdfbc145987b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 9 Oct 2019 21:01:44 +0100 Subject: [PATCH] Regression test for sync cache consistency bug (#718) (though note also that this requires synapse to run in worker mode, with some replication-torturing patches, to show up the issue.) --- tests/31sync/07invited.pl | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/31sync/07invited.pl b/tests/31sync/07invited.pl index 86434a6cf..6fa40c0fc 100644 --- a/tests/31sync/07invited.pl +++ b/tests/31sync/07invited.pl @@ -93,3 +93,51 @@ Future->done(1); }) }; + + +test "Newly joined room is included in an incremental sync after invite", + # matrix-org/synapse#4422 + requires => [ + local_user_and_room_fixtures(), + local_user_fixture( with_events => 0 ), + qw( can_sync ), + ], + + check => sub { + my ( $creator, $room_id, $user ) = @_; + + matrix_sync( $user )->then( sub { + matrix_invite_user_to_room_synced( + $creator, $user, $room_id, + ); + })->then( sub { + matrix_sync_again( $user ); + })->then( sub { + my ( $body ) = @_; + log_if_fail "post-invite sync", $body; + + my $room = $body->{rooms}{invite}{$room_id}; + assert_json_keys( $room, qw( invite_state ) ); + assert_json_keys( $room->{invite_state}, qw( events ) ); + + # accept the invite + matrix_join_room( $user, $room_id ); + })->then( sub { + # wait for the sync to turn up + await_sync( $user, + check => sub { + return $_[0]->{rooms}{join}{$room_id}; + }, + ); + })->then( sub { + my ( $room ) = @_; + log_if_fail "post-join sync", $room; + + assert_json_keys( $room, qw( timeline state ephemeral )); + assert_json_keys( $room->{timeline}, qw( events limited prev_batch )); + assert_json_keys( $room->{state}, qw( events )); + assert_json_keys( $room->{ephemeral}, qw( events )); + + Future->done(1); + }) + };