diff --git a/code/node/src/util/make_node.rs b/code/node/src/util/make_node.rs index 0a97f0c7e..637d8df6e 100644 --- a/code/node/src/util/make_node.rs +++ b/code/node/src/util/make_node.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use std::time::Duration; -use malachite_test::utils::FixedProposer; +use malachite_test::utils::RotateProposer; use malachite_test::{Address, Height, PrivateKey, TestContext, ValidatorSet}; use crate::network::broadcast; @@ -20,7 +20,7 @@ pub async fn make_broadcast_node( ) -> Node { let start_height = Height::new(1); let ctx = TestContext::new(private_key); - let proposer_selector = Arc::new(FixedProposer::new(validator_set.validators[0].address)); + let proposer_selector = Arc::new(RotateProposer); let proposal_builder = Arc::new(TestValueBuilder::default()); let params = Params { @@ -65,7 +65,7 @@ pub async fn make_gossip_node( let start_height = Height::new(1); let ctx = TestContext::new(private_key); - let proposer_selector = Arc::new(FixedProposer::new(validator_set.validators[0].address)); + let proposer_selector = Arc::new(RotateProposer); let proposal_builder = Arc::new(TestValueBuilder::default()); let params = Params { diff --git a/code/test/src/utils.rs b/code/test/src/utils.rs index 25c583f58..ef00c4314 100644 --- a/code/test/src/utils.rs +++ b/code/test/src/utils.rs @@ -15,11 +15,16 @@ pub struct RotateProposer; impl ProposerSelector for RotateProposer { fn select_proposer( &self, - _height: Height, + height: Height, round: Round, validator_set: &ValidatorSet, ) -> Address { - let proposer_index = round.as_i64() as usize % validator_set.validators.len(); + assert!(round != Round::Nil && round.as_i64() >= 0); + + let height = height.as_u64() as usize; + let round = round.as_i64() as usize; + + let proposer_index = (height - 1 + round) % validator_set.validators.len(); validator_set.validators[proposer_index].address } }