-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Enable buidler evm to support exact timestamp testing #508
Merged
alcuadrado
merged 2 commits into
NomicFoundation:development
from
tranvictor:development
Apr 5, 2020
Merged
Enable buidler evm to support exact timestamp testing #508
alcuadrado
merged 2 commits into
NomicFoundation:development
from
tranvictor:development
Apr 5, 2020
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
1. Allow evm_mine to accept a timestamp param to mine an empty block at the exact timestamp. 2. Add new evm_setNextBlockTimestamp to register a timestamp for the next block to be mined at. 3. Add the doc for evm_setNextBlockTimestamp. 4. Add relevant tests for those changes.
alcuadrado
reviewed
Apr 4, 2020
alcuadrado
reviewed
Apr 4, 2020
alcuadrado
reviewed
Apr 4, 2020
packages/buidler-core/src/internal/buidler-evm/provider/node.ts
Outdated
Show resolved
Hide resolved
alcuadrado
reviewed
Apr 4, 2020
alcuadrado
reviewed
Apr 4, 2020
packages/buidler-core/src/internal/buidler-evm/provider/node.ts
Outdated
Show resolved
Hide resolved
alcuadrado
reviewed
Apr 4, 2020
alcuadrado
reviewed
Apr 4, 2020
alcuadrado
requested changes
Apr 4, 2020
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.
Really good work, Victor! Left a few minor comments.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Changes:
Noted behaviors:
Regarding
evm_setNextBlockTimestamp
, it requires one and only one timestamp param. It set the timestamp as a field named_nextBlockTimestamp
of thenode
, this field is taken and restored as per snapshot operations, just likeblockTimeOffsetInSeconds
. Once the_nextBlockTimestamp
is set, the next block will be mined with the timestamp set to its value, EXCEPT if the next block is mined withevm_mine(timestamp
. Whenever a new block is mined,_nextBlockTimestamp
is reset to 0 as its null state.Usecase:
For smart contracts that have block timestamp logic, it is necessary to test its edge cases where a transaction is mined at an exact timestamp.