2
2
3
3
import static org .assertj .core .api .Assertions .assertThat ;
4
4
import static org .cardanofoundation .conversions .domain .NetworkType .MAINNET ;
5
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
5
6
6
7
import java .time .LocalDateTime ;
8
+ import org .cardanofoundation .conversions .CardanoConverters ;
7
9
import org .cardanofoundation .conversions .ClasspathConversionsFactory ;
8
- import org .junit .jupiter .api .Assertions ;
9
10
import org .junit .jupiter .api .BeforeEach ;
10
11
import org .junit .jupiter .api .Test ;
11
12
import org .junit .jupiter .params .ParameterizedTest ;
14
15
class TimeConversionsMainNetTest {
15
16
16
17
private static TimeConversions timeConversions ;
18
+ private CardanoConverters converters ;
17
19
18
20
@ BeforeEach
19
21
public void setup () {
20
- var converters = ClasspathConversionsFactory .createConverters (MAINNET );
22
+ converters = ClasspathConversionsFactory .createConverters (MAINNET );
21
23
timeConversions = converters .time ();
22
24
}
23
25
@@ -57,9 +59,25 @@ public void testBabbageEra1() {
57
59
.isEqualTo (450 );
58
60
}
59
61
62
+ @ Test
63
+ public void testOldDate () {
64
+ IllegalArgumentException thrownException =
65
+ assertThrows (
66
+ IllegalArgumentException .class ,
67
+ () -> {
68
+ timeConversions .toSlot (LocalDateTime .of (1979 , 10 , 3 , 21 , 44 , 11 ));
69
+ });
70
+ }
71
+
72
+ @ Test
73
+ public void testShelleyTime () {
74
+ assertThat (timeConversions .toSlot (converters .genesisConfig ().getShelleyStartTime ()))
75
+ .isEqualTo (4492800L );
76
+ }
77
+
60
78
@ Test
61
79
public void dateTimeToSlotBeforeBlockchainStartThrowsError () {
62
- Assertions . assertThrows (
80
+ assertThrows (
63
81
IllegalArgumentException .class ,
64
82
() -> timeConversions .toSlot (LocalDateTime .of (2015 , 10 , 3 , 21 , 44 , 11 )));
65
83
}
@@ -71,7 +89,7 @@ public void dateTimeToSlotBeforeBlockchainStartThrowsError() {
71
89
"2020-07-29T21:44:31,4492799" , // Last Byron
72
90
"2020-07-29T21:44:51,4492800" , // First Shelley
73
91
})
74
- public void slotToEpoch (String dateTime , long epoch ) {
75
- assertThat (timeConversions .toSlot (LocalDateTime .parse (dateTime ))).isEqualTo (epoch );
92
+ public void slotToEpoch (String dateTime , long absoluteSlot ) {
93
+ assertThat (timeConversions .toSlot (LocalDateTime .parse (dateTime ))).isEqualTo (absoluteSlot );
76
94
}
77
95
}
0 commit comments