Skip to content

Commit 9fa1325

Browse files
Deflake 'uploading signed devices gets propagated over federation' (#1409)
Co-authored-by: Eric Eastwood <[email protected]>
1 parent 9fce947 commit 9fa1325

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/41end-to-end-keys/08-cross-signing.pl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@
563563

564564
my $user2_id = $user2->user_id;
565565
my $user2_device = $user2->device_id;
566+
my $user2_device_key_id_hash = "EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ";
567+
my $user2_device_key_id = "ed25519:$user2_device_key_id_hash";
566568

567569
my $room_id;
568570

@@ -573,8 +575,7 @@
573575
"user_id" => $user2_id,
574576
"usage" => ["self_signing"],
575577
"keys" => {
576-
"ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ"
577-
=> "EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ",
578+
$user2_device_key_id => $user2_device_key_id_hash,
578579
},
579580
};
580581
sign_json(
@@ -639,10 +640,10 @@
639640
})->then( sub {
640641
sign_json(
641642
$device, secret_key => $self_signing_secret_key,
642-
origin => $user2_id, key_id => "ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ"
643+
origin => $user2_id, key_id => $user2_device_key_id
643644
);
644645
log_if_fail "sent signature", $device;
645-
$cross_signature = $device->{signatures}->{$user2_id}->{"ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ"};
646+
$cross_signature = $device->{signatures}->{$user2_id}->{$user2_device_key_id};
646647
matrix_upload_signatures( $user2, {
647648
$user2_id => {
648649
$user2_device => $device
@@ -661,11 +662,19 @@
661662
# On server0, user1 syncs until they see user2's device. This is racey: the
662663
# sync may complete before the signatures have uploaded, propagated over
663664
# federation to server 1 and then over replication to the sync worker.
665+
#
666+
# Thus we wait for the expected signatures to show up inside this function.
664667
matrix_get_e2e_keys( $user1, $user2_id )->then( sub {
665668
my ( $content ) = @_;
666669
log_if_fail "key query content2", $content;
667-
$content->{device_keys}{$user2_id}{$user2_device}{"signatures"}
670+
my $sigs = $content->{device_keys}{$user2_id}{$user2_device}{"signatures"}
668671
or die "No 'signatures' key present";
672+
673+
exists $sigs->{$user2_id}
674+
&& exists $sigs->{$user2_id}{$user2_device_key_id}
675+
&& $sigs->{$user2_id}{$user2_device_key_id} eq $cross_signature
676+
or die "Expected cross-signature ($user2_device_key_id}->$cross_signature not visible";
677+
669678
Future->done( $content );
670679
});
671680
};
@@ -674,15 +683,6 @@
674683

675684
log_if_fail "key query content3", $content;
676685

677-
# Check that fetching the devices again returns the new signature
678-
assert_json_keys( $content->{device_keys}->{$user2_id}->{$user2_device}, "signatures" );
679-
680-
assert_deeply_eq( $content->{device_keys}->{$user2_id}->{$user2_device}->{signatures}, {
681-
$user2_id => {
682-
"ed25519:EmkqvokUn8p+vQAGZitOk4PWjp7Ukp3txV2TbMPEiBQ" => $cross_signature
683-
},
684-
} );
685-
686686
# Check that we still see the master key when querying the devices.
687687
assert_json_keys( $content->{master_keys}, $user2_id );
688688
assert_json_keys( $content->{master_keys}->{$user2_id}, "keys");

0 commit comments

Comments
 (0)