Skip to content

Commit

Permalink
Ran spotlessApply
Browse files Browse the repository at this point in the history
Signed-off-by: gconnect <[email protected]>
  • Loading branch information
gconnect committed Sep 23, 2024
1 parent ba511c6 commit 68cdd57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ public class DatabaseNetwork {

@JsonCreator
DatabaseNetwork(
@JsonProperty("fork_version") final String forkVersion,
@JsonProperty("deposit_contract") final String depositContract,
@JsonProperty("deposit_chainId") final Long depositChainId) {
@JsonProperty("fork_version") final String forkVersion,
@JsonProperty("deposit_contract") final String depositContract,
@JsonProperty("deposit_chainId") final Long depositChainId) {
this.forkVersion = forkVersion;
this.depositContract = depositContract;
this.depositChainId = depositChainId;
}

DatabaseNetwork(
final String forkVersion,
final String depositContract) {
DatabaseNetwork(final String forkVersion, final String depositContract) {
this(forkVersion, depositContract, null);
}

Expand Down Expand Up @@ -110,7 +108,7 @@ public boolean equals(final Object o) {
final DatabaseNetwork that = (DatabaseNetwork) o;
return Objects.equals(forkVersion, that.forkVersion)
&& Objects.equals(depositContract, that.depositContract)
&& Objects.equals(depositChainId, that.depositChainId);
&& Objects.equals(depositChainId, that.depositChainId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Locale;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
Expand Down Expand Up @@ -90,44 +88,43 @@ public void shouldNotThrowIfForkAndContractMatch(@TempDir final File tempDir) th
}

@Test
void shouldWriteAndReadDatabaseNetworkWithChainId(@TempDir final File tempDir) throws IOException {
void shouldWriteAndReadDatabaseNetworkWithChainId(@TempDir final File tempDir)
throws IOException {
final File networkFile = new File(tempDir, "network.yml");

final Bytes4 fork = dataStructureUtil.randomFork().getCurrentVersion();
final Eth1Address eth1Address = dataStructureUtil.randomEth1Address();
final Long depositId = dataStructureUtil.randomLong();
DatabaseNetwork databaseNetwork = new DatabaseNetwork(
fork.toHexString(),
eth1Address.toHexString(),
depositId);
DatabaseNetwork databaseNetwork =
new DatabaseNetwork(fork.toHexString(), eth1Address.toHexString(), depositId);

ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
objectMapper.writerFor(DatabaseNetwork.class).writeValue(networkFile, databaseNetwork);
DatabaseNetwork readDatabaseNetwork = objectMapper.readerFor(DatabaseNetwork.class).readValue(networkFile);
DatabaseNetwork readDatabaseNetwork =
objectMapper.readerFor(DatabaseNetwork.class).readValue(networkFile);

assertEquals(fork.toHexString(), readDatabaseNetwork.forkVersion);
assertEquals(eth1Address.toHexString(), readDatabaseNetwork.depositContract);
assertEquals(depositId, readDatabaseNetwork.depositChainId);
}

@Test
void shouldWriteAndReadDatabaseNetworkWithoutChainId(@TempDir final File tempDir) throws IOException {
void shouldWriteAndReadDatabaseNetworkWithoutChainId(@TempDir final File tempDir)
throws IOException {
final File networkFile = new File(tempDir, "network.yml");

final Bytes4 fork = dataStructureUtil.randomFork().getCurrentVersion();
final Eth1Address eth1Address = dataStructureUtil.randomEth1Address();
DatabaseNetwork databaseNetwork = new DatabaseNetwork(
fork.toHexString(),
eth1Address.toHexString(),
null);
DatabaseNetwork databaseNetwork =
new DatabaseNetwork(fork.toHexString(), eth1Address.toHexString(), null);

ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
objectMapper.writerFor(DatabaseNetwork.class).writeValue(networkFile, databaseNetwork);
DatabaseNetwork readDatabaseNetwork = objectMapper.readerFor(DatabaseNetwork.class).readValue(networkFile);
DatabaseNetwork readDatabaseNetwork =
objectMapper.readerFor(DatabaseNetwork.class).readValue(networkFile);

assertEquals(fork.toHexString(), readDatabaseNetwork.forkVersion);
assertEquals(eth1Address.toHexString(), readDatabaseNetwork.depositContract);
assertNull(readDatabaseNetwork.depositChainId);
}

}

0 comments on commit 68cdd57

Please sign in to comment.