Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3cf86ef
grandpa: update notif protocol name
acatangiu Dec 9, 2021
fbf7cf5
grandpa: add chain id prefix to protocol name
acatangiu Dec 10, 2021
2b22762
grandpa: beautify protocol name handling
acatangiu Dec 10, 2021
206beaa
grandpa: prepend genesis hash to protocol name
acatangiu Dec 10, 2021
952e0a7
chain-spec: add optional 'fork_id'
acatangiu Dec 13, 2021
758ff84
grandpa: protocol_name mod instead of struct
acatangiu Dec 13, 2021
b3a0243
beefy: add genesis hash prefix to protocol name
acatangiu Dec 13, 2021
44baf42
chainspec: add fork_id
acatangiu Dec 14, 2021
0f9d6cc
grandpa: simplify protocol name
acatangiu Dec 14, 2021
393c8cf
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Dec 14, 2021
482f0bc
grandpa: contain protocol name building logic
acatangiu Dec 16, 2021
1dda847
beefy: contain protocol name building logic
acatangiu Dec 16, 2021
1262cce
grandpa: fix tests
acatangiu Dec 16, 2021
f3a006d
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Dec 16, 2021
b4b8a74
fix merge damage
acatangiu Dec 16, 2021
0de4362
fix docs reference visibility
acatangiu Dec 20, 2021
a07eec6
Update client/finality-grandpa/src/lib.rs
acatangiu Dec 20, 2021
1aa9753
Update client/finality-grandpa/src/communication/mod.rs
acatangiu Dec 20, 2021
5673f48
Update client/beefy/src/lib.rs
acatangiu Dec 20, 2021
5a6a7b2
Update client/beefy/src/lib.rs
acatangiu Dec 20, 2021
d70ed35
avoid using hash default, even for protocol names
acatangiu Jan 4, 2022
d5802f6
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Jan 4, 2022
3c7f699
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Jan 5, 2022
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
Prev Previous commit
Next Next commit
grandpa: fix tests
  • Loading branch information
acatangiu committed Dec 16, 2021
commit 1262cce367c972777d649b6ba7d39fe4c793f9f0
41 changes: 20 additions & 21 deletions client/finality-grandpa/src/communication/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ pub(super) struct PeerReport {
#[cfg(test)]
mod tests {
use super::{environment::SharedVoterSetState, *};
use crate::communication;
use sc_network::config::Role;
use sc_network_gossip::Validator as GossipValidatorT;
use sc_network_test::Block;
Expand All @@ -1682,7 +1683,7 @@ mod tests {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: communication::grandpa_protocol_name::NAME.into(),
}
}

Expand Down Expand Up @@ -1844,13 +1845,13 @@ mod tests {

// messages from old rounds are expired.
for round_num in 1u64..last_kept_round {
let topic = crate::communication::round_topic::<Block>(round_num, 1);
let topic = communication::round_topic::<Block>(round_num, 1);
assert!(is_expired(topic, &[1, 2, 3]));
}

// messages from not-too-old rounds are not expired.
for round_num in last_kept_round..10 {
let topic = crate::communication::round_topic::<Block>(round_num, 1);
let topic = communication::round_topic::<Block>(round_num, 1);
assert!(!is_expired(topic, &[1, 2, 3]));
}
}
Expand Down Expand Up @@ -2266,7 +2267,7 @@ mod tests {
// we accept messages from rounds 9, 10 and 11
// therefore neither of those should be considered expired
for round in &[9, 10, 11] {
assert!(!is_expired(crate::communication::round_topic::<Block>(*round, 1), &[]))
assert!(!is_expired(communication::round_topic::<Block>(*round, 1), &[]))
}
}

Expand Down Expand Up @@ -2314,7 +2315,7 @@ mod tests {
if message_allowed(
peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
) {
allowed += 1;
Expand Down Expand Up @@ -2378,7 +2379,7 @@ mod tests {
assert!(!val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
));

Expand All @@ -2392,7 +2393,7 @@ mod tests {
assert!(!val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
));

Expand All @@ -2416,8 +2417,8 @@ mod tests {
auth_data: Vec::new(),
};

crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(2),
set_id: SetId(0),
message: commit,
Expand All @@ -2430,7 +2431,7 @@ mod tests {
assert!(val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(0),
&communication::global_topic::<Block>(0),
&commit,
));
}
Expand Down Expand Up @@ -2470,8 +2471,8 @@ mod tests {
auth_data: Vec::new(),
};

crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(1),
set_id: SetId(1),
message: commit,
Expand All @@ -2489,7 +2490,7 @@ mod tests {
assert!(message_allowed(
&peer1,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(1),
&communication::global_topic::<Block>(1),
&commit,
));

Expand All @@ -2498,7 +2499,7 @@ mod tests {
assert!(!message_allowed(
&peer2,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(1),
&communication::global_topic::<Block>(1),
&commit,
));
}
Expand All @@ -2515,8 +2516,8 @@ mod tests {
auth_data: Vec::new(),
};

crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(round),
set_id: SetId(set_id),
message: commit,
Expand All @@ -2536,15 +2537,13 @@ mod tests {

// a commit message for round 1 that finalizes the same height as we
// have observed previously should not be expired
assert!(
!message_expired(crate::communication::global_topic::<Block>(1), &commit(1, 1, 2),)
);
assert!(!message_expired(communication::global_topic::<Block>(1), &commit(1, 1, 2),));

// it should be expired if it is for a lower block
assert!(message_expired(crate::communication::global_topic::<Block>(1), &commit(1, 1, 1)));
assert!(message_expired(communication::global_topic::<Block>(1), &commit(1, 1, 1)));

// or the same block height but from the previous round
assert!(message_expired(crate::communication::global_topic::<Block>(1), &commit(0, 1, 2)));
assert!(message_expired(communication::global_topic::<Block>(1), &commit(0, 1, 2)));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/src/communication/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn config() -> crate::Config {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
}
}

Expand Down
23 changes: 12 additions & 11 deletions client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use substrate_test_runtime_client::runtime::BlockNumber;
use tokio::runtime::{Handle, Runtime};

use authorities::AuthoritySet;
use communication::grandpa_protocol_name;
use sc_block_builder::BlockBuilderProvider;
use sc_consensus::LongestChain;
use sc_keystore::LocalKeystore;
Expand Down Expand Up @@ -97,7 +98,7 @@ impl GrandpaTestNet {
impl GrandpaTestNet {
fn add_authority_peer(&mut self) {
self.add_full_peer_with_config(FullPeerConfig {
notifications_protocols: vec![communication::grandpa_protocol_name::NAME.into()],
notifications_protocols: vec![grandpa_protocol_name::NAME.into()],
is_authority: true,
..Default::default()
})
Expand All @@ -121,7 +122,7 @@ impl TestNetFactory for GrandpaTestNet {

fn add_full_peer(&mut self) {
self.add_full_peer_with_config(FullPeerConfig {
notifications_protocols: vec![communication::grandpa_protocol_name::NAME.into()],
notifications_protocols: vec![grandpa_protocol_name::NAME.into()],
is_authority: false,
..Default::default()
})
Expand Down Expand Up @@ -274,7 +275,7 @@ fn initialize_grandpa(
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
Expand Down Expand Up @@ -424,7 +425,7 @@ fn finalize_3_voters_1_full_observer() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
Expand Down Expand Up @@ -515,7 +516,7 @@ fn transition_3_voters_twice_1_full_observer() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
Expand Down Expand Up @@ -974,7 +975,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
};

let set_state = {
Expand Down Expand Up @@ -1014,7 +1015,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
Expand Down Expand Up @@ -1055,7 +1056,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
Expand Down Expand Up @@ -1219,7 +1220,7 @@ fn finalize_3_voters_1_light_observer() {
local_role: Role::Full,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
net.peers[3].data.lock().take().expect("link initialized at startup; qed"),
net.peers[3].network_service().clone(),
Expand Down Expand Up @@ -1266,7 +1267,7 @@ fn voter_catches_up_to_latest_round_when_behind() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net.lock().peer(peer_id).network_service().clone(),
Expand Down Expand Up @@ -1384,7 +1385,7 @@ where
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name_prefix: "/test".into(),
protocol_name: grandpa_protocol_name::NAME.into(),
};

let network =
Expand Down