Skip to content

Commit 39baeb5

Browse files
committed
chore: increase coverage add tests
1 parent 2fdf96d commit 39baeb5

File tree

5 files changed

+67
-6
lines changed

5 files changed

+67
-6
lines changed

calculation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.cardanofoundation</groupId>
88
<artifactId>cf-rewards</artifactId>
9-
<version>0.10.0</version>
9+
<version>0.11.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lombok.addLombokGeneratedAnnotation = true

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.cardanofoundation</groupId>
66
<artifactId>cf-rewards</artifactId>
7-
<version>0.10.0</version>
7+
<version>0.11.0</version>
88
<name>cardano-reward-calculation</name>
99
<url>https://github.com/cardano-foundation/cf-java-rewards-calculation.git</url>
1010

validation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.cardanofoundation</groupId>
88
<artifactId>cf-rewards</artifactId>
9-
<version>0.10.0</version>
9+
<version>0.11.0</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

validation/src/test/java/org/cardanofoundation/rewards/validation/EpochValidationTest.java

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.cardanofoundation.rewards.validation;
22

33
import 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.*;
66
import org.cardanofoundation.rewards.validation.data.provider.DataProvider;
77
import org.cardanofoundation.rewards.validation.data.provider.DbSyncDataProvider;
88
import org.cardanofoundation.rewards.validation.data.provider.JsonDataProvider;
@@ -14,9 +14,15 @@
1414
import org.springframework.boot.test.context.SpringBootTest;
1515
import org.springframework.context.annotation.ComponentScan;
1616
import org.springframework.test.context.junit.jupiter.EnabledIf;
17+
18+
import java.math.BigInteger;
19+
import java.util.ArrayList;
20+
import java.util.HashSet;
1721
import java.util.stream.IntStream;
1822
import 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

Comments
 (0)