Skip to content

Commit

Permalink
Update a number of tests to check non-v1 rooms (#716)
Browse files Browse the repository at this point in the history
There are plenty of others which need updating, but it's an improvement.
  • Loading branch information
richvdh authored Oct 8, 2019
1 parent 598127c commit 5ef8265
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tests/50federation/36-state.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ sub get_state_ids_from_server {
test "Inbound federation can get state for a room",
requires => [
$main::OUTBOUND_CLIENT,
federated_rooms_fixture( room_opts => { room_version => "1" } ),
federated_rooms_fixture(),
],

do => sub {
my ( $outbound_client, $creator, $user_id, $room ) = @_;
my $first_home_server = $creator->server_name;

my $room_id = $room->room_id;
my $event_id = $room->id_for_event($room->{prev_events}[-1]);

$outbound_client->do_request_json(
method => "GET",
hostname => $first_home_server,
uri => "/v1/state/$room_id",
params => {
event_id => $room->{prev_events}[-1]->{event_id},
event_id => $event_id,
}
)->then( sub {
my ( $body ) = @_;
Expand All @@ -39,9 +40,10 @@ sub get_state_ids_from_server {
my $power_event = $room->get_current_state_event( "m.room.power_levels", "" );

foreach my $ev ( $create_event, $power_event ) {
log_if_fail "ev", $ev;
my $state_event_id = $room->id_for_event( $ev );
my $type = $ev->{type};
any { $_->{event_id} eq $ev->{event_id} } @{ $state }
log_if_fail "Looking for $type event", $ev;
any { $room->id_for_event( $_ ) eq $state_event_id } @{ $state }
or die "Missing $type event";
}

Expand All @@ -52,7 +54,7 @@ sub get_state_ids_from_server {

test "Inbound federation of state requires event_id as a mandatory paramater",
requires => [ $main::OUTBOUND_CLIENT,
local_user_and_room_fixtures( room_opts => { room_version => "1" } ),
local_user_and_room_fixtures(),
federation_user_id_fixture() ],

do => sub {
Expand All @@ -70,18 +72,19 @@ sub get_state_ids_from_server {
test "Inbound federation can get state_ids for a room",
requires => [
$main::OUTBOUND_CLIENT,
federated_rooms_fixture( room_opts => { room_version => "1" } ),
federated_rooms_fixture(),
],

do => sub {
my ( $outbound_client, $creator, $user_id, $room ) = @_;
my $first_home_server = $creator->server_name;

my $room_id = $room->room_id;
my $event_id = $room->id_for_event($room->{prev_events}[-1]);

get_state_ids_from_server(
$outbound_client, $first_home_server,
$room_id, $room->{prev_events}[-1]->{event_id},
$room_id, $event_id,
)->then( sub {
my ( $body ) = @_;
log_if_fail "Body", $body;
Expand All @@ -93,9 +96,10 @@ sub get_state_ids_from_server {
my $power_event = $room->get_current_state_event( "m.room.power_levels", "" );

foreach my $ev ( $create_event, $power_event ) {
log_if_fail "ev", $ev;
my $state_event_id = $room->id_for_event( $ev );
my $type = $ev->{type};
any { $_ eq $ev->{event_id} } @{ $state }
log_if_fail "Looking for $type event", $ev;
any { $_ eq $state_event_id } @{ $state }
or die "Missing $type event";
}

Expand All @@ -105,7 +109,7 @@ sub get_state_ids_from_server {

test "Inbound federation of state_ids requires event_id as a mandatory paramater",
requires => [ $main::OUTBOUND_CLIENT,
local_user_and_room_fixtures( room_opts => { room_version => "1" } ),
local_user_and_room_fixtures(),
federation_user_id_fixture() ],

do => sub {
Expand All @@ -123,7 +127,6 @@ sub get_state_ids_from_server {
requires => [ $main::OUTBOUND_CLIENT, $main::INBOUND_SERVER,
local_user_and_room_fixtures(
user_opts => { with_events => 1 },
room_opts => { room_version => "1" },
),
federation_user_id_fixture() ],

Expand All @@ -132,7 +135,6 @@ sub get_state_ids_from_server {
my $first_home_server = $creator->server_name;

my $room;
my $sent_event;

$outbound_client->join_room(
server_name => $first_home_server,
Expand All @@ -153,14 +155,12 @@ sub get_state_ids_from_server {

# Generate another one and do send it so it will refer to the
# previous in its prev_events field
$sent_event = $room->create_and_insert_event(
my ( $sent_event, $sent_event_id ) = $room->create_and_insert_event(
type => "m.room.message",

# This would be done by $room->create_and_insert_event anyway but lets be
# sure for this test
prev_events => [
[ $missing_event->{event_id}, $missing_event->{hashes} ],
],
prev_events => $room->make_event_refs( $missing_event ),

sender => $user_id,
content => {
Expand Down Expand Up @@ -189,7 +189,7 @@ sub get_state_ids_from_server {
my ( $body ) = @_;
log_if_fail "send_transaction response", $body;
assert_ok(
defined( $body->{pdus}->{ $sent_event->{event_id} }->{error} ),
defined( $body->{pdus}->{ $sent_event_id }->{error} ),
"/send accepted faulty event",
);

Expand Down

0 comments on commit 5ef8265

Please sign in to comment.