Skip to content

Commit

Permalink
complete deneb mischelper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Dec 13, 2024
1 parent 0c6da5a commit e6e7d27
Showing 1 changed file with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,33 @@ public void versionedHash() {
void verifyBlobSidecarCompleteness_shouldThrowWhenSizesDoNotMatch() {
assertThatThrownBy(
() ->
miscHelpersDeneb.verifyBlobSidecarCompleteness(
dataStructureUtil.randomBlobSidecars(1),
dataStructureUtil.randomSignedBeaconBlockWithCommitments(2)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Blob sidecars are not complete");
miscHelpersDeneb.verifyBlobSidecarCompleteness(
dataStructureUtil.randomBlobSidecars(1),
dataStructureUtil.randomSignedBeaconBlockWithCommitments(2)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Blob sidecars are not complete");
}

@Test
void verifyBlobSidecarCompleteness_shouldThrowWhenBlobSidecarIndexIsWrong() {
final List<BlobSidecar> blobSidecars = dataStructureUtil.randomBlobSidecars(1);
assertThatThrownBy(
() ->
miscHelpersDeneb.verifyBlobSidecarCompleteness(
blobSidecars, dataStructureUtil.randomSignedBeaconBlockWithCommitments(1)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Blob sidecar index mismatch, expected 0, got %s", blobSidecars.getFirst().getIndex());
miscHelpersDeneb.verifyBlobSidecarCompleteness(
blobSidecars, dataStructureUtil.randomSignedBeaconBlockWithCommitments(1)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(
"Blob sidecar index mismatch, expected 0, got %s", blobSidecars.getFirst().getIndex());
}

@Test
void verifyBlobSidecarCompleteness_shouldNotThrow() {
final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlockWithCommitments(2);
final List<BlobSidecar> blobSidecars = List.of(dataStructureUtil.randomBlobSidecarForBlock(block, 0), dataStructureUtil.randomBlobSidecarForBlock(block, 1));
assertDoesNotThrow(
() ->
miscHelpersDeneb.verifyBlobSidecarCompleteness(
blobSidecars, block));
final List<BlobSidecar> blobSidecars =
List.of(
dataStructureUtil.randomBlobSidecarForBlock(block, 0),
dataStructureUtil.randomBlobSidecarForBlock(block, 1));
assertDoesNotThrow(() -> miscHelpersDeneb.verifyBlobSidecarCompleteness(blobSidecars, block));
}

@Test
Expand Down Expand Up @@ -183,8 +183,7 @@ void verifyBlobKzgCommitmentInclusionProofShouldValidate() {
.kzgCommitmentInclusionProof(merkleProof)
.build();
assertThat(miscHelpersDeneb.verifyBlobKzgCommitmentInclusionProof(blobSidecar)).isTrue();
assertThat(blobSidecar.isKzgCommitmentInclusionProofValidated()).isTrue();

assertThat(blobSidecar.isKzgCommitmentInclusionProofValidated()).isTrue();

// And the same blobSidecar but with wrong merkle proof
for (int j = 0; j < numberOfCommitments; ++j) {
Expand Down Expand Up @@ -220,24 +219,28 @@ void verifyBlobKzgCommitmentInclusionProofShouldValidate() {
}
}


@Test
void verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock_returnsTrue() {
final SignedBeaconBlock signedBeaconBlock =
dataStructureUtil.randomSignedBeaconBlockWithCommitments(1);
final BlobSidecar blobSidecar =
dataStructureUtil.randomBlobSidecarForBlock(signedBeaconBlock, 0);
assertThat(miscHelpersDeneb.verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock(blobSidecar, signedBeaconBlock)).isTrue();
assertThat(
miscHelpersDeneb.verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock(
blobSidecar, signedBeaconBlock))
.isTrue();
assertThat(blobSidecar.isSignatureValidated()).isTrue();
}

@Test
void verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock_returnsFalse() {
final SignedBeaconBlock signedBeaconBlock =
dataStructureUtil.randomSignedBeaconBlockWithCommitments(1);
final BlobSidecar blobSidecar =
dataStructureUtil.randomBlobSidecar();
assertThat(miscHelpersDeneb.verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock(blobSidecar, signedBeaconBlock)).isFalse();
dataStructureUtil.randomSignedBeaconBlockWithCommitments(1);
final BlobSidecar blobSidecar = dataStructureUtil.randomBlobSidecar();
assertThat(
miscHelpersDeneb.verifyBlobSidecarBlockHeaderSignatureViaValidatedSignedBlock(
blobSidecar, signedBeaconBlock))
.isFalse();
assertThat(blobSidecar.isSignatureValidated()).isFalse();
}
}

0 comments on commit e6e7d27

Please sign in to comment.