Skip to content

Commit

Permalink
tests: remove author from batch signing
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed Jan 16, 2024
1 parent 203f9e0 commit 3d108ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion node/bft/events/src/certificate_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ pub mod prop_tests {
any::<CommitteeContext>()
.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()
})
Expand Down
6 changes: 6 additions & 0 deletions node/bft/src/helpers/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 3d108ca

Please sign in to comment.