Skip to content

Commit 7147f47

Browse files
authored
chore: Allow any order of change actions in purging_non_finalized_blocks_test (#4033)
This test's expectation has to be adapted whenever the order of the block proposals returned by the purger changes. This usually happens when the block payload struct is updated in a way that changes the lexicographic order of the block hashes. With this PR we allow any order of the returned change actions.
1 parent cdccf1e commit 7147f47

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

rs/consensus/src/consensus/purger.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,10 @@ mod tests {
493493
crypto::CryptoHash,
494494
CryptoHashOfState, SubnetId,
495495
};
496-
use std::sync::{Arc, RwLock};
496+
use std::{
497+
collections::HashSet,
498+
sync::{Arc, RwLock},
499+
};
497500

498501
#[test]
499502
fn test_purger() {
@@ -890,7 +893,10 @@ mod tests {
890893
.replace(finalized_block_proposal_1.content.as_ref().height);
891894

892895
let pool_reader = PoolReader::new(&pool);
893-
let remove_from_validated_changeset: Vec<_> = purger
896+
// Ignored because the `Hash` implementation of `Block` does not
897+
// access the mutable payload `Thunk`.
898+
#[allow(clippy::mutable_key_type)]
899+
let remove_from_validated_changeset: HashSet<_> = purger
894900
.on_state_change(&pool_reader)
895901
.into_iter()
896902
.filter(|change_action| {
@@ -900,7 +906,7 @@ mod tests {
900906

901907
assert_eq!(
902908
remove_from_validated_changeset,
903-
vec![
909+
HashSet::from([
904910
ChangeAction::RemoveFromValidated(ConsensusMessage::Notarization(
905911
non_finalized_notarization_2
906912
)),
@@ -910,7 +916,7 @@ mod tests {
910916
ChangeAction::RemoveFromValidated(ConsensusMessage::BlockProposal(
911917
non_finalized_block_proposal_2_1
912918
)),
913-
]
919+
])
914920
);
915921
})
916922
}

0 commit comments

Comments
 (0)