use of tech.pegasys.teku.infrastructure.bytes.Bytes8 in project teku by ConsenSys.
the class Web3JExecutionEngineClientTest method shouldDeserializeBytes8.
@TestTemplate
void shouldDeserializeBytes8() throws IOException {
Bytes8 originalBytes8 = dataStructureUtil.randomBytes8();
JsonParser parser = prepareDeserializationContext("\"" + originalBytes8.toHexString() + "\"");
Bytes8Deserializer deserializer = new Bytes8Deserializer();
Bytes8 result = deserializer.deserialize(parser, objectMapper.getDeserializationContext());
assertThat(originalBytes8).isEqualTo(result);
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes8 in project teku by ConsenSys.
the class ForkChoiceNotifierTest method getPayloadId_shouldObtainAPayloadIdWhenProposingTheMergeBlock.
@Test
void getPayloadId_shouldObtainAPayloadIdWhenProposingTheMergeBlock() {
reInitializePreMerge();
Bytes32 terminalBlockHash = dataStructureUtil.randomBytes32();
final Bytes8 payloadId = dataStructureUtil.randomBytes8();
final BeaconState headState = getHeadState();
final UInt64 blockSlot = headState.getSlot().plus(1);
final Bytes32 blockRoot = recentChainData.getBestBlockRoot().orElseThrow();
// we expect head block root and slot to be ZERO since in the test we do not send an
// onForkChoiceUpdated before calling onTerminalBlock, so it will initialize ZEROED
final ForkChoiceState forkChoiceState = new ForkChoiceState(Bytes32.ZERO, UInt64.ZERO, terminalBlockHash, terminalBlockHash, Bytes32.ZERO, false);
final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot);
notifier.onTerminalBlockReached(terminalBlockHash);
validateGetPayloadIdOnTheFlyRetrieval(blockSlot, blockRoot, forkChoiceState, payloadId, payloadAttributes, false);
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes8 in project teku by ConsenSys.
the class ForkChoiceNotifierTest method getPayloadId_shouldReturnExceptionallyLatestPayloadIdOnWrongRoot.
@Test
void getPayloadId_shouldReturnExceptionallyLatestPayloadIdOnWrongRoot() {
final Bytes8 payloadId = dataStructureUtil.randomBytes8();
final ForkChoiceState forkChoiceState = getCurrentForkChoiceState();
final BeaconState headState = getHeadState();
final UInt64 blockSlot = headState.getSlot().plus(1);
final Bytes32 wrongBlockRoot = dataStructureUtil.randomBytes32();
final PayloadAttributes payloadAttributes = withProposerForSlot(headState, blockSlot);
final SafeFuture<ForkChoiceUpdatedResult> responseFuture = new SafeFuture<>();
when(executionEngineChannel.forkChoiceUpdated(forkChoiceState, Optional.of(payloadAttributes))).thenReturn(responseFuture);
assertThat(notifier.onForkChoiceUpdated(forkChoiceState)).isCompleted();
responseFuture.complete(createForkChoiceUpdatedResult(ExecutionPayloadStatus.VALID, Optional.of(payloadId)));
assertThatSafeFuture(notifier.getPayloadId(wrongBlockRoot, blockSlot)).isCompletedExceptionally();
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes8 in project teku by ConsenSys.
the class ForkChoiceNotifierTest method getPayloadId_shouldObtainAPayloadIdOnPostMergeBlockFinalizedEvenIfProposerNotPrepared.
@Test
void getPayloadId_shouldObtainAPayloadIdOnPostMergeBlockFinalizedEvenIfProposerNotPrepared() {
final Bytes8 payloadId = dataStructureUtil.randomBytes8();
// current slot: 1
// send post-merge onForkChoiceUpdated (with finalized block state)
ForkChoiceState finalizedForkChoiceState = getCurrentForkChoiceState();
assertThat(finalizedForkChoiceState.getFinalizedExecutionBlockHash()).isNotEqualTo(Bytes32.ZERO);
assertThat(notifier.onForkChoiceUpdated(finalizedForkChoiceState)).isCompleted();
verify(executionEngineChannel).forkChoiceUpdated(finalizedForkChoiceState, Optional.empty());
final BeaconState headState = getHeadState();
// proposing slot 3
final UInt64 blockSlot = headState.getSlot().plus(2);
final Bytes32 blockRoot = recentChainData.getBestBlockRoot().orElseThrow();
final PayloadAttributes payloadAttributes = withProposerForSlotButDoNotPrepare(headState, blockSlot, defaultFeeRecipient);
validateGetPayloadIdOnTheFlyRetrieval(blockSlot, blockRoot, finalizedForkChoiceState, payloadId, payloadAttributes, false);
}
use of tech.pegasys.teku.infrastructure.bytes.Bytes8 in project teku by ConsenSys.
the class ForkChoiceNotifierTest method getPayloadId_shouldFailIfDefaultFeeRecipientIsNotConfigured.
@Test
void getPayloadId_shouldFailIfDefaultFeeRecipientIsNotConfigured() {
setUp(true);
final Bytes8 payloadId = dataStructureUtil.randomBytes8();
// current slot: 1
// send post-merge onForkChoiceUpdated (with finalized block state)
ForkChoiceState finalizedForkChoiceState = getCurrentForkChoiceState();
assertThat(finalizedForkChoiceState.getFinalizedExecutionBlockHash()).isNotEqualTo(Bytes32.ZERO);
assertThat(notifier.onForkChoiceUpdated(finalizedForkChoiceState)).isCompleted();
verify(executionEngineChannel).forkChoiceUpdated(finalizedForkChoiceState, Optional.empty());
final BeaconState headState = getHeadState();
// proposing slot 3
final UInt64 blockSlot = headState.getSlot().plus(2);
final Bytes32 blockRoot = recentChainData.getBestBlockRoot().orElseThrow();
final PayloadAttributes payloadAttributes = withProposerForSlotButDoNotPrepare(headState, blockSlot, Optional.empty());
validateGetPayloadIdOnTheFlyRetrieval(blockSlot, blockRoot, finalizedForkChoiceState, payloadId, payloadAttributes, true);
}
Aggregations