@@ -81,7 +81,7 @@ fn get_tip(sortdb: Option<&SortitionDB>) -> BlockSnapshot {
81
81
SortitionDB :: get_canonical_burn_chain_tip ( & sortdb. unwrap ( ) . conn ( ) ) . unwrap ( )
82
82
}
83
83
84
- fn make_test_epochs_pox ( ) -> ( Vec < StacksEpoch > , PoxConstants ) {
84
+ fn make_test_epochs_pox ( ) -> ( EpochList , PoxConstants ) {
85
85
let EMPTY_SORTITIONS = 25 ;
86
86
let EPOCH_2_1_HEIGHT = EMPTY_SORTITIONS + 11 ; // 36
87
87
let EPOCH_2_2_HEIGHT = EPOCH_2_1_HEIGHT + 14 ; // 50
@@ -92,7 +92,7 @@ fn make_test_epochs_pox() -> (Vec<StacksEpoch>, PoxConstants) {
92
92
93
93
// cycle 11 = 60
94
94
95
- let epochs = vec ! [
95
+ let epochs = EpochList :: new ( & [
96
96
StacksEpoch {
97
97
epoch_id : StacksEpochId :: Epoch10 ,
98
98
start_height : 0 ,
@@ -142,7 +142,7 @@ fn make_test_epochs_pox() -> (Vec<StacksEpoch>, PoxConstants) {
142
142
block_limit : ExecutionCost :: max_value ( ) ,
143
143
network_epoch : PEER_VERSION_EPOCH_2_4 ,
144
144
} ,
145
- ] ;
145
+ ] ) ;
146
146
147
147
let mut pox_constants = PoxConstants :: mainnet_default ( ) ;
148
148
pox_constants. reward_cycle_length = 5 ;
@@ -279,7 +279,7 @@ fn simple_pox_lockup_transition_pox_2() {
279
279
assert_eq ! ( alice_balance, 0 ) ;
280
280
281
281
// produce blocks until immediately before the 2.1 epoch switch
282
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 3 ] . start_height {
282
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch21 ] . start_height {
283
283
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
284
284
285
285
// alice is still locked, balance should be 0
@@ -377,7 +377,7 @@ fn simple_pox_lockup_transition_pox_2() {
377
377
assert_eq ! ( alice_balance, 512 * POX_THRESHOLD_STEPS_USTX ) ;
378
378
379
379
// now, let's roll the chain forward until just before Epoch-2.2
380
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 4 ] . start_height {
380
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch22 ] . start_height {
381
381
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
382
382
// at this point, alice's balance should always include this half lockup
383
383
let alice_balance = get_balance ( & mut peer, & key_to_stacks_addr ( & alice) . into ( ) ) ;
@@ -394,7 +394,8 @@ fn simple_pox_lockup_transition_pox_2() {
394
394
assert_eq ! ( alice_balance, 1024 * POX_THRESHOLD_STEPS_USTX ) ;
395
395
396
396
// now, roll the chain forward to Epoch-2.4
397
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
397
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
398
+ {
398
399
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
399
400
// at this point, alice's balance should always be unlocked
400
401
let alice_balance = get_balance ( & mut peer, & key_to_stacks_addr ( & alice) . into ( ) ) ;
@@ -612,7 +613,8 @@ fn pox_auto_unlock(alice_first: bool) {
612
613
let mut coinbase_nonce = 0 ;
613
614
614
615
// produce blocks until epoch 2.1
615
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 3 ] . start_height {
616
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch21 ] . start_height
617
+ {
616
618
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
617
619
}
618
620
@@ -762,7 +764,8 @@ fn pox_auto_unlock(alice_first: bool) {
762
764
// now, lets check behavior in Epochs 2.2-2.4, with pox-3 auto unlock tests
763
765
764
766
// produce blocks until epoch 2.2
765
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 4 ] . start_height {
767
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch22 ] . start_height
768
+ {
766
769
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
767
770
let alice_balance = get_balance ( & mut peer, & key_to_stacks_addr ( & alice) . into ( ) ) ;
768
771
assert_eq ! ( alice_balance, 0 ) ;
@@ -774,7 +777,8 @@ fn pox_auto_unlock(alice_first: bool) {
774
777
assert_eq ! ( alice_balance, 1024 * POX_THRESHOLD_STEPS_USTX ) ;
775
778
776
779
// produce blocks until epoch 2.4
777
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
780
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
781
+ {
778
782
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
779
783
}
780
784
@@ -1051,7 +1055,8 @@ fn delegate_stack_increase() {
1051
1055
let mut coinbase_nonce = 0 ;
1052
1056
1053
1057
// produce blocks until epoch 2.1
1054
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 3 ] . start_height {
1058
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch21 ] . start_height
1059
+ {
1055
1060
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1056
1061
}
1057
1062
@@ -1236,7 +1241,7 @@ fn delegate_stack_increase() {
1236
1241
// on pox-3
1237
1242
1238
1243
// roll the chain forward until just before Epoch-2.2
1239
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 4 ] . start_height {
1244
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch22 ] . start_height {
1240
1245
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1241
1246
// at this point, alice's balance should always include this half lockup
1242
1247
assert_eq ! (
@@ -1279,7 +1284,8 @@ fn delegate_stack_increase() {
1279
1284
) ;
1280
1285
1281
1286
// Roll to Epoch-2.4 and re-do the above tests
1282
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
1287
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
1288
+ {
1283
1289
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1284
1290
}
1285
1291
@@ -1666,7 +1672,8 @@ fn stack_increase() {
1666
1672
let increase_amt = total_balance - first_lockup_amt;
1667
1673
1668
1674
// produce blocks until epoch 2.1
1669
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 3 ] . start_height {
1675
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch21 ] . start_height
1676
+ {
1670
1677
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1671
1678
}
1672
1679
@@ -1799,7 +1806,7 @@ fn stack_increase() {
1799
1806
// on pox-3
1800
1807
1801
1808
// roll the chain forward until just before Epoch-2.2
1802
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 4 ] . start_height {
1809
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch22 ] . start_height {
1803
1810
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1804
1811
// at this point, alice's balance should always include this half lockup
1805
1812
assert_eq ! (
@@ -1828,7 +1835,8 @@ fn stack_increase() {
1828
1835
) ;
1829
1836
1830
1837
// Roll to Epoch-2.4 and re-do the above stack-increase tests
1831
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
1838
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
1839
+ {
1832
1840
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
1833
1841
}
1834
1842
@@ -2242,7 +2250,7 @@ fn pox_extend_transition() {
2242
2250
}
2243
2251
2244
2252
// produce blocks until epoch 2.1
2245
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 3 ] . start_height {
2253
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch21 ] . start_height {
2246
2254
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
2247
2255
alice_rewards_to_v2_start_checks ( latest_block, & mut peer) ;
2248
2256
}
@@ -2311,7 +2319,7 @@ fn pox_extend_transition() {
2311
2319
// Roll to Epoch-2.4 and re-do the above tests
2312
2320
2313
2321
// roll the chain forward until just before Epoch-2.2
2314
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ 4 ] . start_height {
2322
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height < epochs[ StacksEpochId :: Epoch22 ] . start_height {
2315
2323
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
2316
2324
// at this point, alice's balance should be locked, and so should bob's
2317
2325
let alice_balance = get_balance ( & mut peer, & key_to_stacks_addr ( & alice) . into ( ) ) ;
@@ -2338,7 +2346,8 @@ fn pox_extend_transition() {
2338
2346
assert_eq ! ( bob_account. amount_unlocked( ) , INITIAL_BALANCE ) ;
2339
2347
2340
2348
// Roll to Epoch-2.4 and re-do the above stack-extend tests
2341
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
2349
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
2350
+ {
2342
2351
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
2343
2352
}
2344
2353
@@ -2611,7 +2620,8 @@ fn delegate_extend_pox_3() {
2611
2620
let mut latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
2612
2621
2613
2622
// Roll to Epoch-2.4 and perform the delegate-stack-extend tests
2614
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
2623
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
2624
+ {
2615
2625
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
2616
2626
}
2617
2627
@@ -3087,7 +3097,8 @@ fn pox_3_getters() {
3087
3097
3088
3098
let mut latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3089
3099
// Roll to Epoch-2.4 and perform the delegate-stack-extend tests
3090
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
3100
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
3101
+ {
3091
3102
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3092
3103
}
3093
3104
@@ -3491,10 +3502,12 @@ fn get_pox_addrs() {
3491
3502
} ;
3492
3503
3493
3504
// produce blocks until epoch 2.2
3494
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
3505
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
3506
+ {
3495
3507
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3496
3508
// if we reach epoch 2.1, perform the check
3497
- if get_tip ( peer. sortdb . as_ref ( ) ) . block_height > epochs[ 3 ] . start_height {
3509
+ if get_tip ( peer. sortdb . as_ref ( ) ) . block_height > epochs[ StacksEpochId :: Epoch21 ] . start_height
3510
+ {
3498
3511
assert_latest_was_burn ( & mut peer) ;
3499
3512
}
3500
3513
}
@@ -3700,10 +3713,12 @@ fn stack_with_segwit() {
3700
3713
} ;
3701
3714
3702
3715
// produce blocks until epoch 2.2
3703
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
3716
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
3717
+ {
3704
3718
peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3705
3719
// if we reach epoch 2.1, perform the check
3706
- if get_tip ( peer. sortdb . as_ref ( ) ) . block_height > epochs[ 3 ] . start_height {
3720
+ if get_tip ( peer. sortdb . as_ref ( ) ) . block_height > epochs[ StacksEpochId :: Epoch21 ] . start_height
3721
+ {
3707
3722
assert_latest_was_burn ( & mut peer) ;
3708
3723
}
3709
3724
}
@@ -3882,7 +3897,8 @@ fn stack_aggregation_increase() {
3882
3897
let mut latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3883
3898
3884
3899
// Roll to Epoch-2.4 and perform the delegate-stack-extend tests
3885
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
3900
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
3901
+ {
3886
3902
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
3887
3903
}
3888
3904
@@ -4296,7 +4312,8 @@ fn pox_3_delegate_stx_addr_validation() {
4296
4312
let mut latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
4297
4313
4298
4314
// Roll to Epoch-2.4 and perform the delegate-stack-extend tests
4299
- while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ 6 ] . start_height {
4315
+ while get_tip ( peer. sortdb . as_ref ( ) ) . block_height <= epochs[ StacksEpochId :: Epoch24 ] . start_height
4316
+ {
4300
4317
latest_block = peer. tenure_with_txs ( & [ ] , & mut coinbase_nonce) ;
4301
4318
}
4302
4319
0 commit comments