-
Notifications
You must be signed in to change notification settings - Fork 72
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,tests): Add pre.deploy_contract
, pre.fund_eoa
methods to write tests
#584
Conversation
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'm really loving this and where it's heading.
Regarding the comments below, got a feeling I might have missed the mark about Sender
semantics below?
Would def like to spend more time with this code.
Co-authored-by: danceratopz <danceratopz@gmail.com>
Co-authored-by: danceratopz <danceratopz@gmail.com>
pre.deploy_contract
, pre.fund_sender
methods to write testspre.deploy_contract
, pre.fund_eoa
methods to write tests
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.
Extra comments after updating Shanghai tests respectively.
tests/prague/eip2935_historical_block_hashes_from_state/test_block_hashes.py
Show resolved
Hide resolved
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.
LGTM!
🗒️ Description
This PR adds three methods to the
Alloc
class that allow more versatility and control over the produced tests, by allowing the tests to be written in a way that the required test contracts deploy address is not known ahead of time.This is done by creating a
pre
fixture in the test filler that is added to each test during the fill process.The test needs to add it as a parameter in the following way:
During the test filling process, a new
Alloc
object is created and passed to the test.Then, to "request" a contract to be placed in the pre-state, the test needs to call
pre.deploy_contract
function:And the result of the call is the address of deployment.
Similarly, the test does not assume that the transactions are all sent from the same
TestAddress
and instead requests for a newEOA
:The returned object contains the private key of a funded account, with the requested funding.
Also, when defining the transaction(s) to be sent during the test, the test does no longer need to specify the nonce, since the sender object contains the starting nonce, and the value is automatically increased when the sender is used as a parameter to create a tx:
Currently
deploy_contract
accepts bothnonce
andaddress
parameters, just for the purpose of verifiying that the updated tests have a 1-to-1 fixture outputs. The merged tests though should not use these parameters.A new parameter
--strict-alloc-mode
is introduced in thefill
parameter that, when enabled, if a test uses either of these parameters, the test filling procedure fails.This PR updates all tests in the following folders:
And up to commit 2aad395 the fixtures produce an exact fixture output as the
main
branch, but theaddress
andnonce
workarounds are removed in commit b267d16 and can be filled using the--strict-alloc-mode
parameter.🔗 Related Issues
None
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.