Skip to content

Commit c2df444

Browse files
committed
more test cleanup
* follower_bootup_across_multiple_cycles at least fails faster now: the failure scenario for this test involved not making it to nakamoto blocks, this puts a tighter timeout on that aspect of the test. * block_proposal_max_age_rejections: make the message assertions specifically about the proposed test blocks, not any proposals that the miner might otherwise be trying to submit.
1 parent 4921f5b commit c2df444

File tree

2 files changed

+64
-37
lines changed

2 files changed

+64
-37
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,8 +4101,31 @@ fn follower_bootup_across_multiple_cycles() {
41014101

41024102
debug!("Booted follower-thread");
41034103

4104-
// Wait a long time for the follower to catch up because CI is slow.
4105-
wait_for(600, || {
4104+
// Wait some time for the follower to at least get some nakamoto blocks
4105+
wait_for(120, || {
4106+
thread::sleep(Duration::from_secs(5));
4107+
let Ok(follower_node_info) = get_chain_info_result(&follower_conf) else {
4108+
return Ok(false);
4109+
};
4110+
4111+
let block_id = StacksBlockId::new(
4112+
&follower_node_info.stacks_tip_consensus_hash,
4113+
&follower_node_info.stacks_tip,
4114+
);
4115+
let tip = NakamotoChainState::get_block_header(chainstate.db(), &block_id)
4116+
.unwrap()
4117+
.unwrap();
4118+
info!(
4119+
"Latest follower tip";
4120+
"height" => tip.stacks_block_height,
4121+
"is_nakamoto" => tip.anchored_header.as_stacks_nakamoto().is_some(),
4122+
);
4123+
4124+
Ok(tip.anchored_header.as_stacks_nakamoto().is_some())
4125+
})
4126+
.unwrap();
4127+
4128+
wait_for(480, || {
41064129
sleep_ms(1000);
41074130
let Ok(follower_node_info) = get_chain_info_result(&follower_conf) else {
41084131
return Ok(false);

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

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8163,47 +8163,51 @@ fn block_proposal_max_age_rejections() {
81638163

81648164
info!("------------------------- Test Block Proposal Rejected -------------------------");
81658165
// Verify the signers rejected only the SECOND block proposal. The first was not even processed.
8166-
wait_for(30, || {
8167-
let rejections = test_observer::get_stackerdb_chunks()
8166+
wait_for(120, || {
8167+
let mut status_map = HashMap::new();
8168+
for chunk in test_observer::get_stackerdb_chunks()
81688169
.into_iter()
81698170
.flat_map(|chunk| chunk.modified_slots)
8170-
.map(|chunk| {
8171-
let Ok(message) = SignerMessage::consensus_deserialize(&mut chunk.data.as_slice())
8172-
else {
8173-
return None;
8174-
};
8175-
match message {
8176-
SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
8177-
signer_signature_hash,
8178-
signature,
8179-
..
8180-
})) => {
8181-
assert_eq!(
8182-
signer_signature_hash, block_signer_signature_hash_2,
8183-
"We should only reject the second block"
8184-
);
8185-
Some(signature)
8186-
}
8187-
SignerMessage::BlockResponse(BlockResponse::Accepted(BlockAccepted {
8188-
signer_signature_hash,
8189-
..
8190-
})) => {
8191-
assert_ne!(
8192-
signer_signature_hash, block_signer_signature_hash_1,
8193-
"We should never have accepted block"
8194-
);
8195-
None
8196-
}
8197-
_ => None,
8171+
{
8172+
let Ok(message) = SignerMessage::consensus_deserialize(&mut chunk.data.as_slice())
8173+
else {
8174+
continue;
8175+
};
8176+
match message {
8177+
SignerMessage::BlockResponse(BlockResponse::Rejected(BlockRejection {
8178+
signer_signature_hash,
8179+
..
8180+
})) => {
8181+
let entry = status_map.entry(signer_signature_hash).or_insert((0, 0));
8182+
entry.0 += 1;
81988183
}
8199-
});
8200-
Ok(rejections.count() > num_signers * 7 / 10)
8184+
SignerMessage::BlockResponse(BlockResponse::Accepted(BlockAccepted {
8185+
signer_signature_hash,
8186+
..
8187+
})) => {
8188+
let entry = status_map.entry(signer_signature_hash).or_insert((0, 0));
8189+
entry.1 += 1;
8190+
}
8191+
_ => continue,
8192+
}
8193+
}
8194+
let block_1_status = status_map
8195+
.get(&block_signer_signature_hash_1)
8196+
.cloned()
8197+
.unwrap_or((0, 0));
8198+
assert_eq!(block_1_status, (0, 0));
8199+
8200+
let block_2_status = status_map
8201+
.get(&block_signer_signature_hash_2)
8202+
.cloned()
8203+
.unwrap_or((0, 0));
8204+
assert_eq!(block_2_status.1, 0, "Block 2 should always be rejected");
8205+
8206+
info!("Block 2 status"; "accepted" => block_2_status.1, "rejected" => block_2_status.0);
8207+
Ok(block_2_status.0 > num_signers * 7 / 10)
82018208
})
82028209
.expect("Timed out waiting for block rejections");
82038210

8204-
info!("------------------------- Test Peer Info-------------------------");
8205-
assert_eq!(info_before, get_chain_info(&signer_test.running_nodes.conf));
8206-
82078211
info!("------------------------- Test Shutdown-------------------------");
82088212
signer_test.shutdown();
82098213
}

0 commit comments

Comments
 (0)