Skip to content

Commit 054033c

Browse files
committed
Empty sortition needed a longer wait time before ignoring a block and should wait for a block more definitively
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 70bef50 commit 054033c

File tree

1 file changed

+15
-33
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+15
-33
lines changed

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

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,20 @@ impl SignerTest<SpawnedSigner> {
231231
Some(self.num_stacking_cycles),
232232
);
233233
info!("Waiting for signer set calculation.");
234-
let mut reward_set_calculated = false;
235-
let short_timeout = Duration::from_secs(60);
236-
let now = std::time::Instant::now();
237234
// Make sure the signer set is calculated before continuing or signers may not
238235
// recognize that they are registered signers in the subsequent burn block event
239236
let reward_cycle = self.get_current_reward_cycle() + 1;
240-
while !reward_set_calculated {
241-
let reward_set = self
237+
wait_for(30, || {
238+
Ok(self
242239
.stacks_client
243240
.get_reward_set_signers(reward_cycle)
244-
.expect("Failed to check if reward set is calculated");
245-
reward_set_calculated = reward_set.is_some();
246-
if reward_set_calculated {
247-
debug!("Signer set: {:?}", reward_set.unwrap());
248-
}
249-
std::thread::sleep(Duration::from_secs(1));
250-
assert!(
251-
now.elapsed() < short_timeout,
252-
"Timed out waiting for reward set calculation"
253-
);
254-
}
241+
.expect("Failed to check if reward set is calculated")
242+
.map(|reward_set| {
243+
debug!("Signer set: {:?}", reward_set);
244+
})
245+
.is_some())
246+
})
247+
.expect("Timed out waiting for reward set calculation");
255248
info!("Signer set calculated");
256249

257250
// Manually consume one more block to ensure signers refresh their state
@@ -264,8 +257,7 @@ impl SignerTest<SpawnedSigner> {
264257
info!("Signers initialized");
265258

266259
self.run_until_epoch_3_boundary();
267-
std::thread::sleep(Duration::from_secs(1));
268-
wait_for(60, || {
260+
wait_for(30, || {
269261
Ok(get_chain_info_opt(&self.running_nodes.conf).is_some())
270262
})
271263
.expect("Timed out waiting for network to restart after 3.0 boundary reached");
@@ -275,11 +267,11 @@ impl SignerTest<SpawnedSigner> {
275267
// could be other miners mining blocks.
276268
let height_before = get_chain_info(&self.running_nodes.conf).stacks_tip_height;
277269
info!("Waiting for first Nakamoto block: {}", height_before + 1);
278-
next_block_and(&mut self.running_nodes.btc_regtest_controller, 60, || {
279-
let height = get_chain_info(&self.running_nodes.conf).stacks_tip_height;
280-
Ok(height > height_before)
270+
self.mine_nakamoto_block(Duration::from_secs(30));
271+
wait_for(30, || {
272+
Ok(get_chain_info(&self.running_nodes.conf).stacks_tip_height > height_before)
281273
})
282-
.unwrap();
274+
.expect("Timed out waiting for first Nakamoto block after 3.0 boundary");
283275
info!("Ready to mine Nakamoto blocks!");
284276
}
285277

@@ -553,19 +545,9 @@ fn miner_gather_signatures() {
553545
let num_signers = 5;
554546
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new(num_signers, vec![]);
555547
let timeout = Duration::from_secs(30);
556-
let mined_blocks = signer_test.running_nodes.nakamoto_blocks_mined.clone();
557-
let blocks_mined_before = mined_blocks.load(Ordering::SeqCst);
558548

559549
signer_test.boot_to_epoch_3();
560550

561-
// give the system a chance to reach the Nakamoto start tip
562-
// mine a Nakamoto block
563-
wait_for(30, || {
564-
let blocks_mined = mined_blocks.load(Ordering::SeqCst);
565-
Ok(blocks_mined > blocks_mined_before)
566-
})
567-
.unwrap();
568-
569551
info!("------------------------- Test Mine and Verify Confirmed Nakamoto Block -------------------------");
570552
signer_test.mine_and_verify_confirmed_naka_block(timeout, num_signers);
571553

@@ -2317,7 +2299,7 @@ fn empty_sortition() {
23172299
let send_amt = 100;
23182300
let send_fee = 180;
23192301
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
2320-
let block_proposal_timeout = Duration::from_secs(5);
2302+
let block_proposal_timeout = Duration::from_secs(20);
23212303
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
23222304
num_signers,
23232305
vec![(sender_addr.clone(), send_amt + send_fee)],

0 commit comments

Comments
 (0)