Skip to content

Update state idempotency tests to not use initialsync#960

Open
neilalexander wants to merge 2 commits intodevelopfrom
neilalexander/statesync
Open

Update state idempotency tests to not use initialsync#960
neilalexander wants to merge 2 commits intodevelopfrom
neilalexander/statesync

Conversation

@neilalexander
Copy link
Copy Markdown
Contributor

This updates the following tests so that they no longer use initialsync:

Setting state twice is idempotent
Joining room twice is idempotent

Closes matrix-org/dendrite#1311.

@neilalexander neilalexander requested a review from a team September 24, 2020 11:18
Copy link
Copy Markdown
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit broken, as reflected in the fact the tests are failing.

Comment thread tests/30rooms/01state.pl
update_next_batch => 0,
set_presence => "offline",
)->then( sub {
my ( $body ) = @_;
Copy link
Copy Markdown
Member

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code yet again :/

Comment thread tests/30rooms/01state.pl

my $event_id = $state_by_type{ $type }[0]{event_id};
log_if_fail "Event for ${\$user->user_id}", $event;
Future->done( $event->{event_id} );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this creates a Future which is discarded?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I think this should be at the higher level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment thread tests/30rooms/01state.pl

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sync_timeline_contains returns a truthy result? shouldn't we be doing something with that result (otherwise the call is redundant?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 sub and match the event we want, that the Future wouldn't be done?

Comment thread tests/30rooms/01state.pl
matrix_put_room_state( $user, $room_id,
type => "a.test.state.type",
state_key => "",
state_key => $user->user_id,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change, ooi?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just to match the filter return unless $event->{type} eq $type and $event->{state_key} eq $user->user_id; in sync_timeline_contains.

@richvdh
Copy link
Copy Markdown
Member

richvdh commented Feb 23, 2021

@neilalexander is this still on your radar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix joining a room twice

2 participants