Skip to content

Commit b2a3696

Browse files
committed
Remove static of timestamp formatter
1 parent 25ee9d6 commit b2a3696

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Diff for: ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataDumper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private void createDirectory(
141141
}
142142

143143
@VisibleForTesting
144-
static String formatTimestamp(final Optional<UInt64> arrivalTimestamp) {
144+
String formatTimestamp(final Optional<UInt64> arrivalTimestamp) {
145145
if (arrivalTimestamp.isEmpty()) {
146146
return "unknown";
147147
}

Diff for: ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/DebugDataDumperTest.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void saveGossipMessageDecodingError_shouldSaveToFile(@TempDir Path tempDir) {
4747
final String topic = "test_topic";
4848
manager.saveGossipMessageDecodingError("test_topic", arrivalTimestamp, messageBytes);
4949

50-
final String fileName =
51-
String.format("%s.ssz", DebugDataDumper.formatTimestamp(arrivalTimestamp));
50+
final String fileName = String.format("%s.ssz", manager.formatTimestamp(arrivalTimestamp));
5251
final Path expectedFile =
5352
tempDir
5453
.resolve("gossip_messages")
@@ -66,8 +65,7 @@ void saveGossipMessageDecodingError_shouldNotSaveToFileWhenDisabled(@TempDir Pat
6665
manager.saveGossipMessageDecodingError("test_topic", arrivalTimestamp, messageBytes);
6766
assertThat(manager.isEnabled()).isFalse();
6867

69-
final String fileName =
70-
String.format("%s.ssz", DebugDataDumper.formatTimestamp(arrivalTimestamp));
68+
final String fileName = String.format("%s.ssz", manager.formatTimestamp(arrivalTimestamp));
7169
final Path expectedFile =
7270
tempDir.resolve("gossip_messages").resolve("decoding_error").resolve(fileName);
7371
checkFileNotExist(expectedFile);
@@ -81,8 +79,7 @@ void saveGossipRejectedMessageToFile_shouldSaveToFile(@TempDir Path tempDir) {
8179
final String topic = "test_topic";
8280
manager.saveGossipRejectedMessageToFile("test_topic", arrivalTimestamp, messageBytes);
8381

84-
final String fileName =
85-
String.format("%s.ssz", DebugDataDumper.formatTimestamp(arrivalTimestamp));
82+
final String fileName = String.format("%s.ssz", manager.formatTimestamp(arrivalTimestamp));
8683
final Path expectedFile =
8784
tempDir.resolve("gossip_messages").resolve("rejected").resolve(topic).resolve(fileName);
8885
checkBytesSavedToFile(expectedFile, messageBytes);
@@ -157,14 +154,16 @@ void constructionOfDirectories_shouldDisableWhenFailedToCreate(@TempDir Path tem
157154

158155
@Test
159156
void formatTimestamp_shouldFormatDate() {
157+
final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true);
160158
final String formattedTimestamp =
161-
DebugDataDumper.formatTimestamp(Optional.of(timeProvider.getTimeInMillis()));
159+
manager.formatTimestamp(Optional.of(timeProvider.getTimeInMillis()));
162160
assertThat(formattedTimestamp).isEqualTo("1970-01-01T12:46:40.00");
163161
}
164162

165163
@Test
166164
void formatTimestamp_shouldReturnConsistentUnknown() {
167-
final String formattedTimestamp = DebugDataDumper.formatTimestamp(Optional.empty());
165+
final DebugDataDumper manager = new DebugDataDumper(Path.of("."), true);
166+
final String formattedTimestamp = manager.formatTimestamp(Optional.empty());
168167
assertThat(formattedTimestamp).isEqualTo("unknown");
169168
}
170169

0 commit comments

Comments
 (0)