Skip to content

Commit 4861a14

Browse files
committed
Take default when storage graffiti is empty
1 parent 77be046 commit 4861a14

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

validator/api/src/main/java/tech/pegasys/teku/validator/api/UpdatableGraffitiProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public UpdatableGraffitiProvider(
4343

4444
@Override
4545
public Optional<Bytes32> get() {
46-
return getGraffitiFromStorage().or(defaultProvider::get).filter(this::graffitiNotEmpty);
46+
return getGraffitiFromStorage().filter(this::graffitiNotEmpty).or(defaultProvider::get);
4747
}
4848

4949
private Optional<Bytes32> getGraffitiFromStorage() {

validator/api/src/test/java/tech/pegasys/teku/validator/api/UpdatableGraffitiProviderTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ void get_shouldUseDefaultWhenFileNotReadable(@TempDir final Path tempDir) throws
101101
}
102102

103103
@Test
104-
void get_shouldReturnEmptyWhenEmptyFileAvailable(@TempDir final Path tempDir) throws IOException {
104+
void get_shouldReturnDefaultWhenEmptyFileAvailable(@TempDir final Path tempDir)
105+
throws IOException {
105106
dataDirLayout = new SimpleDataDirLayout(tempDir);
106107
provider = new UpdatableGraffitiProvider(dataDirLayout, publicKey, defaultProvider);
107108
storeGraffiti(publicKey, Bytes32.EMPTY);
108109

109-
assertThat(provider.get()).isEmpty();
110+
assertThat(provider.get()).hasValue(defaultGraffiti);
110111
}
111112

112113
private void storeGraffiti(final BLSPublicKey publicKey, final Bytes graffiti)

0 commit comments

Comments
 (0)