Skip to content
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

Check that direct to device messages work over federation #301

Merged
merged 3 commits into from
Sep 8, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions tests/46direct/03federation.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
test "Can recv device messages over federation",
requires => [ local_user_fixture(), remote_user_fixture(),
qw( can_recv_device_message ) ],

check => sub {
my ( $local_user, $remote_user ) = @_;

matrix_send_device_message( $local_user,
type => "my.test.type",
messages => {
$remote_user->user_id => {
$remote_user->device_id => {
message => "first",
},
},
},
)->then( sub {
# Download the first message again and acknowledge it.
matrix_recv_and_ack_device_message( $remote_user );
})->then( sub {
my ( $messages ) = @_;

assert_deeply_eq( $messages, [{
sender => $local_user->user_id,
type => "my.test.type",
content => {
message => "first",
},
}]);

matrix_send_device_message( $local_user,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not immediately obvious from the test why you're basically doing the same thing twice. Can you put a comment here to suggest why?

type => "my.test.type",
messages => {
$remote_user->user_id => {
$remote_user->device_id => {
message => "second",
},
},
},
);
})->then( sub {
# Download the second message and acknowledge it.
matrix_recv_and_ack_device_message( $remote_user );
})->then( sub {
my ( $messages ) = @_;

assert_deeply_eq( $messages, [{
sender => $local_user->user_id,
type => "my.test.type",
content => {
message => "second",
},
}]);

Future->done(1);
});
};