Skip to content

Commit 738845e

Browse files
committed
Fix test
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 83a032f commit 738845e

File tree

1 file changed

+21
-27
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+21
-27
lines changed

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{env, thread};
2323

2424
use clarity::vm::types::PrincipalData;
2525
use libsigner::v0::messages::{
26-
BlockRejection, BlockResponse, MessageSlotID, MinerSlotID, RejectCode, SignerMessage,
26+
BlockAccepted, BlockRejection, BlockResponse, MessageSlotID, MinerSlotID, RejectCode, SignerMessage
2727
};
2828
use libsigner::{BlockProposal, SignerSession, StackerDBSession, VERSION_STRING};
2929
use stacks::address::AddressHashMode;
@@ -8614,8 +8614,6 @@ fn block_proposal_max_age_rejections() {
86148614
signer_test.boot_to_epoch_3();
86158615
let short_timeout = Duration::from_secs(30);
86168616

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

86348632
// Next propose a recent invalid block
@@ -8647,31 +8645,27 @@ fn block_proposal_max_age_rejections() {
86478645
else {
86488646
return None;
86498647
};
8650-
assert!(matches!(
8651-
message,
8652-
SignerMessage::BlockResponse(BlockResponse::Rejected(_))
8653-
));
8654-
let SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
8655-
reason_code,
8656-
signer_signature_hash,
8657-
signature,
8658-
..
8659-
})) = message
8660-
else {
8661-
panic!("Received an unexpected block approval from the signer");
8662-
};
8663-
assert_eq!(
8664-
signer_signature_hash, block_signer_signature_hash_2,
8665-
"Received a rejection for an unexpected block: {signer_signature_hash}"
8666-
);
8667-
assert!(
8668-
matches!(reason_code, RejectCode::SortitionViewMismatch),
8669-
"Received a rejection for an unexpected reason: {reason_code}"
8670-
);
8671-
Some(signature)
8648+
match message {
8649+
SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
8650+
signer_signature_hash,
8651+
signature,
8652+
..
8653+
})) => {
8654+
assert_eq!(signer_signature_hash, block_signer_signature_hash_2, "We should only reject the second block");
8655+
Some(signature)
8656+
}
8657+
SignerMessage::BlockResponse(BlockResponse::Accepted(BlockAccepted {
8658+
signer_signature_hash,
8659+
..
8660+
})) => {
8661+
assert_ne!(signer_signature_hash, block_signer_signature_hash_1, "We should never have accepted block");
8662+
None
8663+
}
8664+
_ => None,
8665+
}
86728666
})
86738667
.collect();
8674-
Ok(rejections.len() == num_signers)
8668+
Ok(rejections.len() > num_signers * 7/10)
86758669
})
86768670
.expect("Timed out waiting for block rejections");
86778671

0 commit comments

Comments
 (0)