Skip to content

Commit

Permalink
Merge pull request #489 from matrix-org/matthew/disable-ll-on-incr-syncs
Browse files Browse the repository at this point in the history
more gappy sync tests
  • Loading branch information
ara4n authored Sep 11, 2018
2 parents aa65de6 + 904a87a commit 0e5472f
Showing 1 changed file with 157 additions and 0 deletions.
157 changes: 157 additions & 0 deletions tests/31sync/15lazy-members.pl
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,163 @@
};


test "Old members are included in gappy incr LL sync if they start speaking",
requires => [ local_user_fixtures( 3 ),
qw( can_sync ) ],

check => sub {
my ( $alice, $bob, $charlie ) = @_;

# Alice creates a public room,
# Bob and Charlie join.
# Bob sends 10 events into it
# Alice initial syncs with a filter on the last 10 events, and LL members
# Alice should see only Bob in the membership list.
# Charlie then sends 10 events
# Alice syncs again; she should get a gappy sync and see
# Charlie's membership (due to his timeline events).

my ( $filter_id, $room_id, $event_id_1, $event_id_2 );

matrix_create_filter( $alice, {
room => {
state => {
lazy_load_members => JSON::true
},
timeline => {
limit => 10
},
}
} )->then( sub {
( $filter_id ) = @_;

matrix_create_room_synced( $alice );
})->then( sub {
( $room_id ) = @_;
matrix_put_room_state( $alice, $room_id,
type => "m.room.name",
content => { name => "A room name" },
);
})->then( sub {
matrix_join_room( $bob, $room_id );
})->then( sub {
matrix_join_room( $charlie, $room_id );
})->then( sub {
repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $bob, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 20 ])
})->then( sub {
matrix_sync( $alice, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;
assert_room_members( $body, $room_id, [
$bob->user_id
]);

repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $charlie, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 20 ])
})->then( sub {
matrix_sync_again( $alice, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;
assert_room_members( $body, $room_id, [
$charlie->user_id,
]);
Future->done(1);
});
};


test "Members from the gap are included in gappy incr LL sync",
requires => [ local_user_fixtures( 4 ),
qw( can_sync ) ],

check => sub {
my ( $alice, $bob, $charlie, $dave ) = @_;

# Alice creates a public room,
# Bob and Charlie join.
# Bob sends 10 events into it
# Alice initial syncs with a filter on the last 10 events, and LL members
# Alice should see only Bob in the membership list.
# Dave joins
# Charlie then sends 10 events
# Alice syncs again; she should get a gappy sync and see both
# Charlie's membership (due to his timeline events) and
# Dave's membership (because he joined during the gap)

my ( $filter_id, $room_id, $event_id_1, $event_id_2 );

matrix_create_filter( $alice, {
room => {
state => {
lazy_load_members => JSON::true
},
timeline => {
limit => 10
},
}
} )->then( sub {
( $filter_id ) = @_;

matrix_create_room_synced( $alice );
})->then( sub {
( $room_id ) = @_;
matrix_put_room_state( $alice, $room_id,
type => "m.room.name",
content => { name => "A room name" },
);
})->then( sub {
matrix_join_room( $bob, $room_id );
})->then( sub {
matrix_join_room( $charlie, $room_id );
})->then( sub {
repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $bob, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 10 ])
})->then( sub {
matrix_sync( $alice, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;
assert_room_members( $body, $room_id, [
$bob->user_id
]);

matrix_join_room( $dave, $room_id );
})->then( sub {
repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $charlie, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 10 ])
})->then( sub {
matrix_sync_again( $alice, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;
assert_room_members( $body, $room_id, [
$charlie->user_id,
$dave->user_id
]);
Future->done(1);
});
};


test "We don't send redundant membership state across incremental syncs by default",
requires => [ local_user_fixtures( 3 ),
qw( can_sync ) ],
Expand Down

0 comments on commit 0e5472f

Please sign in to comment.