feat(tests): add test "framework" for BN254 precompiles#1871
feat(tests): add test "framework" for BN254 precompiles#1871danceratopz merged 3 commits intoethereum:forks/amsterdamfrom
Conversation
|
I mostly copied the conftest.py from BLS precompiles tests. This works nicely here too because it uses features from Byzantium. So you may want to extract this as a tool for any other precompile testing. However, it will not work for eariler precompiles without modifications. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #1871 +/- ##
===================================================
+ Coverage 86.15% 86.26% +0.10%
===================================================
Files 538 538
Lines 34557 34557
Branches 3222 3222
===================================================
+ Hits 29773 29809 +36
+ Misses 4177 4161 -16
+ Partials 607 587 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* type(tests): convert create suicide during init * Fixes, increase coverage * fix: Coverage script * Add coveraged missed reason --------- Co-authored-by: Mario Vega <marioevz@gmail.com>
danceratopz
left a comment
There was a problem hiding this comment.
Thanks @chfast, very nice!
Re-using the existing BLS pytest fixtures is a good idea. I think we should move these to a central place now in the scope of this PR.
I see two options:
- Add them to a new module
tests/common/precompile_fixtures.pyand import them as required from there - this enables explicit local use of these fixtures and avoids defining them globally for all tests. - Add them to a new
fillplugin that is loaded by default (via fill's pytest ini file) and globally scoped.
Although it's a new pattern, I prefer 1. to avoid polluting the test session with fixtures that intended to have a limited scope. Having these fixtures available globally increases the risk of error in unrelated tests that use fixtures that (accidentally) have the same names (the implementer could forget to shadow one or more of the fixtures, leading to unexpected behavior). We could consider using more ambiguous naming, but that's no absolute guarantee that they won't get used by mistake.
If you're happy with 1. Please add it to this PR and state briefly in the new module which type of precompiles could make use of it and why earlier precompiles can't use it. Thanks!
tests/common/precompile_fixtures.py
Outdated
| @@ -0,0 +1,198 @@ | |||
| """pytest fixtures for tests executing precompiled contracts.""" | |||
There was a problem hiding this comment.
Could you please improve the docstring here?
state briefly in the new module which type of precompiles could make use of it and why earlier precompiles can't use it. Thanks!
🗒️ Description
Add test "framework" for BN254 precompiles: spec.py with some constants and conftest.py with generic fixtures.
🔗 Related Issues or PRs
#1860
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture
🐛