Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kantai authored and wileyj committed Apr 28, 2023
1 parent e6ffcdc commit 225549c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions testnet/stacks-node/src/tests/epoch_22.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;
use std::env;
use std::thread;
use std::time::Duration;

use stacks::burnchains::Burnchain;
use stacks::chainstate::stacks::address::PoxAddress;
Expand Down Expand Up @@ -877,10 +878,10 @@ fn pox_2_unlock_all() {
// that it can mine _at all_ is a success criterion
let mut last_block_height = get_chain_info(&conf).burn_block_height;

// advance to 2 blocks before 2.2 activation
// advance to 3 blocks before 2.2 activation
loop {
let tip_info = get_chain_info(&conf);
if tip_info.burn_block_height >= epoch_2_2 - 2 {
if tip_info.burn_block_height >= epoch_2_2 - 3 {
break;
}
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
Expand All @@ -898,10 +899,7 @@ fn pox_2_unlock_all() {

submit_tx(&http_origin, &tx);
let nonce_of_2_1_unlock_ht_call = 3;
// this is the last block before 2.2 activates
next_block_and_wait(&mut &mut btc_regtest_controller, &blocks_processed);

// this block activates 2.2
// this will build the last block before 2.2 activates
next_block_and_wait(&mut &mut btc_regtest_controller, &blocks_processed);

let tx = make_contract_call(
Expand All @@ -917,9 +915,15 @@ fn pox_2_unlock_all() {
submit_tx(&http_origin, &tx);
let nonce_of_2_2_unlock_ht_call = 4;

// this block activates 2.2
next_block_and_wait(&mut &mut btc_regtest_controller, &blocks_processed);

// this *burn block* is when the unlock occurs
next_block_and_wait(&mut &mut btc_regtest_controller, &blocks_processed);

// and this will wake up the node
next_block_and_wait(&mut &mut btc_regtest_controller, &blocks_processed);

let spender_1_account = get_account(&http_origin, &spender_addr);
let spender_2_account = get_account(&http_origin, &spender_2_addr);

Expand All @@ -928,15 +932,15 @@ fn pox_2_unlock_all() {

assert_eq!(
spender_1_account.balance as u64,
spender_1_initial_balance - stacked - (4 * tx_fee),
spender_1_initial_balance - stacked - (5 * tx_fee),
"Spender 1 should still be locked"
);
assert_eq!(
spender_1_account.locked as u64, stacked,
"Spender 1 should still be locked"
);
assert_eq!(
spender_1_account.nonce, 4,
spender_1_account.nonce, 5,
"Spender 1 should have 4 accepted transactions"
);

Expand Down Expand Up @@ -1233,7 +1237,7 @@ fn pox_2_unlock_all() {
tx.get("raw_result").unwrap().as_str().unwrap(),
)
.unwrap();
assert_eq!(result.to_string(), format!("(ok u{})", 225 + 60));
assert_eq!(result.to_string(), format!("(ok u{})", 230 + 60));
unlock_ht_21_tested = true;
}
}
Expand Down

0 comments on commit 225549c

Please sign in to comment.