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; } }