Skip to content

Commit b9e1bb9

Browse files
committed
test: resolve issues with check_block_times
1 parent 5202e88 commit b9e1bb9

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7294,7 +7294,7 @@ fn get_block_times(
72947294
&sender_addr,
72957295
contract3_name,
72967296
"get-tenure-time",
7297-
vec![&clarity::vm::Value::UInt(tenure_height)],
7297+
vec![&clarity::vm::Value::UInt(block_height)],
72987298
);
72997299
let time3_tenure = time3_tenure_value
73007300
.expect_optional()
@@ -7349,15 +7349,7 @@ fn get_block_times(
73497349
time0_now, time1_now,
73507350
"Time from pre- and post-epoch 3.0 contracts should match"
73517351
);
7352-
assert_eq!(
7353-
time0, time3_tenure,
7354-
"Tenure time should match Clarity 2 block time"
7355-
);
73567352
assert_eq!(time0_now, time1_now, "Time should match across contracts");
7357-
assert_eq!(
7358-
time0_now, time3_now_tenure,
7359-
"Clarity 3 tenure time should match Clarity 2 block time"
7360-
);
73617353

73627354
(
73637355
time0,
@@ -7394,7 +7386,7 @@ fn check_block_times() {
73947386
let deploy_fee = 3000;
73957387
naka_conf.add_initial_balance(
73967388
PrincipalData::from(sender_addr.clone()).to_string(),
7397-
3 * deploy_fee + (send_amt + send_fee) * 2,
7389+
3 * deploy_fee + (send_amt + send_fee) * 12,
73987390
);
73997391
naka_conf.add_initial_balance(
74007392
PrincipalData::from(sender_signer_addr.clone()).to_string(),
@@ -7471,7 +7463,7 @@ fn check_block_times() {
74717463
next_block_and(&mut btc_regtest_controller, 60, || {
74727464
let info = get_chain_info_result(&naka_conf).unwrap();
74737465
last_stacks_block_height = info.stacks_tip_height as u128;
7474-
last_tenure_height = last_stacks_block_height;
7466+
last_tenure_height = last_stacks_block_height + 1;
74757467
Ok(info.burn_block_height == epoch_3_start)
74767468
})
74777469
.unwrap();
@@ -7510,7 +7502,7 @@ fn check_block_times() {
75107502
let contract_clarity3 = r#"
75117503
(define-read-only (get-block-time (height uint)) (get-stacks-block-info? time height))
75127504
(define-read-only (get-tenure-time (height uint)) (get-tenure-info? time height))
7513-
(define-read-only (get-last-tenure-time) (get-tenure-info? time (- tenure-height u1)))
7505+
(define-read-only (get-last-tenure-time) (get-tenure-info? time (- stacks-block-height u1)))
75147506
"#;
75157507

75167508
let contract_tx3 = make_contract_publish(
@@ -7546,14 +7538,23 @@ fn check_block_times() {
75467538
last_tenure_height += 1;
75477539
info!("New tenure {last_tenure_height}, Stacks height: {last_stacks_block_height}");
75487540

7549-
let (time0, _time0_now, _time1, _time1_now, _time3_tenure, time3_block, _time3_now_tenure) =
7541+
let (time0, time0_now, _time1, _time1_now, time3_tenure, time3_block, time3_now_tenure) =
75507542
get_block_times(
75517543
&naka_conf,
75527544
&sender_addr,
75537545
last_stacks_block_height - 1,
75547546
last_tenure_height - 1,
75557547
);
75567548

7549+
assert_eq!(
7550+
time0, time3_tenure,
7551+
"Tenure time should match Clarity 2 block time"
7552+
);
7553+
assert_eq!(
7554+
time0_now, time3_now_tenure,
7555+
"Clarity 3 tenure time should match Clarity 2 block time in the first block of a tenure"
7556+
);
7557+
75577558
// Mine a Nakamoto block
75587559
info!("Mining Nakamoto block");
75597560

@@ -7588,17 +7589,17 @@ fn check_block_times() {
75887589
_time1a_now,
75897590
_time3a_tenure,
75907591
time3a_block,
7591-
_time3a_now_tenure,
7592+
time3a_now_tenure,
75927593
) = get_block_times(
75937594
&naka_conf,
75947595
&sender_addr,
75957596
last_stacks_block_height - 1,
75967597
last_tenure_height - 1,
75977598
);
75987599

7599-
assert!(
7600-
time0a - time0 >= 1,
7601-
"get-block-info? time should have changed. time_0 = {time0}. time_0_a = {time0a}"
7600+
assert_eq!(
7601+
time0a, time0,
7602+
"get-block-info? time should not have changed"
76027603
);
76037604
assert!(
76047605
time3a_block - time3_block >= 1,
@@ -7618,6 +7619,7 @@ fn check_block_times() {
76187619
send_amt,
76197620
);
76207621
submit_tx(&http_origin, &transfer_tx);
7622+
sender_nonce += 1;
76217623

76227624
// wait for the block to be mined
76237625
wait_for(30, || {
@@ -7632,11 +7634,11 @@ fn check_block_times() {
76327634
let (
76337635
time0b,
76347636
_time0b_now,
7635-
time1b,
7637+
_time1b,
76367638
_time1b_now,
76377639
_time3b_tenure,
76387640
time3b_block,
7639-
_time3b_now_tenure,
7641+
time3b_now_tenure,
76407642
) = get_block_times(
76417643
&naka_conf,
76427644
&sender_addr,
@@ -7645,17 +7647,17 @@ fn check_block_times() {
76457647
);
76467648

76477649
assert_eq!(
7648-
time0a, time0b,
7650+
time0b, time0a,
76497651
"get-block-info? time should not have changed"
76507652
);
7651-
assert_eq!(
7652-
time0b, time1b,
7653-
"Time from pre- and post-epoch 3.0 contracts should match"
7654-
);
76557653
assert!(
76567654
time3b_block - time3a_block >= 1,
76577655
"get-stacks-block-info? time should have changed"
76587656
);
7657+
assert_eq!(
7658+
time3b_now_tenure, time3a_now_tenure,
7659+
"get-tenure-info? time should not have changed"
7660+
);
76597661
}
76607662

76617663
coord_channel

0 commit comments

Comments
 (0)