Skip to content

Commit a7f7ea0

Browse files
committed
updated test
1 parent d693d28 commit a7f7ea0

File tree

1 file changed

+96
-8
lines changed

1 file changed

+96
-8
lines changed

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

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,18 +3340,24 @@ fn advance_to_block_height(
33403340

33413341
#[test]
33423342
/// Test for verifying that the stacker aggregation works as expected
3343-
/// with new signature parameters.
3343+
/// with new signature parameters. In this test Alice is the service signer,
3344+
/// Bob is the pool operator, Carl & Dave are delegates for pool 1, Eve is a late
3345+
/// delegate for pool 1, Frank is a delegate for pool 2, & Grace is a delegate for pool 2.
33443346
fn stack_agg_increase() {
33453347
// Alice service signer setup
33463348
let mut alice = StackerSignerInfo::new();
33473349
// Bob pool operator
33483350
let mut bob = StackerSignerInfo::new();
3349-
// Carl pool delegate
3351+
// Carl pool 1 delegate
33503352
let mut carl = StackerSignerInfo::new();
3351-
// Dave pool delegate
3353+
// Dave pool 1 delegate
33523354
let mut dave = StackerSignerInfo::new();
3353-
// Eve late pool delegate
3355+
// Eve late 1 pool delegate
33543356
let mut eve = StackerSignerInfo::new();
3357+
// Frank pool 2 delegate
3358+
let mut frank = StackerSignerInfo::new();
3359+
// Grace pool 2 delegate
3360+
let mut grace = StackerSignerInfo::new();
33553361

33563362
let default_initial_balances = 1_000_000_000_000_000_000;
33573363
let observer = TestEventObserver::new();
@@ -3362,6 +3368,8 @@ fn stack_agg_increase() {
33623368
(carl.principal.clone(), default_initial_balances),
33633369
(dave.principal.clone(), default_initial_balances),
33643370
(eve.principal.clone(), default_initial_balances),
3371+
(frank.principal.clone(), default_initial_balances),
3372+
(grace.principal.clone(), default_initial_balances),
33653373
];
33663374
let aggregate_public_key = test_signers.aggregate_public_key.clone();
33673375
let mut peer_config = TestPeerConfig::new(function_name!(), 0, 0);
@@ -3416,9 +3424,9 @@ fn stack_agg_increase() {
34163424
let amount = (default_initial_balances / 2).wrapping_sub(1000) as u128;
34173425

34183426
// Signatures
3419-
// Initial Alice Signature For Bob
3427+
// Initial Alice Signature For Bob Pool 1
34203428
let lock_period = 1;
3421-
let alice_signature_initial = make_signer_key_signature(
3429+
let alice_signature_initial_one = make_signer_key_signature(
34223430
&bob.pox_address,
34233431
&alice.private_key,
34243432
next_reward_cycle,
@@ -3428,7 +3436,6 @@ fn stack_agg_increase() {
34283436
1,
34293437
);
34303438
// Increase Error Bob Signature For Bob
3431-
let lock_period = 1;
34323439
let bob_err_signature_increase = make_signer_key_signature(
34333440
&bob.pox_address,
34343441
&bob.private_key,
@@ -3448,6 +3455,16 @@ fn stack_agg_increase() {
34483455
u128::MAX,
34493456
1,
34503457
);
3458+
// Initial Alice Signature For Bob Pool 2
3459+
let alice_signature_initial_two = make_signer_key_signature(
3460+
&bob.pox_address,
3461+
&alice.private_key,
3462+
next_reward_cycle,
3463+
&Pox4SignatureTopic::AggregationCommit,
3464+
lock_period,
3465+
u128::MAX,
3466+
2,
3467+
);
34513468

34523469
// Timely Delegate-STX Functions
34533470
// Carl pool stacker timely delegating STX to Bob
@@ -3502,7 +3519,7 @@ fn stack_agg_increase() {
35023519
bob.nonce,
35033520
&bob.pox_address,
35043521
next_reward_cycle,
3505-
Some(alice_signature_initial),
3522+
Some(alice_signature_initial_one),
35063523
&alice.public_key,
35073524
u128::MAX,
35083525
1,
@@ -3595,12 +3612,72 @@ fn stack_agg_increase() {
35953612
u128::MAX,
35963613
1,
35973614
);
3615+
bob.nonce += 1;
3616+
// Frank pool stacker delegating STX to Bob
3617+
let frank_delegate_stx_to_bob_tx = make_pox_4_delegate_stx(
3618+
&frank.private_key,
3619+
frank.nonce,
3620+
amount,
3621+
bob.principal.clone(),
3622+
None,
3623+
Some(bob.pox_address.clone()),
3624+
);
3625+
frank.nonce += 1;
3626+
// Grace pool stacker delegating STX to Bob
3627+
let grace_delegate_stx_to_bob_tx = make_pox_4_delegate_stx(
3628+
&grace.private_key,
3629+
grace.nonce,
3630+
amount,
3631+
bob.principal.clone(),
3632+
None,
3633+
Some(bob.pox_address.clone()),
3634+
);
3635+
grace.nonce += 1;
3636+
// Bob pool operator calling delegate-stack-stx on behalf of Faith
3637+
let bob_delegate_stack_stx_for_faith_tx = make_pox_4_delegate_stack_stx(
3638+
&bob.private_key,
3639+
bob.nonce,
3640+
frank.principal.clone(),
3641+
amount,
3642+
bob.pox_address.clone(),
3643+
burn_block_height as u128,
3644+
lock_period,
3645+
);
3646+
bob.nonce += 1;
3647+
// Bob pool operator calling delegate-stack-stx on behalf of Grace
3648+
let bob_delegate_stack_stx_for_grace_tx = make_pox_4_delegate_stack_stx(
3649+
&bob.private_key,
3650+
bob.nonce,
3651+
grace.principal.clone(),
3652+
amount,
3653+
bob.pox_address.clone(),
3654+
burn_block_height as u128,
3655+
lock_period,
3656+
);
3657+
bob.nonce += 1;
3658+
// Aggregate Commit 2nd Pool
3659+
let bobs_aggregate_commit_index_tx = make_pox_4_aggregation_commit_indexed(
3660+
&bob.private_key,
3661+
bob.nonce,
3662+
&bob.pox_address,
3663+
next_reward_cycle,
3664+
Some(alice_signature_initial_two),
3665+
&alice.public_key,
3666+
u128::MAX,
3667+
2,
3668+
);
3669+
bob.nonce += 1;
35983670

35993671
let txs = vec![
36003672
eve_delegate_stx_to_bob_tx.clone(),
36013673
bob_delegate_stack_stx_for_eve_tx.clone(),
36023674
bobs_err_aggregate_increase.clone(),
36033675
bobs_aggregate_increase.clone(),
3676+
frank_delegate_stx_to_bob_tx.clone(),
3677+
grace_delegate_stx_to_bob_tx.clone(),
3678+
bob_delegate_stack_stx_for_faith_tx.clone(),
3679+
bob_delegate_stack_stx_for_grace_tx.clone(),
3680+
bobs_aggregate_commit_index_tx.clone(),
36043681
];
36053682

36063683
// Advance to next block in order to attempt aggregate increase
@@ -3638,6 +3715,17 @@ fn stack_agg_increase() {
36383715
.expect_result_ok()
36393716
.unwrap();
36403717
assert_eq!(bob_aggregate_increase_result, &Value::Bool(true));
3718+
3719+
// Check that Bob's second pool has an assigned reward index of 1
3720+
let bob_aggregate_commit_reward_index = &tx_block
3721+
.receipts
3722+
.get(9)
3723+
.unwrap()
3724+
.result
3725+
.clone()
3726+
.expect_result_ok()
3727+
.unwrap();
3728+
assert_eq!(bob_aggregate_commit_reward_index, &Value::UInt(1));
36413729
}
36423730

36433731
#[test]

0 commit comments

Comments
 (0)