use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.
the class DepositProviderTest method setup.
void setup(final int maxDeposits) {
when(state.getSlot()).thenReturn(UInt64.valueOf(1234));
SpecConfig specConfig = SpecConfigLoader.loadConfig("minimal", b -> b.maxDeposits(maxDeposits));
spec = TestSpecFactory.createPhase0(specConfig);
depositUtil = new DepositUtil(spec);
dataStructureUtil = new DataStructureUtil(spec);
depositProvider = new DepositProvider(new StubMetricsSystem(), recentChainData, eth1DataCache, spec);
depositMerkleTree = new OptimizedMerkleTree(spec.getGenesisSpecConfig().getDepositContractTreeDepth());
mockStateEth1DataVotes();
createDepositEvents(40);
randomEth1Data = dataStructureUtil.randomEth1Data();
}
use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.
the class TerminalPowBlockMonitorTest method setUpCommon.
private void setUpCommon(Consumer<BellatrixBuilder> bellatrixBuilder) {
spec = TestSpecFactory.createBellatrix(SpecConfigLoader.loadConfig("minimal", phase0Builder -> phase0Builder.altairBuilder(altairBuilder -> altairBuilder.altairForkEpoch(UInt64.ZERO)).bellatrixBuilder(bellatrixBuilder)));
dataStructureUtil = new DataStructureUtil(spec);
storageSystem = InMemoryStorageSystemBuilder.buildDefault(spec);
storageSystem.chainUpdater().initializeGenesis(false);
recentChainData = storageSystem.recentChainData();
localTransitionConfiguration = new TransitionConfiguration(spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalTotalDifficulty(), spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalBlockHash(), UInt64.ZERO);
terminalPowBlockMonitor = new TerminalPowBlockMonitor(executionEngine, spec, recentChainData, forkChoiceNotifier, asyncRunner, eventLogger);
terminalPowBlockMonitor.onNodeSyncStateChanged(true);
}
use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.
the class RpcResponseDecoderTest method beaconState.
private BeaconState beaconState(final boolean usePhase0State) {
final Spec spec = usePhase0State ? TestSpecFactory.createMinimalPhase0() : TestSpecFactory.createMinimalAltair();
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
return usePhase0State ? dataStructureUtil.stateBuilderPhase0().build() : dataStructureUtil.stateBuilderAltair().build();
}
use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertEnrForkId.
@Test
public void shouldConvertEnrForkId() {
EnrForkId enrForkId = new DataStructureUtil().randomEnrForkId();
Bytes encodedForkId = enrForkId.sszSerialize();
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234), new EnrField(ETH2_ENR_FIELD, encodedForkId));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), Optional.of(enrForkId), ATTNETS, SYNCNETS));
}
use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.
the class MetricRecordingValidatorApiChannelTest method getSendDataArguments.
public static Stream<Arguments> getSendDataArguments() {
final DataStructureUtil dataStructureUtil = new DataStructureUtil(TestSpecFactory.createMinimalAltair());
final List<SubmitDataError> submissionErrors = List.of(new SubmitDataError(UInt64.ZERO, "Nope"));
final List<Attestation> attestations = List.of(dataStructureUtil.randomAttestation());
final List<SyncCommitteeMessage> syncCommitteeMessages = List.of(dataStructureUtil.randomSyncCommitteeMessage());
final List<SignedAggregateAndProof> aggregateAndProofs = List.of(dataStructureUtil.randomSignedAggregateAndProof());
return Stream.of(sendDataTest("sendSignedAttestations", channel -> channel.sendSignedAttestations(attestations), MetricRecordingValidatorApiChannel.PUBLISHED_ATTESTATION_COUNTER_NAME, submissionErrors), sendDataTest("sendSyncCommitteeMessages", channel -> channel.sendSyncCommitteeMessages(syncCommitteeMessages), MetricRecordingValidatorApiChannel.SYNC_COMMITTEE_SEND_MESSAGES_NAME, submissionErrors), sendDataTest("sendAggregateAndProofs", channel -> channel.sendAggregateAndProofs(aggregateAndProofs), MetricRecordingValidatorApiChannel.PUBLISHED_AGGREGATE_COUNTER_NAME, submissionErrors));
}
Aggregations