Skip to content

Commit 11bc001

Browse files
committed
test: fix flakiness from boot_to_epoch_3
If we did not successfully mine a block after the signer set has been calculated, then we will stall below. If retrieving the reward set times out, then try mining another block so we can recover. This should fix flakiness in all epoch 3 signer tests.
1 parent 6a2f682 commit 11bc001

File tree

1 file changed

+23
-7
lines changed
  • stacks-node/src/tests/signer

1 file changed

+23
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,36 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
143143
&self.running_nodes.btc_regtest_controller,
144144
Some(self.num_stacking_cycles),
145145
);
146+
146147
info!("Waiting for signer set calculation.");
147148
// Make sure the signer set is calculated before continuing or signers may not
148149
// recognize that they are registered signers in the subsequent burn block event
149150
let reward_cycle = self.get_current_reward_cycle() + 1;
151+
let mut last_probe = Instant::now();
150152
wait_for(120, || {
151-
let Ok(Some(reward_set)) = self.stacks_client.get_reward_set_signers(reward_cycle)
152-
else {
153-
return Ok(false);
154-
};
155-
156-
debug!("Signer set: {reward_set:?}");
157-
Ok(true)
153+
match self.stacks_client.get_reward_set_signers(reward_cycle).unwrap_or_default() {
154+
Some(reward_set) => {
155+
debug!("Signer set: {reward_set:?}");
156+
Ok(true)
157+
}
158+
None => {
159+
// If we've been waiting ~30s since the last probe, maybe the last block failed
160+
// so we should try to mine another block
161+
if last_probe.elapsed() >= Duration::from_secs(30) {
162+
warn!(
163+
"Timed out waiting for reward set calculation. Mining another block to try again."
164+
);
165+
self.running_nodes
166+
.btc_regtest_controller
167+
.build_next_block(1);
168+
last_probe = Instant::now();
169+
}
170+
Ok(false)
171+
}
172+
}
158173
})
159174
.expect("Timed out waiting for reward set calculation");
175+
160176
info!("Signer set calculated");
161177

162178
// Manually consume one more block to ensure signers refresh their state

0 commit comments

Comments
 (0)