@@ -42,7 +42,7 @@ use sp_runtime::{
4242use astar_primitives:: {
4343 dapp_staking:: {
4444 CycleConfiguration , EraNumber , RankedTier , SmartContractHandle , StakingRewardHandler ,
45- TierSlots ,
45+ TierSlots , STANDARD_TIER_SLOTS_ARGS ,
4646 } ,
4747 Balance , BlockNumber ,
4848} ;
@@ -2685,6 +2685,13 @@ fn force_with_safeguard_on_fails() {
26852685#[ test]
26862686fn tier_config_recalculation_works ( ) {
26872687 ExtBuilder :: default ( ) . build_and_execute ( || {
2688+ // Setup for price based slot capacity
2689+ StaticTierParams :: < Test > :: mutate ( |params| {
2690+ params. slot_number_args = STANDARD_TIER_SLOTS_ARGS ;
2691+ } ) ;
2692+ assert_ok ! ( DappStaking :: force( RuntimeOrigin :: root( ) , ForcingType :: Era ) ) ;
2693+ run_for_blocks ( 1 ) ;
2694+
26882695 let init_price = NATIVE_PRICE . with ( |v| v. borrow ( ) . clone ( ) ) ;
26892696 let init_tier_config = TierConfig :: < Test > :: get ( ) ;
26902697
@@ -2878,12 +2885,6 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() {
28782885 dapp_reward_pool,
28792886 ) ;
28802887
2881- // Debug: Print actual ranks assigned
2882- for ( dapp_id, ranked_tier) in tier_assignment. dapps . iter ( ) {
2883- let ( tier, rank) = ranked_tier. deconstruct ( ) ;
2884- println ! ( "Tier {}: dApp {} has rank {}" , tier, dapp_id, rank) ;
2885- }
2886-
28872888 // Ranks rewards are 50% of the tier allocation
28882889 // Dapp rewards allocations for tiers are: 40%, 30%, 20%, 10%
28892890 // Points per tiers are: 1, 55, 55, 55
@@ -3478,6 +3479,13 @@ fn safeguard_configurable_by_genesis_config() {
34783479#[ test]
34793480fn base_number_of_slots_is_respected ( ) {
34803481 ExtBuilder :: default ( ) . build_and_execute ( || {
3482+ // Setup for price based slot capacity
3483+ StaticTierParams :: < Test > :: mutate ( |params| {
3484+ params. slot_number_args = STANDARD_TIER_SLOTS_ARGS ;
3485+ } ) ;
3486+ assert_ok ! ( DappStaking :: force( RuntimeOrigin :: root( ) , ForcingType :: Era ) ) ;
3487+ run_for_blocks ( 1 ) ;
3488+
34813489 // 0. Get expected number of slots for the base price
34823490 let total_issuance = <Test as Config >:: Currency :: total_issuance ( ) ;
34833491 let base_native_price = <Test as Config >:: BaseNativeCurrencyPrice :: get ( ) ;
@@ -3589,36 +3597,17 @@ fn base_number_of_slots_is_respected() {
35893597#[ test]
35903598fn ranking_with_points_calculates_reward_correctly ( ) {
35913599 ExtBuilder :: default ( ) . build_and_execute ( || {
3592- // Configure tiers with specific rank_points for predictable testing
35933600 // Tier 1: 3 slots with points [5, 10, 15] (sum = 30)
35943601 // Tier 2: 2 slots with points [4, 8] (sum = 12)
3595- let tier_params = TierParameters :: < <Test as Config >:: NumberOfTiers > {
3596- reward_portion : BoundedVec :: try_from ( vec ! [
3597- Permill :: from_percent( 40 ) ,
3598- Permill :: from_percent( 30 ) ,
3599- Permill :: from_percent( 20 ) ,
3600- Permill :: from_percent( 10 ) ,
3601- ] )
3602- . unwrap ( ) ,
3603- slot_distribution : BoundedVec :: try_from ( vec ! [
3604- Permill :: from_percent( 10 ) ,
3605- Permill :: from_percent( 20 ) ,
3606- Permill :: from_percent( 30 ) ,
3607- Permill :: from_percent( 40 ) ,
3608- ] )
3609- . unwrap ( ) ,
3610- tier_thresholds : StaticTierParams :: < Test > :: get ( ) . tier_thresholds ,
3611- slot_number_args : ( 0 , 16 ) ,
3612- rank_points : BoundedVec :: try_from ( vec ! [
3602+ StaticTierParams :: < Test > :: mutate ( |params| {
3603+ params. rank_points = BoundedVec :: try_from ( vec ! [
36133604 BoundedVec :: try_from( vec![ ] ) . unwrap( ) , // tier 0: no ranking
36143605 BoundedVec :: try_from( vec![ 5u8 , 10 , 15 ] ) . unwrap( ) , // tier 1: sum = 30
36153606 BoundedVec :: try_from( vec![ 4u8 , 8 ] ) . unwrap( ) , // tier 2: sum = 12
36163607 BoundedVec :: try_from( vec![ ] ) . unwrap( ) , // tier 3: no ranking
36173608 ] )
3618- . unwrap ( ) ,
3619- base_reward_portion : Permill :: from_percent ( 50 ) ,
3620- } ;
3621- StaticTierParams :: < Test > :: put ( tier_params) ;
3609+ . unwrap ( ) ;
3610+ } ) ;
36223611
36233612 // Tier config is specially adapted for this test.
36243613 TierConfig :: < Test > :: mutate ( |config| {
@@ -3680,10 +3669,10 @@ fn ranking_with_points_calculates_reward_correctly() {
36803669 // Tier 3: no ranking → 0
36813670 rank_rewards: BoundedVec :: try_from( vec![ 0 , 5_000 , 8_333 , 0 ] ) . unwrap( ) ,
36823671 rank_points: BoundedVec :: try_from( vec![
3683- BoundedVec :: try_from( vec![ ] ) . unwrap( ) , // tier 0: no ranking
3684- BoundedVec :: try_from( vec![ 5u8 , 10 , 15 ] ) . unwrap( ) , // tier 1: sum = 30
3685- BoundedVec :: try_from( vec![ 4u8 , 8 ] ) . unwrap( ) , // tier 2: sum = 12
3686- BoundedVec :: try_from( vec![ ] ) . unwrap( ) , // tier 3: no ranking
3672+ BoundedVec :: try_from( vec![ ] ) . unwrap( ) ,
3673+ BoundedVec :: try_from( vec![ 5u8 , 10 , 15 ] ) . unwrap( ) ,
3674+ BoundedVec :: try_from( vec![ 4u8 , 8 ] ) . unwrap( ) ,
3675+ BoundedVec :: try_from( vec![ ] ) . unwrap( ) ,
36873676 ] )
36883677 . unwrap( ) ,
36893678 }
@@ -3698,8 +3687,7 @@ fn ranking_with_points_calculates_reward_correctly() {
36983687#[ test]
36993688fn claim_dapp_reward_with_rank_points ( ) {
37003689 ExtBuilder :: default ( ) . build_and_execute ( || {
3701- // Configure tier 1 with rank_points for testing
3702- // 5 slots with points [1, 5, 10, 15, 20]
3690+ // Tier-1: 5 slots with points [1, 5, 10, 15, 20]
37033691 StaticTierParams :: < Test > :: mutate ( |params| {
37043692 params. rank_points = BoundedVec :: try_from ( vec ! [
37053693 BoundedVec :: try_from( vec![ ] ) . unwrap( ) ,
@@ -3708,7 +3696,6 @@ fn claim_dapp_reward_with_rank_points() {
37083696 BoundedVec :: try_from( vec![ ] ) . unwrap( ) ,
37093697 ] )
37103698 . unwrap ( ) ;
3711- params. base_reward_portion = Permill :: from_percent ( 50 ) ;
37123699 } ) ;
37133700
37143701 let total_issuance = <Test as Config >:: Currency :: total_issuance ( ) ;
0 commit comments