Skip to content

Commit 419ce43

Browse files
committed
more test fixes
1 parent 677accd commit 419ce43

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

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

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5909,6 +5909,15 @@ fn clarity_burn_state() {
59095909
})
59105910
.unwrap();
59115911

5912+
// in the first tenure, make sure that the contracts are published
5913+
if tenure_ix == 0 {
5914+
wait_for(30, || {
5915+
let cur_sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
5916+
Ok(cur_sender_nonce >= sender_nonce)
5917+
})
5918+
.expect("Timed out waiting for contracts to publish");
5919+
}
5920+
59125921
let info = get_chain_info(&naka_conf);
59135922
burn_block_height = info.burn_block_height as u128;
59145923
info!("Expecting burn block height to be {}", burn_block_height);
@@ -7100,14 +7109,24 @@ fn check_block_times() {
71007109
contract3_name,
71017110
contract_clarity3,
71027111
);
7103-
sender_nonce += 1;
71047112
submit_tx(&http_origin, &contract_tx3);
7113+
sender_nonce += 1;
7114+
7115+
// sleep to ensure seconds have changed
7116+
thread::sleep(Duration::from_secs(3));
71057117

71067118
next_block_and_process_new_stacks_block(&mut btc_regtest_controller, 60, &coord_channel)
71077119
.unwrap();
71087120

7121+
// make sure that the contracts are published
7122+
wait_for(30, || {
7123+
let cur_sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
7124+
Ok(cur_sender_nonce >= sender_nonce)
7125+
})
7126+
.expect("Timed out waiting for contracts to publish");
7127+
71097128
let info = get_chain_info_result(&naka_conf).unwrap();
7110-
info!("Chain info: {:?}", info);
7129+
info!("Chain info: {:?}", info.stacks_tip_height);
71117130
let last_stacks_block_height = info.stacks_tip_height as u128;
71127131
let last_tenure_height = last_stacks_block_height as u128;
71137132

@@ -7116,7 +7135,7 @@ fn check_block_times() {
71167135
&sender_addr,
71177136
contract0_name,
71187137
"get-time",
7119-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7138+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
71207139
);
71217140
let time0 = time0_value
71227141
.expect_optional()
@@ -7130,7 +7149,7 @@ fn check_block_times() {
71307149
&sender_addr,
71317150
contract1_name,
71327151
"get-time",
7133-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7152+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
71347153
);
71357154
let time1 = time1_value
71367155
.expect_optional()
@@ -7148,7 +7167,7 @@ fn check_block_times() {
71487167
&sender_addr,
71497168
contract3_name,
71507169
"get-tenure-time",
7151-
vec![&clarity::vm::Value::UInt(last_tenure_height - 1)],
7170+
vec![&clarity::vm::Value::UInt(last_tenure_height - 2)],
71527171
);
71537172
let time3_tenure = time3_tenure_value
71547173
.expect_optional()
@@ -7166,7 +7185,7 @@ fn check_block_times() {
71667185
&sender_addr,
71677186
contract3_name,
71687187
"get-block-time",
7169-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7188+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
71707189
);
71717190
let time3_block = time3_block_value
71727191
.expect_optional()
@@ -7176,34 +7195,26 @@ fn check_block_times() {
71767195
.unwrap();
71777196

71787197
// Sleep to ensure the seconds have changed
7179-
thread::sleep(Duration::from_secs(1));
7198+
thread::sleep(Duration::from_secs(2));
71807199

71817200
// Mine a Nakamoto block
71827201
info!("Mining Nakamoto block");
7183-
let blocks_processed_before = coord_channel
7184-
.lock()
7185-
.expect("Mutex poisoned")
7186-
.get_stacks_blocks_processed();
71877202

71887203
// submit a tx so that the miner will mine an extra block
71897204
let transfer_tx =
71907205
make_stacks_transfer(&sender_sk, sender_nonce, send_fee, &recipient, send_amt);
71917206
sender_nonce += 1;
71927207
submit_tx(&http_origin, &transfer_tx);
71937208

7194-
loop {
7195-
let blocks_processed = coord_channel
7196-
.lock()
7197-
.expect("Mutex poisoned")
7198-
.get_stacks_blocks_processed();
7199-
if blocks_processed > blocks_processed_before {
7200-
break;
7201-
}
7202-
thread::sleep(Duration::from_millis(100));
7203-
}
7209+
// make sure that the contracts are published
7210+
wait_for(30, || {
7211+
let cur_sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
7212+
Ok(cur_sender_nonce >= sender_nonce)
7213+
})
7214+
.expect("Timed out waiting for transfer to complete");
72047215

72057216
let info = get_chain_info_result(&naka_conf).unwrap();
7206-
info!("Chain info: {:?}", info);
7217+
info!("Chain info: {:?}", info.stacks_tip_height);
72077218
let last_stacks_block_height = info.stacks_tip_height as u128;
72087219

72097220
let time0a_value = call_read_only(
@@ -7221,7 +7232,7 @@ fn check_block_times() {
72217232
.unwrap();
72227233
assert!(
72237234
time0a - time0 >= 1,
7224-
"get-block-info? time should have changed"
7235+
"get-block-info? time should have changed. time_0 = {time0}. time_0_a = {time0a}"
72257236
);
72267237

72277238
let time1a_value = call_read_only(
@@ -7598,9 +7609,19 @@ fn check_block_info() {
75987609
sender_nonce += 1;
75997610
submit_tx(&http_origin, &contract_tx3);
76007611

7612+
// sleep to ensure seconds have changed
7613+
thread::sleep(Duration::from_secs(3));
7614+
76017615
next_block_and_process_new_stacks_block(&mut btc_regtest_controller, 60, &coord_channel)
76027616
.unwrap();
76037617

7618+
// make sure that the contracts are published
7619+
wait_for(30, || {
7620+
let cur_sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
7621+
Ok(cur_sender_nonce >= sender_nonce)
7622+
})
7623+
.expect("Timed out waiting for contracts to publish");
7624+
76047625
let info = get_chain_info_result(&naka_conf).unwrap();
76057626
info!("Chain info: {:?}", info);
76067627
let last_stacks_block_height = info.stacks_tip_height as u128;
@@ -7610,7 +7631,7 @@ fn check_block_info() {
76107631
&sender_addr,
76117632
contract0_name,
76127633
"get-info",
7613-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7634+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
76147635
);
76157636
let tuple0 = result0.expect_tuple().unwrap().data_map;
76167637
assert_block_info(&tuple0, &miner, &miner_spend);
@@ -7620,7 +7641,7 @@ fn check_block_info() {
76207641
&sender_addr,
76217642
contract1_name,
76227643
"get-info",
7623-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7644+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
76247645
);
76257646
let tuple1 = result1.expect_tuple().unwrap().data_map;
76267647
assert_eq!(tuple0, tuple1);
@@ -7630,7 +7651,7 @@ fn check_block_info() {
76307651
&sender_addr,
76317652
contract3_name,
76327653
"get-tenure-info",
7633-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7654+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
76347655
);
76357656
let tuple3_tenure0 = result3_tenure.expect_tuple().unwrap().data_map;
76367657
assert_eq!(
@@ -7661,7 +7682,7 @@ fn check_block_info() {
76617682
&sender_addr,
76627683
contract3_name,
76637684
"get-block-info",
7664-
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 1)],
7685+
vec![&clarity::vm::Value::UInt(last_stacks_block_height - 2)],
76657686
);
76667687
let tuple3_block1 = result3_block.expect_tuple().unwrap().data_map;
76677688
assert_eq!(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ pub fn call_read_only(
929929
let http_origin = format!("http://{}", &conf.node.rpc_bind);
930930
let client = reqwest::blocking::Client::new();
931931

932+
info!("Call read only: {contract}.{function}({args:?})");
933+
932934
let path = format!(
933935
"{http_origin}/v2/contracts/call-read/{}/{}/{}",
934936
principal, contract, function

0 commit comments

Comments
 (0)