-
Notifications
You must be signed in to change notification settings - Fork 153
feat(tests): Additional EIP-7934 test cases #1890
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
base: main
Are you sure you want to change the base?
Conversation
6335dc3
to
cd39587
Compare
cd39587
to
a2146f9
Compare
- Create global fixtures for default transactions that are covariant with ``fork`` - These should allow overriding particular default transactions by re-defining the fixture for the particular tx type e.g.: ```python @pytest.fixture def type_2_default_transaction(pre): return Transaction(...) ``` - Use these as part of the ``fork`` plugin
a2146f9
to
eab5984
Compare
Hmm having a difficult time reproducing this CI error locally. I added the concept of a @pytest.fixture
def type_2_default_transaction(sender):
return Transaction(...) Something in the |
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.
Awesome! Thanks for implementing this.
I wrote a couple of comments that might be worth considering.
@pytest.fixture | ||
def typed_transaction(request, fork): |
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 think we could create ./tests/conftest.py
and move all of these fixtures there with some minor changes to not require a change in the plugins:
@pytest.fixture | |
def typed_transaction(request, fork): | |
@pytest.fixture | |
def typed_transaction(tx_type: int, fork: Fork) -> Transaction: |
Then the test adds typed_transaction: Transaction
as a parameter, but it might have the downside that the test has to also include the tx_type: int
parameter to simply not use it, and maybe some other downside I could be missing.
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.
Ok yeah, this was the route I was originally going to take but wasn't sure why a global conftest.py
didn't exist yet and thought it may not be desirable. I think if you're good with that I am good with it as well 👍🏼
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 might have the downside that the test has to also include the
tx_type: int
parameter to simply not use it
I implemented it so that the typed_transaction
fixture uses the tx_type
and so all you have to do is use the @pytest.mark.with_all_tx_types
and you can use the typed_transaction
directly. If it's better to keep this as a separate marker, just let me know, but I think if we document it well enough that you can use either the tx_type
or the typed_transaction
then it's fairly frictionless and versatile.
lmk what you think about that or if the separation of concerns is better.
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.
Ok. So based on @danceratopz comments, I moved it back to the plugins. But based on your request @marioevz, I put this inside shared
and available to shared/execute_fill.py
plugin. I refactored the logic for the indirect
covariant checks so it could be used by other markers in the future if needed. The CovariantDecorator
takes an indirect
kwarg that will run the values of the fork_attribute_name
in this case through the fixtures (argnames
) which is then what is used in the test.
I ended up creating a more global sender
and I did so inside execute_fill.py
but perhaps this can live somewhere else or this may not be ideal, so let me know there. But we can remove the redundant re-definitions of sender
fixture that don't need some special type of logic if we have this more global one set here.
Would love thoughts on this from you both.
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.
Global sender
allows us to remove quite a few redundancies in tests/
fixtures, as per the last commit in this PR.
- Move default transaction logic to a ``conftest.py`` setup. - Add ``conftest.py`` files for each fork with the respective transaction pytest fixtures. - Opt for `Type | None` over `Optional[Type]` to avoid an extra import.
- Move default transaction logic to a ``conftest.py`` setup. - Add ``conftest.py`` files for each fork with the respective transaction pytest fixtures. - Opt for `Type | None` over `Optional[Type]` to avoid an extra import.
8451823
to
d26c90b
Compare
I'm just missing the documentation here which I can update but we should get consensus on the code first and then I can document the changes appropriately and add the release notes. |
- Move default transaction logic to a ``conftest.py`` setup. - Add ``conftest.py`` files for each fork with the respective transaction pytest fixtures. - Opt for `Type | None` over `Optional[Type]` to avoid an extra import.
d26c90b
to
39d2880
Compare
- Move transaction fixtures to a `shared` pytest plugin. - Opt for `Type | None` over `Optional[Type]` to avoid an extra import. Bonus: - Refactor the `indirect` marker logic to be more generic for future use. If a marker uses `indirect`, it will take the values from the `fork_attribute_name` and run it through a fixture of name `argnames` which provides some added logic. In this case it builds default transactions from the `tx_types` values for each fork.
39d2880
to
d03452a
Compare
3fc79fd
to
619bbaa
Compare
🗒️ Description
🔗 Related Issues or PRs
Related to #1772
TODO:
with_all_tx_types
into something that can be more useful across the board. I'm thinking default transactions that each fork can define if it includes a new tx type and tests can automatically use these transactions, override them as fixtures, or some other more useful flow than re-building every time.with_all_typed_transactions
indirect (new feature) marker✅ Checklist
tox
checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
type(scope):
.mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.