Search in sources :

Example 26 with Bytes4

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");
}
Also used : SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) Eth2TopicHandler(tech.pegasys.teku.networking.eth2.gossip.topics.topichandlers.Eth2TopicHandler) Test(org.junit.jupiter.api.Test)

Example 27 with Bytes4

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);
}
Also used : SpecVersion(tech.pegasys.teku.spec.SpecVersion) Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4)

Example 28 with Bytes4

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);
    }
}
Also used : Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) SpecMilestone(tech.pegasys.teku.spec.SpecMilestone)

Example 29 with Bytes4

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");
}
Also used : DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) File(java.io.File) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test)

Example 30 with Bytes4

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));
}
Also used : Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) File(java.io.File) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Test(org.junit.jupiter.api.Test)

Aggregations

Bytes4 (tech.pegasys.teku.infrastructure.bytes.Bytes4)33 Test (org.junit.jupiter.api.Test)20 Bytes32 (org.apache.tuweni.bytes.Bytes32)5 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)5 File (java.io.File)4 Bytes (org.apache.tuweni.bytes.Bytes)4 Eth2TopicHandler (tech.pegasys.teku.networking.eth2.gossip.topics.topichandlers.Eth2TopicHandler)4 SpecVersion (tech.pegasys.teku.spec.SpecVersion)4 Eth1Address (tech.pegasys.teku.spec.datastructures.eth1.Eth1Address)4 SignedBeaconBlock (tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock)3 EnrForkId (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId)3 ForkInfo (tech.pegasys.teku.spec.datastructures.state.ForkInfo)3 SingleProtocolEth2RpcMethod (tech.pegasys.teku.networking.eth2.rpc.core.methods.SingleProtocolEth2RpcMethod)2 SignedBeaconBlockSchema (tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema)2 Fork (tech.pegasys.teku.spec.datastructures.state.Fork)2 DatabaseStorageException (tech.pegasys.teku.storage.server.DatabaseStorageException)2 Suppliers (com.google.common.base.Suppliers)1 Optional (java.util.Optional)1 Random (java.util.Random)1 Set (java.util.Set)1