Skip to content

Commit 677accd

Browse files
committed
more test fixes
1 parent 6f60813 commit 677accd

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

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

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,10 @@ fn signer_vote_if_needed(
11881188
btc_regtest_controller.get_burnchain().first_block_height,
11891189
reward_cycle,
11901190
);
1191+
let epochs = btc_regtest_controller.get_stacks_epochs();
1192+
let is_naka_epoch = epochs[StacksEpoch::find_epoch(&epochs, block_height).unwrap()]
1193+
.epoch_id
1194+
.uses_nakamoto_blocks();
11911195

11921196
if block_height >= prepare_phase_start {
11931197
// If the key is already set, do nothing.
@@ -1210,6 +1214,7 @@ fn signer_vote_if_needed(
12101214
clarity::vm::Value::buff_from(aggregate_key.compress().data.to_vec())
12111215
.expect("Failed to serialize aggregate public key");
12121216

1217+
let mut expected_nonces = vec![];
12131218
for (i, signer_sk) in signer_sks.iter().enumerate() {
12141219
let signer_nonce = get_account(&http_origin, &to_addr(signer_sk)).nonce;
12151220

@@ -1228,8 +1233,19 @@ fn signer_vote_if_needed(
12281233
clarity::vm::Value::UInt(reward_cycle as u128 + 1),
12291234
],
12301235
);
1236+
expected_nonces.push((to_addr(signer_sk), signer_nonce + 1));
12311237
submit_tx(&http_origin, &voting_tx);
12321238
}
1239+
1240+
if is_naka_epoch {
1241+
wait_for(30, || {
1242+
let all_bumped = expected_nonces.iter().all(|(addr, expected_nonce)| {
1243+
get_account(&http_origin, addr).nonce >= *expected_nonce
1244+
});
1245+
Ok(all_bumped)
1246+
})
1247+
.expect("Timed out waiting for an interim nakamoto block to process our transactions");
1248+
}
12331249
}
12341250
}
12351251

@@ -1465,7 +1481,7 @@ fn simple_neon_integration() {
14651481
let (mut naka_conf, _miner_account) = naka_neon_integration_conf(None);
14661482
let prom_bind = format!("{}:{}", "127.0.0.1", 6000);
14671483
naka_conf.node.prometheus_bind = Some(prom_bind.clone());
1468-
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1000);
1484+
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(5);
14691485
let sender_sk = Secp256k1PrivateKey::new();
14701486
// setup sender + recipient for a test stx transfer
14711487
let sender_addr = tests::to_addr(&sender_sk);
@@ -1601,6 +1617,19 @@ fn simple_neon_integration() {
16011617
)
16021618
.unwrap();
16031619

1620+
wait_for(30, || {
1621+
let transfer_tx_included = test_observer::get_blocks().into_iter().any(|block_json| {
1622+
block_json["transactions"]
1623+
.as_array()
1624+
.unwrap()
1625+
.iter()
1626+
.find(|tx_json| tx_json["raw_tx"].as_str() == Some(&transfer_tx_hex))
1627+
.is_some()
1628+
});
1629+
Ok(transfer_tx_included)
1630+
})
1631+
.expect("Timed out waiting for submitted transaction to be included in a block");
1632+
16041633
// Mine 15 more nakamoto tenures
16051634
for _i in 0..15 {
16061635
next_block_and_mine_commit(
@@ -2416,7 +2445,7 @@ fn correct_burn_outs() {
24162445
epochs[epoch_30_ix].start_height = 225;
24172446
}
24182447

2419-
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1000);
2448+
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1);
24202449
naka_conf.initial_balances.clear();
24212450
let accounts: Vec<_> = (0..8)
24222451
.map(|ix| {
@@ -5183,6 +5212,15 @@ fn check_block_heights() {
51835212
next_block_and_process_new_stacks_block(&mut btc_regtest_controller, 60, &coord_channel)
51845213
.unwrap();
51855214

5215+
// in the first tenure, make sure that the contracts are published
5216+
if tenure_ix == 0 {
5217+
wait_for(30, || {
5218+
let cur_sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
5219+
Ok(cur_sender_nonce >= sender_nonce)
5220+
})
5221+
.expect("Timed out waiting for contracts to publish");
5222+
}
5223+
51865224
let heights1_value = call_read_only(
51875225
&naka_conf,
51885226
&sender_addr,
@@ -5247,9 +5285,15 @@ fn check_block_heights() {
52475285
.clone()
52485286
.expect_u128()
52495287
.unwrap();
5288+
let expected_height = if tenure_ix == 0 {
5289+
// tenure 0 will include an interim block at this point because of the contract publish
5290+
// txs
5291+
last_stacks_block_height + 2
5292+
} else {
5293+
last_stacks_block_height + 1
5294+
};
52505295
assert_eq!(
5251-
sbh,
5252-
last_stacks_block_height + 1,
5296+
sbh, expected_height,
52535297
"Stacks block heights should have incremented"
52545298
);
52555299
last_stacks_block_height = sbh;
@@ -5373,8 +5417,8 @@ fn check_block_heights() {
53735417
assert!(tip.anchored_header.as_stacks_nakamoto().is_some());
53745418
assert_eq!(
53755419
tip.stacks_block_height,
5376-
block_height_pre_3_0 + ((inter_blocks_per_tenure + 1) * tenure_count),
5377-
"Should have mined (1 + interim_blocks_per_tenure) * tenure_count nakamoto blocks"
5420+
block_height_pre_3_0 + 1 + ((inter_blocks_per_tenure + 1) * tenure_count),
5421+
"Should have mined 1 + (1 + interim_blocks_per_tenure) * tenure_count nakamoto blocks"
53785422
);
53795423

53805424
coord_channel

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
266266
}
267267
info!("Finished signers: {:?}", finished_signers.iter().collect::<Vec<_>>());
268268
Ok(finished_signers.len() == self.spawned_signers.len())
269-
}).unwrap();
269+
}).expect("Timed out while waiting for the signers to be registered");
270270
}
271271

272272
pub fn wait_for_cycle(&mut self, timeout_secs: u64, reward_cycle: u64) {

0 commit comments

Comments
 (0)