22
33import static org .assertj .core .api .Assertions .assertThat ;
44import static org .cardanofoundation .conversions .domain .NetworkType .MAINNET ;
5+ import static org .junit .jupiter .api .Assertions .assertThrows ;
56
67import java .time .LocalDateTime ;
8+ import org .cardanofoundation .conversions .CardanoConverters ;
79import org .cardanofoundation .conversions .ClasspathConversionsFactory ;
8- import org .junit .jupiter .api .Assertions ;
910import org .junit .jupiter .api .BeforeEach ;
1011import org .junit .jupiter .api .Test ;
1112import org .junit .jupiter .params .ParameterizedTest ;
1415class TimeConversionsMainNetTest {
1516
1617 private static TimeConversions timeConversions ;
18+ private CardanoConverters converters ;
1719
1820 @ BeforeEach
1921 public void setup () {
20- var converters = ClasspathConversionsFactory .createConverters (MAINNET );
22+ converters = ClasspathConversionsFactory .createConverters (MAINNET );
2123 timeConversions = converters .time ();
2224 }
2325
@@ -57,9 +59,25 @@ public void testBabbageEra1() {
5759 .isEqualTo (450 );
5860 }
5961
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+
6078 @ Test
6179 public void dateTimeToSlotBeforeBlockchainStartThrowsError () {
62- Assertions . assertThrows (
80+ assertThrows (
6381 IllegalArgumentException .class ,
6482 () -> timeConversions .toSlot (LocalDateTime .of (2015 , 10 , 3 , 21 , 44 , 11 )));
6583 }
@@ -71,7 +89,7 @@ public void dateTimeToSlotBeforeBlockchainStartThrowsError() {
7189 "2020-07-29T21:44:31,4492799" , // Last Byron
7290 "2020-07-29T21:44:51,4492800" , // First Shelley
7391 })
74- public void slotToEpoch (String dateTime , long epoch ) {
75- assertThat (timeConversions .toSlot (LocalDateTime .parse (dateTime ))).isEqualTo (epoch );
92+ public void dateToSlot (String dateTime , long absoluteSlot ) {
93+ assertThat (timeConversions .toSlot (LocalDateTime .parse (dateTime ))).isEqualTo (absoluteSlot );
7694 }
7795}
0 commit comments