-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat(fw): add pydantic models for json fixture files #501
Merged
Conversation
This file contains 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
This required: 1. Changing the from_pipe_str() BeforeValidator method to convert the serialized exception string back to an Exception enum instance (or list). 2. Modifying the annotated types to also accept single TransactionException or BlockchainException types so that they are also correctly coerced via from_pipe_str().
This fixes src/ethereum_test_tools/tests/test_types.py::TestPydanticModelConversion::test_json_serialization[transaction_t8n_to_none]. An additional class TransactionTransitionToolConverter now specifies how an evm transition tool should validate and serialize the to field. Whilst this didn't break test generation, it caused deserialization to fail on individual Transaction models.
The incorrect field name was specified. This only became apparent when deserializing fixtures, as the info field is not present when the hash gets generated after filling. Patches up existing tests and also adds a dedicated test for this: src/ethereum_test_tools/tests/test_spec_base.py::test_json_dict
danceratopz
added
type:feat
type: Feature
scope:fw
Scope: Framework (evm|tools|forks|pytest)
labels
Apr 11, 2024
marioevz
approved these changes
Apr 12, 2024
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 great, thanks!
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🗒️ Description
This PR fixes a couple of issues when deserializing json fixtures (loading them into a pydantic model) and adds new models for interacting with json fixture files. It also adds a script that can be used to verify the framework's serialization/deserialization of json fixtures files on disk using their hashes.
Adds rich as a dependency. To add rich, install the new script entry point, execute:
🔗 Related Issues
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.