-
Notifications
You must be signed in to change notification settings - Fork 55
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
Update state idempotency tests to not use initialsync #960
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copy-pasta'd from elsewhere, but I figured that if the timeline didn't hit the |
||
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} ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this creates a Future which is discarded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I think this should be at the higher level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly I have no idea. I still don't think I grok how this works looking at it again. |
||
return 1; | ||
}) or die "Expected event not in initial sync"; | ||
|
||
Future->done( $event_id ); | ||
return 0; | ||
}); | ||
} | ||
|
||
|
@@ -259,15 +269,14 @@ sub set_test_state | |
|
||
matrix_put_room_state( $user, $room_id, | ||
type => "a.test.state.type", | ||
state_key => "", | ||
state_key => $user->user_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change, ooi? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly just to match the filter |
||
content => { "a_key" => "a_value" }, | ||
)->then( sub { | ||
get_test_state( $user, $room_id, "a.test.state.type" ); | ||
}); | ||
} | ||
|
||
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 } ) ], | ||
|
@@ -292,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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no fan of the 3-space indentation convention, but 5 spaces doesn't seem an improvement...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS Code yet again :/