11package org .cardanofoundation .rewards .validation ;
22
33import lombok .extern .slf4j .Slf4j ;
4- import org .cardanofoundation .rewards .calculation .domain . AdaPots ;
5- import org .cardanofoundation .rewards .calculation .domain .EpochCalculationResult ;
4+ import org .cardanofoundation .rewards .calculation .EpochCalculation ;
5+ import org .cardanofoundation .rewards .calculation .domain .* ;
66import org .cardanofoundation .rewards .validation .data .provider .DataProvider ;
77import org .cardanofoundation .rewards .validation .data .provider .DbSyncDataProvider ;
88import org .cardanofoundation .rewards .validation .data .provider .JsonDataProvider ;
1414import org .springframework .boot .test .context .SpringBootTest ;
1515import org .springframework .context .annotation .ComponentScan ;
1616import org .springframework .test .context .junit .jupiter .EnabledIf ;
17+
18+ import java .math .BigInteger ;
19+ import java .util .ArrayList ;
20+ import java .util .HashSet ;
1721import java .util .stream .IntStream ;
1822import java .util .stream .Stream ;
1923
24+ import static org .cardanofoundation .rewards .calculation .constants .RewardConstants .*;
25+
2026@ SpringBootTest
2127@ ComponentScan
2228@ Slf4j
@@ -31,6 +37,14 @@ public void testCalculateEpochPots(final int epoch, DataProvider dataProvider, b
3137 EpochCalculationResult epochCalculationResult = EpochValidation .calculateEpochRewardPots (epoch , dataProvider , detailedValidation );
3238 AdaPots adaPotsForCurrentEpoch = dataProvider .getAdaPotsForEpoch (epoch );
3339
40+ if (epoch < MAINNET_SHELLEY_START_EPOCH ) {
41+ log .info ("Epoch " + epoch + " is before Shelley era, no rewards are calculated" );
42+ return ;
43+ } else if (epoch == MAINNET_SHELLEY_START_EPOCH ) {
44+ log .info ("Epoch " + epoch + " is the first Shelley era epoch, no rewards are calculated" );
45+ return ;
46+ }
47+
3448 log .info ("Treasury difference: " + adaPotsForCurrentEpoch .getTreasury ().subtract (epochCalculationResult .getTreasury ()).longValue () + " Lovelace" );
3549 log .info ("Reserves difference: " + adaPotsForCurrentEpoch .getReserves ().subtract (epochCalculationResult .getReserves ()).longValue () + " Lovelace" );
3650
@@ -39,8 +53,54 @@ public void testCalculateEpochPots(final int epoch, DataProvider dataProvider, b
3953 Assertions .assertEquals (adaPotsForCurrentEpoch .getReserves (), epochCalculationResult .getReserves ());
4054 }
4155
56+ @ Test
57+ public void testCalculateEpochRewardsForEpoch207 () {
58+ EpochCalculationResult epochCalculationResult = EpochCalculation .calculateEpochRewardPots (207 ,
59+ BigInteger .ZERO ,
60+ BigInteger .ZERO ,
61+ new ProtocolParameters (),
62+ new Epoch (),
63+ new HashSet <>(),
64+ new HashSet <>(),
65+ new ArrayList <>(),
66+ new ArrayList <>(),
67+ new ArrayList <>(),
68+ new HashSet <>(), new HashSet <>(), new HashSet <>(), new HashSet <>(), new HashSet <>()
69+ );
70+ Assertions .assertEquals (epochCalculationResult .getReserves (), BigInteger .ZERO );
71+ Assertions .assertEquals (epochCalculationResult .getTreasury (), BigInteger .ZERO );
72+ }
73+
74+ @ Test
75+ public void testCalculateEpochRewardsForEpoch208 () {
76+ EpochCalculationResult epochCalculationResult = EpochCalculation .calculateEpochRewardPots (208 ,
77+ BigInteger .ZERO ,
78+ BigInteger .ZERO ,
79+ new ProtocolParameters (),
80+ new Epoch (),
81+ new HashSet <>(),
82+ new HashSet <>(),
83+ new ArrayList <>(),
84+ new ArrayList <>(),
85+ new ArrayList <>(),
86+ new HashSet <>(), new HashSet <>(), new HashSet <>(), new HashSet <>(), new HashSet <>()
87+ );
88+ Assertions .assertEquals (epochCalculationResult .getReserves (), MAINNET_SHELLEY_INITIAL_RESERVES );
89+ Assertions .assertEquals (epochCalculationResult .getTreasury (), MAINNET_SHELLEY_INITIAL_TREASURY );
90+ }
91+
92+ @ Test
93+ public void testAllegraHardForkEpoch () {
94+ testCalculateEpochPots (MAINNET_ALLEGRA_HARDFORK_EPOCH , jsonDataProvider , false );
95+ }
96+
97+ @ Test
98+ public void testCalculateEpochRewardsForEpoch360 () {
99+ testCalculateEpochPots (360 , jsonDataProvider , false );
100+ }
101+
42102 static Stream <Integer > dataProviderEpochRange () {
43- return IntStream .range (208 , 230 ).boxed ();
103+ return IntStream .range (206 , 230 ).boxed ();
44104 }
45105
46106 @ ParameterizedTest
0 commit comments