From d4257d7acb662c5430aeead93311747845abea6e Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 24 Sep 2020 12:08:40 +0100 Subject: [PATCH 1/2] Update state idempotency tests to not use initialsync --- tests/30rooms/01state.pl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/30rooms/01state.pl b/tests/30rooms/01state.pl index d6b672fdd..b7eb6c6d9 100644 --- a/tests/30rooms/01state.pl +++ b/tests/30rooms/01state.pl @@ -242,14 +242,24 @@ sub get_test_state { my ( $user, $room_id, $type ) = @_; - matrix_initialsync_room( $user, $room_id, limit => 0 )->then( sub { - my ( $body ) = @_; + matrix_sync( $user, + filter => '{"room":{"rooms":["'.$room_id.'"]},"account_data":{},"presence":{"types":[]}}', + update_next_batch => 0, + set_presence => "offline", + )->then( sub { + my ( $body ) = @_; - my %state_by_type = partition_by { $_->{type} } @{ $body->{state} }; + # We expect the event to be in the initial sync + sync_timeline_contains( $body, $room_id, sub { + my ( $event ) = @_; + return unless $event->{type} eq $type and $event->{state_key} eq $user->user_id; - my $event_id = $state_by_type{ $type }[0]{event_id}; + log_if_fail "Event for ${\$user->user_id}", $event; + Future->done( $event->{event_id} ); + return 1; + }) or die "Expected event not in initial sync"; - Future->done( $event_id ); + return 0; }); } @@ -259,7 +269,7 @@ sub set_test_state matrix_put_room_state( $user, $room_id, type => "a.test.state.type", - state_key => "", + state_key => $user->user_id, content => { "a_key" => "a_value" }, )->then( sub { get_test_state( $user, $room_id, "a.test.state.type" ); From 462418ad536f8bd4fb500e7bb5b8969e66f2536d Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 24 Sep 2020 12:09:14 +0100 Subject: [PATCH 2/2] Remove warning comments --- tests/30rooms/01state.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/30rooms/01state.pl b/tests/30rooms/01state.pl index b7eb6c6d9..279405377 100644 --- a/tests/30rooms/01state.pl +++ b/tests/30rooms/01state.pl @@ -277,7 +277,6 @@ sub set_test_state } test "Setting state twice is idempotent", - # TODO: deprecated endpoint used in this test # Setting synced to 1 inserts a m.room.test object into the # timeline which this test does not expect requires => [ local_user_and_room_fixtures( room_opts => { synced => 0 } ) ], @@ -302,7 +301,6 @@ sub set_test_state }; test "Joining room twice is idempotent", - # TODO: deprecated endpoint used in this test requires => [ local_user_and_room_fixtures() ], check => sub {