Skip to content

Commit

Permalink
changes as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 22, 2023
1 parent e0c5d28 commit 4856090
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ protected void prepareDefaultPayload(final Spec spec) {
.getHeaderOfDefaultPayload();
}

protected BlobsBundle prepareBlobsBundle(final Spec spec) {
protected BlobsBundle prepareBlobsBundle(final Spec spec, final int count) {
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle();
final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle(count);
this.blobsBundle = blobsBundle;
return blobsBundle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.util.stream.Collectors;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlindedBlobSidecar;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsBundle;
import tech.pegasys.teku.spec.datastructures.blocks.BlindedBlockContainer;
import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer;
Expand All @@ -34,21 +38,25 @@ public class BlockFactoryDenebTest extends AbstractBlockFactoryTest {
void shouldCreateBlockContentsWhenDenebIsActive() {

prepareDefaultPayload(spec);
final BlobsBundle blobsBundle = prepareBlobsBundle(spec);
final BlobsBundle blobsBundle = prepareBlobsBundle(spec, 3);

final BlockContainer blockContainer = assertBlockCreated(1, spec, false, false);

assertThat(blockContainer).isInstanceOf(BlockContents.class);
assertThat(blockContainer.getBlobSidecars())
.hasValueSatisfying(
blobSidecars -> assertThat(blobSidecars).hasSize(blobsBundle.getNumberOfBlobs()));
blobSidecars ->
assertThat(blobSidecars)
.hasSize(3)
.map(BlobSidecar::getBlob)
.hasSameElementsAs(blobsBundle.getBlobs()));
}

@Test
void shouldCreateBlindedBlockContentsWhenDenebIsActiveAndBlindedBlockRequested() {

prepareDefaultPayload(spec);
final BlobsBundle blobsBundle = prepareBlobsBundle(spec);
final BlobsBundle blobsBundle = prepareBlobsBundle(spec, 3);

final BlockContainer blockContainer = assertBlockCreated(1, spec, false, true);

Expand All @@ -57,7 +65,13 @@ void shouldCreateBlindedBlockContentsWhenDenebIsActiveAndBlindedBlockRequested()
assertThat(blindedBlockContainer.getBlindedBlobSidecars())
.hasValueSatisfying(
blindedBlobSidecars ->
assertThat(blindedBlobSidecars).hasSize(blobsBundle.getNumberOfBlobs()));
assertThat(blindedBlobSidecars)
.hasSize(3)
.map(BlindedBlobSidecar::getBlobRoot)
.hasSameElementsAs(
blobsBundle.getBlobs().stream()
.map(Blob::hashTreeRoot)
.collect(Collectors.toList())));
}

@Override
Expand Down

0 comments on commit 4856090

Please sign in to comment.