@@ -3340,18 +3340,24 @@ fn advance_to_block_height(
3340
3340
3341
3341
#[ test]
3342
3342
/// 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.
3344
3346
fn stack_agg_increase ( ) {
3345
3347
// Alice service signer setup
3346
3348
let mut alice = StackerSignerInfo :: new ( ) ;
3347
3349
// Bob pool operator
3348
3350
let mut bob = StackerSignerInfo :: new ( ) ;
3349
- // Carl pool delegate
3351
+ // Carl pool 1 delegate
3350
3352
let mut carl = StackerSignerInfo :: new ( ) ;
3351
- // Dave pool delegate
3353
+ // Dave pool 1 delegate
3352
3354
let mut dave = StackerSignerInfo :: new ( ) ;
3353
- // Eve late pool delegate
3355
+ // Eve late 1 pool delegate
3354
3356
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 ( ) ;
3355
3361
3356
3362
let default_initial_balances = 1_000_000_000_000_000_000 ;
3357
3363
let observer = TestEventObserver :: new ( ) ;
@@ -3362,6 +3368,8 @@ fn stack_agg_increase() {
3362
3368
( carl. principal. clone( ) , default_initial_balances) ,
3363
3369
( dave. principal. clone( ) , default_initial_balances) ,
3364
3370
( eve. principal. clone( ) , default_initial_balances) ,
3371
+ ( frank. principal. clone( ) , default_initial_balances) ,
3372
+ ( grace. principal. clone( ) , default_initial_balances) ,
3365
3373
] ;
3366
3374
let aggregate_public_key = test_signers. aggregate_public_key . clone ( ) ;
3367
3375
let mut peer_config = TestPeerConfig :: new ( function_name ! ( ) , 0 , 0 ) ;
@@ -3416,9 +3424,9 @@ fn stack_agg_increase() {
3416
3424
let amount = ( default_initial_balances / 2 ) . wrapping_sub ( 1000 ) as u128 ;
3417
3425
3418
3426
// Signatures
3419
- // Initial Alice Signature For Bob
3427
+ // Initial Alice Signature For Bob Pool 1
3420
3428
let lock_period = 1 ;
3421
- let alice_signature_initial = make_signer_key_signature (
3429
+ let alice_signature_initial_one = make_signer_key_signature (
3422
3430
& bob. pox_address ,
3423
3431
& alice. private_key ,
3424
3432
next_reward_cycle,
@@ -3428,7 +3436,6 @@ fn stack_agg_increase() {
3428
3436
1 ,
3429
3437
) ;
3430
3438
// Increase Error Bob Signature For Bob
3431
- let lock_period = 1 ;
3432
3439
let bob_err_signature_increase = make_signer_key_signature (
3433
3440
& bob. pox_address ,
3434
3441
& bob. private_key ,
@@ -3448,6 +3455,16 @@ fn stack_agg_increase() {
3448
3455
u128:: MAX ,
3449
3456
1 ,
3450
3457
) ;
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
+ ) ;
3451
3468
3452
3469
// Timely Delegate-STX Functions
3453
3470
// Carl pool stacker timely delegating STX to Bob
@@ -3502,7 +3519,7 @@ fn stack_agg_increase() {
3502
3519
bob. nonce ,
3503
3520
& bob. pox_address ,
3504
3521
next_reward_cycle,
3505
- Some ( alice_signature_initial ) ,
3522
+ Some ( alice_signature_initial_one ) ,
3506
3523
& alice. public_key ,
3507
3524
u128:: MAX ,
3508
3525
1 ,
@@ -3595,12 +3612,72 @@ fn stack_agg_increase() {
3595
3612
u128:: MAX ,
3596
3613
1 ,
3597
3614
) ;
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 ;
3598
3670
3599
3671
let txs = vec ! [
3600
3672
eve_delegate_stx_to_bob_tx. clone( ) ,
3601
3673
bob_delegate_stack_stx_for_eve_tx. clone( ) ,
3602
3674
bobs_err_aggregate_increase. clone( ) ,
3603
3675
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( ) ,
3604
3681
] ;
3605
3682
3606
3683
// Advance to next block in order to attempt aggregate increase
@@ -3638,6 +3715,17 @@ fn stack_agg_increase() {
3638
3715
. expect_result_ok ( )
3639
3716
. unwrap ( ) ;
3640
3717
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 ) ) ;
3641
3729
}
3642
3730
3643
3731
#[ test]
0 commit comments