use of tech.pegasys.teku.infrastructure.bytes.Bytes4 in project teku by ConsenSys.
the class VoluntaryExitTopicHandlerTest method returnProperTopicName.
@Test
public void returnProperTopicName() {
final Bytes4 forkDigest = Bytes4.fromHexString("0x11223344");
final Eth2TopicHandler<SignedVoluntaryExit> topicHandler = new Eth2TopicHandler<>(recentChainData, asyncRunner, processor, gossipEncoding, forkDigest, GossipTopicName.VOLUNTARY_EXIT, SignedVoluntaryExit.SSZ_SCHEMA, GOSSIP_MAX_SIZE);
assertThat(topicHandler.getTopic()).isEqualTo("/eth2/11223344/voluntary_exit/ssz_snappy");
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes4 in project teku by ConsenSys.
the class DataStructureUtil method computeDomain.
private Bytes32 computeDomain() {
final SpecVersion genesisSpec = spec.getGenesisSpec();
final Bytes4 domain = Domain.DEPOSIT;
return genesisSpec.miscHelpers().computeDomain(domain);
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes4 in project teku by ConsenSys.
the class SnappyPreparedGossipMessage method createMessageIdCalculator.
private MessageIdCalculator createMessageIdCalculator(final String topic, final Bytes compressedData, final ForkDigestToMilestone forkDigestToMilestone) {
final Bytes4 forkDigest = GossipTopics.extractForkDigest(topic);
final SpecMilestone milestone = forkDigestToMilestone.getMilestone(forkDigest).orElseThrow(() -> new IllegalStateException("Failed to associate a milestone with the forkDigest in topic: " + topic));
switch(milestone) {
case PHASE0:
return new MesssageIdCalculatorPhase0(compressedData);
case ALTAIR:
default:
return new MesssageIdCalculatorAltair(compressedData, topic);
}
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes4 in project teku by ConsenSys.
the class DatabaseNetworkTest method shouldThrowIfForkDiffers.
@Test
public void shouldThrowIfForkDiffers(@TempDir final File tempDir) throws IOException {
final File networkFile = new File(tempDir, "network.yml");
assertThat(networkFile).doesNotExist();
final Bytes4 fork = dataStructureUtil.randomFork().getCurrent_version();
final Eth1Address eth1Address = dataStructureUtil.randomEth1Address();
DatabaseNetwork.init(networkFile, dataStructureUtil.randomFork().getCurrent_version(), eth1Address);
assertThatThrownBy(() -> DatabaseNetwork.init(networkFile, fork, eth1Address)).isInstanceOf(DatabaseStorageException.class).hasMessageStartingWith("Supplied fork version");
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes4 in project teku by ConsenSys.
the class DatabaseNetworkTest method shouldNotThrowIfForkAndContractMatch.
@Test
public void shouldNotThrowIfForkAndContractMatch(@TempDir final File tempDir) throws IOException {
final File networkFile = new File(tempDir, "network.yml");
assertThat(networkFile).doesNotExist();
final Bytes4 fork = dataStructureUtil.randomFork().getCurrent_version();
final Eth1Address eth1Address = dataStructureUtil.randomEth1Address();
DatabaseNetwork.init(networkFile, fork, eth1Address);
assertDoesNotThrow(() -> DatabaseNetwork.init(networkFile, fork, eth1Address));
}
Aggregations