Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Dec 9, 2024
1 parent 83a032f commit 738845e
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions testnet/stacks-node/src/tests/signer/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{env, thread};

use clarity::vm::types::PrincipalData;
use libsigner::v0::messages::{
BlockRejection, BlockResponse, MessageSlotID, MinerSlotID, RejectCode, SignerMessage,
BlockAccepted, BlockRejection, BlockResponse, MessageSlotID, MinerSlotID, RejectCode, SignerMessage
};
use libsigner::{BlockProposal, SignerSession, StackerDBSession, VERSION_STRING};
use stacks::address::AddressHashMode;
Expand Down Expand Up @@ -8614,8 +8614,6 @@ fn block_proposal_max_age_rejections() {
signer_test.boot_to_epoch_3();
let short_timeout = Duration::from_secs(30);

// Make sure no other block approvals are in the system.
test_observer::clear();
info!("------------------------- Send Block Proposal To Signers -------------------------");
let info_before = get_chain_info(&signer_test.running_nodes.conf);
let mut block = NakamotoBlock {
Expand All @@ -8628,7 +8626,7 @@ fn block_proposal_max_age_rejections() {
.block_proposal_max_age_secs
.saturating_add(1),
);
let _block_signer_signature_hash_1 = block.header.signer_signature_hash();
let block_signer_signature_hash_1 = block.header.signer_signature_hash();
signer_test.propose_block(block.clone(), short_timeout);

// Next propose a recent invalid block
Expand All @@ -8647,31 +8645,27 @@ fn block_proposal_max_age_rejections() {
else {
return None;
};
assert!(matches!(
message,
SignerMessage::BlockResponse(BlockResponse::Rejected(_))
));
let SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
reason_code,
signer_signature_hash,
signature,
..
})) = message
else {
panic!("Received an unexpected block approval from the signer");
};
assert_eq!(
signer_signature_hash, block_signer_signature_hash_2,
"Received a rejection for an unexpected block: {signer_signature_hash}"
);
assert!(
matches!(reason_code, RejectCode::SortitionViewMismatch),
"Received a rejection for an unexpected reason: {reason_code}"
);
Some(signature)
match message {
SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
signer_signature_hash,
signature,
..
})) => {
assert_eq!(signer_signature_hash, block_signer_signature_hash_2, "We should only reject the second block");
Some(signature)
}
SignerMessage::BlockResponse(BlockResponse::Accepted(BlockAccepted {
signer_signature_hash,
..
})) => {
assert_ne!(signer_signature_hash, block_signer_signature_hash_1, "We should never have accepted block");
None
}
_ => None,
}
})
.collect();
Ok(rejections.len() == num_signers)
Ok(rejections.len() > num_signers * 7/10)
})
.expect("Timed out waiting for block rejections");

Expand Down

0 comments on commit 738845e

Please sign in to comment.