Skip to content

Commit

Permalink
update BlockBlobSidecarsTrackerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Dec 9, 2024
1 parent 164982e commit f494afe
Showing 1 changed file with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -346,6 +367,8 @@ void getMissingBlobSidecars_shouldRespectMaxBlobsPerBlock() {
.index(UInt64.valueOf(100))
.build();

toAdd.markKzgAndInclusionProofAsValidated();

blockBlobSidecarsTracker.add(toAdd);

final List<BlobIdentifier> knownMissing =
Expand Down Expand Up @@ -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;
}
}

0 comments on commit f494afe

Please sign in to comment.