Skip to content

Commit b1b60d1

Browse files
committed
fix: update scenario_five_test
1 parent fb4a2fa commit b1b60d1

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

stackslib/src/chainstate/stacks/boot/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,7 @@ pub mod test {
17731773
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
17741774
d
17751775
} else {
1776+
warn!("get_stacker_info: No PoX info for {}", addr);
17761777
return None;
17771778
};
17781779

stackslib/src/chainstate/stacks/boot/pox_4_tests.rs

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6793,6 +6793,7 @@ pub fn pox_4_scenario_test_setup_nakamoto<'a>(
67936793
pox_constants.pox_3_activation_height = 26;
67946794
pox_constants.v3_unlock_height = 27;
67956795
pox_constants.pox_4_activation_height = 41;
6796+
pox_constants.prepare_length = 5;
67966797
let mut boot_plan = NakamotoBootPlan::new(test_name)
67976798
.with_test_stackers(test_stackers)
67986799
.with_test_signers(test_signers.clone())
@@ -6807,6 +6808,8 @@ pub fn pox_4_scenario_test_setup_nakamoto<'a>(
68076808
boot_plan.initial_balances = initial_balances;
68086809
boot_plan.pox_constants = pox_constants.clone();
68096810
burnchain.pox_constants = pox_constants.clone();
6811+
peer_config.burnchain = burnchain.clone();
6812+
peer_config.test_signers = Some(test_signers.clone());
68106813

68116814
info!("---- Booting into Nakamoto Peer ----");
68126815
let mut peer = boot_plan.boot_into_nakamoto_peer(vec![], Some(observer));
@@ -8873,6 +8876,7 @@ pub fn prepare_pox4_test<'a>(
88738876
pox_constants.pox_3_activation_height = 26;
88748877
pox_constants.v3_unlock_height = 27;
88758878
pox_constants.pox_4_activation_height = 41;
8879+
pox_constants.prepare_length = 5;
88768880
let mut boot_plan = NakamotoBootPlan::new(test_name)
88778881
.with_test_stackers(test_stackers)
88788882
.with_test_signers(test_signers.clone())
@@ -9427,6 +9431,17 @@ fn test_scenario_five(use_nakamoto: bool) {
94279431
use_nakamoto,
94289432
);
94299433

9434+
// Add to test signers
9435+
if let Some(ref mut test_signers) = test_signers.as_mut() {
9436+
test_signers.signer_keys.extend(vec![
9437+
alice.private_key.clone(),
9438+
bob.private_key.clone(),
9439+
carl.private_key.clone(),
9440+
david.private_key.clone(),
9441+
eve.private_key.clone(),
9442+
]);
9443+
}
9444+
94309445
// Lock periods for each stacker
94319446
let carl_lock_period = 3;
94329447
let frank_lock_period = 1;
@@ -9684,6 +9699,12 @@ fn test_scenario_five(use_nakamoto: bool) {
96849699
.reward_cycle_to_block_height(next_reward_cycle as u64)
96859700
.saturating_sub(peer_config.burnchain.pox_constants.prepare_length as u64)
96869701
.wrapping_add(2);
9702+
info!(
9703+
"Scenario five: submitting stacking txs.";
9704+
"target_height" => target_height,
9705+
"next_reward_cycle" => next_reward_cycle,
9706+
"prepare_length" => peer_config.burnchain.pox_constants.prepare_length,
9707+
);
96879708
let (latest_block, tx_block, _receipts) = advance_to_block_height(
96889709
&mut peer,
96899710
&observer,
@@ -9765,12 +9786,15 @@ fn test_scenario_five(use_nakamoto: bool) {
97659786
alice.nonce += 1;
97669787
bob.nonce += 1;
97679788
carl.nonce += 1;
9768-
97699789
// Mine vote txs & advance to the reward set calculation of the next reward cycle
97709790
let target_height = peer
97719791
.config
97729792
.burnchain
97739793
.reward_cycle_to_block_height(next_reward_cycle as u64);
9794+
info!(
9795+
"Scenario five: submitting votes. Target height: {}",
9796+
target_height
9797+
);
97749798
let (latest_block, tx_block, _receipts) = advance_to_block_height(
97759799
&mut peer,
97769800
&observer,
@@ -9878,7 +9902,11 @@ fn test_scenario_five(use_nakamoto: bool) {
98789902
.reward_cycle_to_block_height(next_reward_cycle as u64)
98799903
.saturating_sub(peer_config.burnchain.pox_constants.prepare_length as u64)
98809904
.wrapping_add(2);
9881-
let (latest_block, tx_block, _receipts) = advance_to_block_height(
9905+
info!(
9906+
"Scenario five: submitting extend and aggregate commit txs. Target height: {}",
9907+
target_height
9908+
);
9909+
let (latest_block, tx_block, receipts) = advance_to_block_height(
98829910
&mut peer,
98839911
&observer,
98849912
&txs,
@@ -9888,17 +9916,19 @@ fn test_scenario_five(use_nakamoto: bool) {
98889916
);
98899917

98909918
// Check that all of David's stackers are stacked
9891-
for (stacker, stacker_lock_period) in davids_stackers {
9919+
for (idx, (stacker, stacker_lock_period)) in davids_stackers.iter().enumerate() {
98929920
let (pox_address, first_reward_cycle, lock_period, _indices) =
9893-
get_stacker_info_pox_4(&mut peer, &stacker.principal).expect("Failed to find stacker");
9921+
get_stacker_info_pox_4(&mut peer, &stacker.principal)
9922+
.expect(format!("Failed to find stacker {}", idx).as_str());
98949923
assert_eq!(first_reward_cycle, reward_cycle);
98959924
assert_eq!(pox_address, david.pox_address);
98969925
assert_eq!(lock_period, *stacker_lock_period);
98979926
}
98989927
// Check that all of Eve's stackers are stacked
9899-
for (stacker, stacker_lock_period) in eves_stackers {
9928+
for (idx, (stacker, stacker_lock_period)) in eves_stackers.iter().enumerate() {
99009929
let (pox_address, first_reward_cycle, lock_period, _indices) =
9901-
get_stacker_info_pox_4(&mut peer, &stacker.principal).expect("Failed to find stacker");
9930+
get_stacker_info_pox_4(&mut peer, &stacker.principal)
9931+
.expect(format!("Failed to find stacker {}", idx).as_str());
99029932
assert_eq!(first_reward_cycle, reward_cycle);
99039933
assert_eq!(pox_address, eve.pox_address);
99049934
assert_eq!(lock_period, *stacker_lock_period);
@@ -9970,6 +10000,10 @@ fn test_scenario_five(use_nakamoto: bool) {
997010000
.burnchain
997110001
.reward_cycle_to_block_height(next_reward_cycle as u64);
997210002
// Submit vote transactions
10003+
info!(
10004+
"Scenario five: submitting votes. Target height: {}",
10005+
target_height
10006+
);
997310007
let (latest_block, tx_block, _receipts) = advance_to_block_height(
997410008
&mut peer,
997510009
&observer,
@@ -10085,7 +10119,8 @@ fn test_scenario_five(use_nakamoto: bool) {
1008510119
(heidi.clone(), heidi_lock_period),
1008610120
];
1008710121

10088-
let (latest_block, tx_block, _receipts) = advance_to_block_height(
10122+
info!("Scenario five: submitting increase and aggregate-commit txs");
10123+
let (latest_block, tx_block, receipts) = advance_to_block_height(
1008910124
&mut peer,
1009010125
&observer,
1009110126
&txs,
@@ -10116,6 +10151,6 @@ fn test_scenario_five(use_nakamoto: bool) {
1011610151
assert_eq!(pox_address, carl.pox_address);
1011710152

1011810153
// Assert that carl's error is err(40)
10119-
let carl_increase_err = tx_block.receipts[1].clone().result;
10154+
let carl_increase_err = receipts[1].clone().result;
1012010155
assert_eq!(carl_increase_err, Value::error(Value::Int(40)).unwrap());
1012110156
}

0 commit comments

Comments
 (0)