From 3d108ca48656d8cccc5e8782ce14283677c3c0d3 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 15 Jan 2024 17:35:35 -0800 Subject: [PATCH] tests: remove author from batch signing --- node/bft/events/src/certificate_response.rs | 6 +++++- node/bft/src/helpers/storage.rs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/node/bft/events/src/certificate_response.rs b/node/bft/events/src/certificate_response.rs index 0b02b99f4b..f0942dfc32 100644 --- a/node/bft/events/src/certificate_response.rs +++ b/node/bft/events/src/certificate_response.rs @@ -108,8 +108,12 @@ pub mod prop_tests { any::() .prop_flat_map(|committee| (Just(committee.clone()), any_batch_header(&committee))) .prop_map(|(committee, batch_header)| { - let CommitteeContext(_, validator_set) = committee; + let CommitteeContext(_, mut validator_set) = committee; let mut rng = TestRng::default(); + + // Remove the author from the validator set passed to create the batch + // certificate, the author should not sign their own batch. + validator_set.0.retain(|v| v.address != batch_header.author()); BatchCertificate::from(batch_header.clone(), sign_batch_header(&validator_set, &batch_header, &mut rng)) .unwrap() }) diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 0649001e12..071e47a7be 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -1125,6 +1125,12 @@ pub mod prop_tests { &mut rng, ) .unwrap(); + + // Remove the author from the validator set passed to create the batch + // certificate, the author should not sign their own batch. + let mut validators = validators.clone(); + validators.remove(signer); + let certificate = BatchCertificate::from( batch_header.clone(), sign_batch_header(&ValidatorSet(validators), &batch_header, &mut rng),