From f494afe2e9acdf8c1aab6fe5d21ae97bf3dba072 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Fri, 22 Nov 2024 12:22:13 +0100 Subject: [PATCH] update BlockBlobSidecarsTrackerTest --- .../blobs/BlockBlobSidecarsTrackerTest.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/blobs/BlockBlobSidecarsTrackerTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/blobs/BlockBlobSidecarsTrackerTest.java index d5d702acbc9..791d6201f30 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/blobs/BlockBlobSidecarsTrackerTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/blobs/BlockBlobSidecarsTrackerTest.java @@ -29,6 +29,7 @@ import java.util.Set; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.SafeFutureAssert; @@ -62,6 +63,11 @@ public class BlockBlobSidecarsTrackerTest { blobSidecar -> new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex())) .collect(Collectors.toList()); + @BeforeEach + void setUp() { + blobSidecarsForBlock.forEach(BlobSidecar::markKzgAndInclusionProofAsValidated); + } + @Test void isNotCompletedJustAfterCreation() { final BlockBlobSidecarsTracker blockBlobSidecarsTracker = @@ -165,6 +171,21 @@ void getCompletionFuture_returnsIndependentFutures() { SafeFutureAssert.assertThatSafeFuture(completionFuture3).isCompleted(); } + @Test + void add_shouldFailIfBlobsIsNotMarkedAsKzgAndInclusionProofValidated() { + final BlockBlobSidecarsTracker blockBlobSidecarsTracker = + new BlockBlobSidecarsTracker(slotAndBlockRoot, maxBlobsPerBlock); + final BlobSidecar toAdd = + dataStructureUtil + .createRandomBlobSidecarBuilder() + .signedBeaconBlockHeader(block.asHeader()) + .build(); + + assertThatThrownBy(() -> blockBlobSidecarsTracker.add(toAdd)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("BlobSidecar must be validated before adding"); + } + @Test void add_shouldWorkTillCompletionWhenAddingBlobsBeforeBlockIsSet() { final BlockBlobSidecarsTracker blockBlobSidecarsTracker = @@ -346,6 +367,8 @@ void getMissingBlobSidecars_shouldRespectMaxBlobsPerBlock() { .index(UInt64.valueOf(100)) .build(); + toAdd.markKzgAndInclusionProofAsValidated(); + blockBlobSidecarsTracker.add(toAdd); final List knownMissing = @@ -422,10 +445,13 @@ void enableBlockImportOnCompletion_shouldImportOnlyOnceWhenCalled() { } private BlobSidecar createBlobSidecar(final UInt64 index) { - return dataStructureUtil - .createRandomBlobSidecarBuilder() - .signedBeaconBlockHeader(block.asHeader()) - .index(index) - .build(); + final BlobSidecar blobSidecar = + dataStructureUtil + .createRandomBlobSidecarBuilder() + .signedBeaconBlockHeader(block.asHeader()) + .index(index) + .build(); + blobSidecar.markKzgAndInclusionProofAsValidated(); + return blobSidecar; } }