Search in sources :

Example 21 with DataStructureUtil

use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.

the class AbstractDatabaseTest method shouldRecordAndRetrieveGenesisInformation.

@Test
public void shouldRecordAndRetrieveGenesisInformation() {
    final DataStructureUtil util = new DataStructureUtil(spec);
    final MinGenesisTimeBlockEvent event = new MinGenesisTimeBlockEvent(util.randomUInt64(), util.randomUInt64(), util.randomBytes32());
    database.addMinGenesisTimeBlock(event);
    final Optional<MinGenesisTimeBlockEvent> fetch = database.getMinGenesisTimeBlock();
    assertThat(fetch.isPresent()).isTrue();
    assertThat(fetch.get()).isEqualToComparingFieldByField(event);
}
Also used : MinGenesisTimeBlockEvent(tech.pegasys.teku.ethereum.pow.api.MinGenesisTimeBlockEvent) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Example 22 with DataStructureUtil

use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.

the class WeakSubjectivityOptionsTest method weakSubjectivityCheckpoint_handleBadValue.

@Test
public void weakSubjectivityCheckpoint_handleBadValue() {
    final DataStructureUtil dataStructureUtil = new DataStructureUtil();
    final Checkpoint checkpoint = dataStructureUtil.randomCheckpoint();
    final String checkpointParam = checkpoint.getRoot().toHexString() + ":";
    final String[] args = { "--ws-checkpoint", checkpointParam };
    final int result = beaconNodeCommand.parse(args);
    String str = getCommandLineOutput();
    assertThat(str).contains("Invalid value for option '--ws-checkpoint': " + CheckpointConverter.CHECKPOINT_ERROR);
    assertThat(str).contains("To display full help:");
    assertThat(str).contains("--help");
    assertThat(result).isGreaterThan(0);
}
Also used : Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 23 with DataStructureUtil

use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.

the class WeakSubjectivityOptionsTest method weakSubjectivityCheckpoint_shouldAcceptValue.

@Test
public void weakSubjectivityCheckpoint_shouldAcceptValue() {
    final DataStructureUtil dataStructureUtil = new DataStructureUtil();
    final Checkpoint checkpoint = dataStructureUtil.randomCheckpoint();
    final String checkpointParam = checkpoint.getRoot().toHexString() + ":" + checkpoint.getEpoch();
    final TekuConfiguration config = getTekuConfigurationFromArguments("--ws-checkpoint", checkpointParam);
    assertThat(config.weakSubjectivity().getWeakSubjectivityCheckpoint()).contains(checkpoint);
    assertThat(createConfigBuilder().weakSubjectivity(b -> b.weakSubjectivityCheckpoint(checkpoint)).build()).usingRecursiveComparison().isEqualTo(config);
}
Also used : Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 24 with DataStructureUtil

use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.

the class SchemaObjectsTestFixture method syncCommitteeContribution.

public SyncCommitteeContribution syncCommitteeContribution(final UInt64 slot) {
    final Spec altairSpec = TestSpecFactory.createMainnetAltair();
    final DataStructureUtil altairData = new DataStructureUtil(altairSpec);
    return new SyncCommitteeContribution(altairData.randomSyncCommitteeContribution(slot));
}
Also used : SyncCommitteeContribution(tech.pegasys.teku.api.schema.altair.SyncCommitteeContribution) Spec(tech.pegasys.teku.spec.Spec) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

Example 25 with DataStructureUtil

use of tech.pegasys.teku.spec.util.DataStructureUtil in project teku by ConsenSys.

the class ExternalSignerBlockRequestProviderTest method altairBlockGeneratesCorrectSignTypeAndMetadata.

@Test
void altairBlockGeneratesCorrectSignTypeAndMetadata() {
    final Spec spec = TestSpecFactory.createMinimalAltair();
    final BeaconBlock block = new DataStructureUtil(spec).randomBeaconBlock(10);
    final ExternalSignerBlockRequestProvider externalSignerBlockRequestProvider = new ExternalSignerBlockRequestProvider(spec, block);
    final SignType signType = externalSignerBlockRequestProvider.getSignType();
    final Map<String, Object> blockMetadata = externalSignerBlockRequestProvider.getBlockMetadata(Map.of());
    assertThat(signType).isEqualTo(SignType.BLOCK_V2);
    assertThat(blockMetadata).containsKey("beacon_block");
    assertThat(blockMetadata.get("beacon_block")).isExactlyInstanceOf(BlockRequestBody.class);
}
Also used : BeaconBlock(tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock) Spec(tech.pegasys.teku.spec.Spec) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Aggregations

DataStructureUtil (tech.pegasys.teku.spec.util.DataStructureUtil)45 Test (org.junit.jupiter.api.Test)33 Spec (tech.pegasys.teku.spec.Spec)11 Checkpoint (tech.pegasys.teku.spec.datastructures.state.Checkpoint)8 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)7 Bytes32 (org.apache.tuweni.bytes.Bytes32)6 List (java.util.List)4 Bytes (org.apache.tuweni.bytes.Bytes)4 StubMetricsSystem (tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem)4 Attestation (tech.pegasys.teku.spec.datastructures.operations.Attestation)4 AnchorPoint (tech.pegasys.teku.spec.datastructures.state.AnchorPoint)4 Response (okhttp3.Response)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 PostDataFailureResponse (tech.pegasys.teku.api.response.v1.beacon.PostDataFailureResponse)3 BLSSignature (tech.pegasys.teku.api.schema.BLSSignature)3 SyncCommitteeMessage (tech.pegasys.teku.api.schema.altair.SyncCommitteeMessage)3 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)3 BLSSignature (tech.pegasys.teku.bls.BLSSignature)3 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)3 WeakSubjectivityConfig (tech.pegasys.teku.weaksubjectivity.config.WeakSubjectivityConfig)3