From ae09a43ceff139cc50fe677a4b182aaac6a289e0 Mon Sep 17 00:00:00 2001 From: courtneyeh Date: Fri, 12 Apr 2024 16:25:46 +1000 Subject: [PATCH] Fix unit test --- .../statetransition/util/DebugDataDumperTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/DebugDataDumperTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/DebugDataDumperTest.java index 4d02887ddf1..dc33c3ddeab 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/DebugDataDumperTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/DebugDataDumperTest.java @@ -22,6 +22,9 @@ import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.sql.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Optional; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; @@ -162,14 +165,20 @@ void formatTimestamp_shouldFormatDate() { final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true); final String formattedTimestamp = manager.formatOptionalTimestamp(Optional.of(timeProvider.getTimeInMillis())); - assertThat(formattedTimestamp).isEqualTo("1970-01-01T12_46_40.00"); + + final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss.SS"); + final Date date = new Date(timeProvider.getTimeInMillis().longValue()); + assertThat(formattedTimestamp).isEqualTo(df.format(date)); } @Test void generateTimestamp_shouldGenerateTimestamp() { final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true); final String formattedTimestamp = manager.generateTimestamp(timeProvider); - assertThat(formattedTimestamp).isEqualTo("1970-01-01T12_46_40.00"); + + final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss.SS"); + final Date date = new Date(timeProvider.getTimeInMillis().longValue()); + assertThat(formattedTimestamp).isEqualTo(df.format(date)); } private void checkBytesSavedToFile(final Path path, final Bytes expectedBytes) {