diff --git a/node/network/gossip-support/src/lib.rs b/node/network/gossip-support/src/lib.rs index 8a6d08b27280..52c6ffc165be 100644 --- a/node/network/gossip-support/src/lib.rs +++ b/node/network/gossip-support/src/lib.rs @@ -291,14 +291,19 @@ impl State { ); } - let authorities = determine_relevant_authorities(ctx, relay_parent).await?; - let our_index = ensure_i_am_an_authority(keystore, &authorities).await?; + let all_authorities = determine_relevant_authorities(ctx, relay_parent).await?; + let our_index = ensure_i_am_an_authority(keystore, &all_authorities).await?; + let other_authorities = { + let mut authorities = all_authorities.clone(); + authorities.swap_remove(our_index); + authorities + }; - self.issue_connection_request(ctx, authorities.clone()).await?; + self.issue_connection_request(ctx, other_authorities).await?; if is_new_session { self.last_session_index = Some(session_index); - update_gossip_topology(ctx, our_index, authorities, relay_parent).await?; + update_gossip_topology(ctx, our_index, all_authorities, relay_parent).await?; } } } diff --git a/node/network/gossip-support/src/tests.rs b/node/network/gossip-support/src/tests.rs index f858ae1bc9cf..1ca76728adb9 100644 --- a/node/network/gossip-support/src/tests.rs +++ b/node/network/gossip-support/src/tests.rs @@ -92,20 +92,27 @@ async fn overseer_recv(overseer: &mut VirtualOverseer) -> AllMessages { } fn authorities() -> Vec { + let mut authorities = other_authorities(); + authorities.push(Sr25519Keyring::Ferdie.public().into()); + authorities +} + +// Authorities other than ourselves: +fn other_authorities() -> Vec { vec![ Sr25519Keyring::Alice.public().into(), Sr25519Keyring::Bob.public().into(), Sr25519Keyring::Charlie.public().into(), - Sr25519Keyring::Ferdie.public().into(), Sr25519Keyring::Eve.public().into(), Sr25519Keyring::One.public().into(), + Sr25519Keyring::Two.public().into(), ] } fn neighbors() -> Vec { vec![ - Sr25519Keyring::One.public().into(), - Sr25519Keyring::Alice.public().into(), + Sr25519Keyring::Two.public().into(), + Sr25519Keyring::Charlie.public().into(), Sr25519Keyring::Eve.public().into(), ] } @@ -177,7 +184,7 @@ fn issues_a_connection_request_on_new_session() { peer_set, failed, }) => { - assert_eq!(validator_ids, authorities()); + assert_eq!(validator_ids, other_authorities()); assert_eq!(peer_set, PeerSet::Validation); failed.send(0).unwrap(); } @@ -245,7 +252,7 @@ fn issues_a_connection_request_on_new_session() { peer_set, failed, }) => { - assert_eq!(validator_ids, authorities()); + assert_eq!(validator_ids, other_authorities()); assert_eq!(peer_set, PeerSet::Validation); failed.send(0).unwrap(); } @@ -293,7 +300,7 @@ fn issues_a_connection_request_when_last_request_was_mostly_unresolved() { peer_set, failed, }) => { - assert_eq!(validator_ids, authorities()); + assert_eq!(validator_ids, other_authorities()); assert_eq!(peer_set, PeerSet::Validation); failed.send(2).unwrap(); } @@ -340,7 +347,7 @@ fn issues_a_connection_request_when_last_request_was_mostly_unresolved() { peer_set, failed, }) => { - assert_eq!(validator_ids, authorities()); + assert_eq!(validator_ids, other_authorities()); assert_eq!(peer_set, PeerSet::Validation); failed.send(1).unwrap(); }