-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Port blob_to_kzg_commitment tests to pytest
#4541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jtraglia
merged 9 commits into
ethereum:master
from
leolara:leolara/several-refactoring-testing
Sep 19, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6430930
Several refactorings to testing
leolara c4d7888
Merge important fix to legacy tests
jtraglia 1bc62a4
Fix vectors directories
leolara c600e07
Only generator enabled in KZG tests
leolara 58e4af3
lint
leolara 5ca697f
Apply suggestion from @jtraglia
leolara 53b3d50
lint
leolara 5843208
Remove caching
leolara 56d6120
Remove comment
leolara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
77 changes: 77 additions & 0 deletions
77
tests/core/pyspec/eth2spec/test/deneb/kzg/test_blob_to_kzg_commitment.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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