Search in sources :

Example 41 with DataStructureUtil

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

the class SyncCommitteeSchedulerTest method shouldNotRecalculateDutiesOnHeadUpdateWithSlotNonPriorToAltairActivation.

@Test
void shouldNotRecalculateDutiesOnHeadUpdateWithSlotNonPriorToAltairActivation() {
    scheduler.onSlot(UInt64.ONE);
    verify(dutyLoader).loadDutiesForEpoch(getRequestEpochForCommitteePeriod(0));
    DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    scheduler.onHeadUpdate(UInt64.ZERO, dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes32());
    verifyNoMoreInteractions(dutyLoader);
}
Also used : DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Example 42 with DataStructureUtil

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

the class SyncCommitteeSchedulerTest method shouldRecalculateDutiesOnHeadUpdateWithSlotPriorToAltairActivation.

@Test
void shouldRecalculateDutiesOnHeadUpdateWithSlotPriorToAltairActivation() {
    // simulates altair activation at slot 1
    Spec mockedSpec = spy(spec);
    SyncCommitteeScheduler schedulerWithMockedSpec = new SyncCommitteeScheduler(new StubMetricsSystem(), mockedSpec, dutyLoader, earlySubscribeRandomSource);
    when(mockedSpec.getSyncCommitteeUtil(UInt64.ZERO)).thenReturn(Optional.empty());
    schedulerWithMockedSpec.onSlot(UInt64.ONE);
    verify(dutyLoader).loadDutiesForEpoch(getRequestEpochForCommitteePeriod(0));
    DataStructureUtil dataStructureUtil = new DataStructureUtil(mockedSpec);
    schedulerWithMockedSpec.onHeadUpdate(UInt64.ZERO, dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes32());
    verify(dutyLoader, times(2)).loadDutiesForEpoch(getRequestEpochForCommitteePeriod(0));
}
Also used : StubMetricsSystem(tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem) Spec(tech.pegasys.teku.spec.Spec) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Example 43 with DataStructureUtil

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

the class AbstractDatabaseTest method updateWeakSubjectivityState_setValue.

@Test
public void updateWeakSubjectivityState_setValue() {
    final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    final Checkpoint checkpoint = dataStructureUtil.randomCheckpoint();
    assertThat(database.getWeakSubjectivityState().getCheckpoint()).isEmpty();
    final WeakSubjectivityUpdate update = WeakSubjectivityUpdate.setWeakSubjectivityCheckpoint(checkpoint);
    database.updateWeakSubjectivityState(update);
    assertThat(database.getWeakSubjectivityState().getCheckpoint()).contains(checkpoint);
}
Also used : WeakSubjectivityUpdate(tech.pegasys.teku.storage.events.WeakSubjectivityUpdate) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Example 44 with DataStructureUtil

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

the class AbstractDatabaseTest method updateWeakSubjectivityState_clearValue.

@Test
public void updateWeakSubjectivityState_clearValue() {
    final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
    final Checkpoint checkpoint = dataStructureUtil.randomCheckpoint();
    // Set an initial value
    final WeakSubjectivityUpdate initUpdate = WeakSubjectivityUpdate.setWeakSubjectivityCheckpoint(checkpoint);
    database.updateWeakSubjectivityState(initUpdate);
    assertThat(database.getWeakSubjectivityState().getCheckpoint()).contains(checkpoint);
    // Clear the checkpoint
    final WeakSubjectivityUpdate update = WeakSubjectivityUpdate.clearWeakSubjectivityCheckpoint();
    database.updateWeakSubjectivityState(update);
    assertThat(database.getWeakSubjectivityState().getCheckpoint()).isEmpty();
}
Also used : WeakSubjectivityUpdate(tech.pegasys.teku.storage.events.WeakSubjectivityUpdate) Checkpoint(tech.pegasys.teku.spec.datastructures.state.Checkpoint) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil) Test(org.junit.jupiter.api.Test)

Example 45 with DataStructureUtil

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

the class SchemaObjectsTestFixture method beaconBlockAltair.

public BeaconBlock beaconBlockAltair() {
    final Spec altairSpec = TestSpecFactory.createMainnetAltair();
    final DataStructureUtil altairData = new DataStructureUtil(altairSpec);
    final SchemaObjectProvider schemaObjectProvider = new SchemaObjectProvider(altairSpec);
    return schemaObjectProvider.getBeaconBlock(altairData.randomBeaconBlock(UInt64.ONE));
}
Also used : Spec(tech.pegasys.teku.spec.Spec) SchemaObjectProvider(tech.pegasys.teku.api.SchemaObjectProvider) DataStructureUtil(tech.pegasys.teku.spec.util.DataStructureUtil)

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