Skip to content

Commit dc18f49

Browse files
author
Mateusz Czeladka
committed
chore: adding more tests
1 parent 8a63774 commit dc18f49

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/test/java/org/cardanofoundation/conversions/converters/TimeConversionsMainNetTest.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44
import static org.cardanofoundation.conversions.domain.NetworkType.MAINNET;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
56

67
import java.time.LocalDateTime;
8+
import org.cardanofoundation.conversions.CardanoConverters;
79
import org.cardanofoundation.conversions.ClasspathConversionsFactory;
8-
import org.junit.jupiter.api.Assertions;
910
import org.junit.jupiter.api.BeforeEach;
1011
import org.junit.jupiter.api.Test;
1112
import org.junit.jupiter.params.ParameterizedTest;
@@ -14,10 +15,11 @@
1415
class 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 testShelleySlot() {
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
}

src/test/java/org/cardanofoundation/conversions/converters/TimeConversionsPreProdTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ public void testBabbageEra2() {
2929
assertThat(timeConversions.utcTimeToEpochNo(LocalDateTime.of(2023, 11, 23, 12, 48, 58)))
3030
.isEqualTo(108);
3131
}
32+
33+
@Test
34+
// https://preprod.cardanoscan.io/transaction/1188eb4283ae74e4e62d99ec201cb15ee916d4edb2b70fc8de3cb2824ea461b7
35+
public void toSlot1() {
36+
assertThat(timeConversions.toSlot(LocalDateTime.of(2024, 11, 29, 15, 51, 43)))
37+
.isEqualTo(77208703L);
38+
}
3239
}

0 commit comments

Comments
 (0)