-
Notifications
You must be signed in to change notification settings - Fork 111
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
block header validation in context of blockchain test #1230
base: main
Are you sure you want to change the base?
Conversation
But in any code if we don't provide fork value to FixtureHeader before pydantic validation, it will not validate the corectness of the fields. there is one approach is the we derive fork field when validating FixtureHeader by looking at what fields are there. |
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.
Looks good overall, just a minor suggestion to make this more future-proof. Thanks!
from ethereum_test_forks import ( | ||
Cancun, | ||
Constantinople, | ||
Fork, | ||
Frontier, | ||
Homestead, | ||
Istanbul, | ||
Paris, | ||
Prague, | ||
) |
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.
We could use get_forks
to make the fork resolution by name more dynamic.
from ethereum_test_forks import ( | |
Cancun, | |
Constantinople, | |
Fork, | |
Frontier, | |
Homestead, | |
Istanbul, | |
Paris, | |
Prague, | |
) | |
from ethereum_test_forks import Fork, Paris, get_forks |
And then simply define something like:
all_forks_by_name = {fork.name(): fork for fork in get_forks()}
if network == "Frontier": | ||
header["fork"] = Frontier | ||
elif network == "Homestead": | ||
header["fork"] = Homestead | ||
elif network == "Constantinople": | ||
header["fork"] = Constantinople | ||
elif network == "Istanbul": | ||
header["fork"] = Istanbul | ||
elif network == "Paris": | ||
header["fork"] = Paris | ||
elif network == "Cancun": | ||
header["fork"] = Cancun | ||
elif network == "Prague": | ||
header["fork"] = Prague |
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.
if network == "Frontier": | |
header["fork"] = Frontier | |
elif network == "Homestead": | |
header["fork"] = Homestead | |
elif network == "Constantinople": | |
header["fork"] = Constantinople | |
elif network == "Istanbul": | |
header["fork"] = Istanbul | |
elif network == "Paris": | |
header["fork"] = Paris | |
elif network == "Cancun": | |
header["fork"] = Cancun | |
elif network == "Prague": | |
header["fork"] = Prague | |
if network in all_forks_by_name: | |
header["fork"] = all_forks_by_name[network] |
Follow up to the previous comment.
🗒️ Description
this is a unit test setup for blockheader schema validation in context of blockchain tests
it sets up a fork for validation of blockheader model.
and a unit test that will check missing or extra fields errors
🔗 Related Issues
#940
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.