Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
# Test cases for blob_to_kzg_commitment
###############################################################################

from eth_utils import encode_hex

from eth2spec.test.context import only_generator, single_phase, spec_test, with_phases
from eth2spec.test.helpers.constants import DENEB
from eth2spec.test.utils.kzg_tests import (
INVALID_BLOBS,
VALID_BLOBS,
)
from tests.infra.manifest import manifest
from tests.infra.template_test import template_test


@template_test
def _blob_to_kzg_commitment_case_valid_blob(index):
blob = VALID_BLOBS[index]

@manifest(preset_name="general", suite_name="kzg-mainnet")
@only_generator("too slow")
@with_phases([DENEB])
@spec_test
@single_phase
def the_test(spec):
commitment = spec.blob_to_kzg_commitment(blob)

yield (
"data",
"data",
{
"input": {"blob": encode_hex(blob)},
"output": encode_hex(commitment),
},
)

return (the_test, f"test_blob_to_kzg_commitment_case_valid_blob_{index}")


for index in range(0, len(VALID_BLOBS)):
_blob_to_kzg_commitment_case_valid_blob(index)


@template_test
def _blob_to_kzg_commitment_case_invalid_blob(index):
blob = INVALID_BLOBS[index]

@manifest(preset_name="general", suite_name="kzg-mainnet")
@only_generator("too slow")
@with_phases([DENEB])
@spec_test
@single_phase
def the_test(spec):
commitment = None
try:
commitment = spec.blob_to_kzg_commitment(blob)
except Exception:
pass

# exception is thrown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the useless comment.

This comment was marked as spam.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not useless, it is a justtification to assert False

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean to assert commitment is None

assert commitment is None

yield (
"data",
"data",
{
"input": {"blob": encode_hex(blob)},
"output": None,
},
)

return (the_test, f"test_blob_to_kzg_commitment_case_invalid_blob_{index}")


for index in range(0, len(INVALID_BLOBS)):
_blob_to_kzg_commitment_case_invalid_blob(index)
2 changes: 1 addition & 1 deletion tests/core/pyspec/eth2spec/test/utils/kzg_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int_to_big_endian,
)

from eth2spec.fulu import spec
from eth2spec.fulu import mainnet as spec
from eth2spec.utils import bls

###############################################################################
Expand Down
Loading