Skip to content

Commit

Permalink
add execution layer manager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Oct 1, 2024
1 parent ca20c14 commit 1bc04e7
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.builder.BuilderBid;
import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBid;
import tech.pegasys.teku.spec.datastructures.execution.BlobAndProof;
import tech.pegasys.teku.spec.datastructures.execution.BlobsBundle;
import tech.pegasys.teku.spec.datastructures.execution.BuilderBidOrFallbackData;
import tech.pegasys.teku.spec.datastructures.execution.BuilderPayloadOrFallbackData;
Expand All @@ -58,6 +60,7 @@
import tech.pegasys.teku.spec.datastructures.execution.FallbackReason;
import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.logic.versions.deneb.types.VersionedHash;
import tech.pegasys.teku.spec.util.DataStructureUtil;

class ExecutionLayerManagerImplTest {
Expand Down Expand Up @@ -656,6 +659,18 @@ void onSlot_shouldCleanUpFallbackCache() {
verifyNoMoreInteractions(executionClientHandler);
}

@Test
public void engineGetBlobs_shouldReturnGetBlobsResponseViaEngine() {
setupDeneb();
final List<VersionedHash> versionedHashes =
dataStructureUtil.randomVersionedHashes(spec.getMaxBlobsPerBlock().orElseThrow());
final UInt64 slot = dataStructureUtil.randomSlot();
final List<BlobAndProof> getBlobsResponse =
prepareEngineGetBlobsResponse(versionedHashes, slot);
assertThat(executionLayerManager.engineGetBlobs(versionedHashes, slot))
.isCompletedWithValue(getBlobsResponse.stream().map(Optional::ofNullable).toList());
}

private void setupDeneb() {
spec = TestSpecFactory.createMinimalDeneb();
dataStructureUtil = new DataStructureUtil(spec);
Expand Down Expand Up @@ -786,6 +801,19 @@ private GetPayloadResponse prepareEngineGetPayloadResponseWithBlobs(
return getPayloadResponse;
}

private List<BlobAndProof> prepareEngineGetBlobsResponse(
final List<VersionedHash> blobVersionedHashes, final UInt64 slot) {
final List<BlobSidecar> blobSidecars =
dataStructureUtil.randomBlobSidecars(spec.getMaxBlobsPerBlock().orElseThrow());
final List<BlobAndProof> getBlobsResponse =
blobSidecars.stream()
.map(blobSidecar -> new BlobAndProof(blobSidecar.getBlob(), blobSidecar.getKZGProof()))
.toList();
when(executionClientHandler.engineGetBlobs(blobVersionedHashes, slot))
.thenReturn(SafeFuture.completedFuture(getBlobsResponse));
return getBlobsResponse;
}

private ExecutionLayerManagerImpl createExecutionLayerChannelImpl(
final boolean builderEnabled, final boolean builderValidatorEnabled) {
return createExecutionLayerChannelImpl(
Expand Down

0 comments on commit 1bc04e7

Please sign in to comment.