|
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 | }
|
|
0 commit comments