Skip to content

Commit

Permalink
Add test for PDU limit on transactions API (#555)
Browse files Browse the repository at this point in the history
* Add test for PDU limit on transactions API

* Fixes and additional check for under-limit transactions

* Remove
  • Loading branch information
anoadragon453 authored and hawkowl committed Jan 31, 2019
1 parent f8933f1 commit 33607b6
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/50federation/51transactions.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
test "Server correctly handles transactions that break edu limits",
requires => [ $main::OUTBOUND_CLIENT, $main::INBOUND_SERVER, $main::HOMESERVER_INFO[0],
local_user_and_room_fixtures(), room_alias_name_fixture() ],

do => sub {
my ( $outbound_client, $inbound_server, $info, $creator, $room_id, $room_alias_name ) = @_;

my $local_server_name = $info->server_name;

my $remote_server_name = $inbound_server->server_name;

my $room_alias = "#$room_alias_name:$remote_server_name";

$outbound_client->join_room(
server_name => $local_server_name,
room_id => $room_id,
user_id => $creator->user_id,
)->then( sub {
my ( $room ) = @_;

my $new_event = $room->create_and_insert_event(
type => "m.room.message",

sender => $creator->user_id,
content => {
body => "Message 1",
},
);

# Generate two transactions, one that breaks the 50 PDU limit and one
# that does not
my @bad_pdus = ( $new_event ) x 51;
my @good_pdus = ( $new_event ) x 10;

Future->needs_all(
# Send the transaction to the client and expect a fail
$outbound_client->send_transaction(
pdus => \@bad_pdus,
destination => $local_server_name,
)->main::expect_http_400(),

# Send the transaction to the client and expect a succeed
$outbound_client->send_transaction(
pdus => \@good_pdus,
destination => $local_server_name,
)->then( sub {
my ( $response ) = @_;

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

0 comments on commit 33607b6

Please sign in to comment.