Skip to content
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
merged 2 commits into from
Apr 5, 2020

Conversation

tranvictor
Copy link
Contributor

Changes:

  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.

Noted behaviors:
Regarding evm_setNextBlockTimestamp, it requires one and only one timestamp param. It set the timestamp as a field named _nextBlockTimestamp of the node, this field is taken and restored as per snapshot operations, just like blockTimeOffsetInSeconds. 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 with evm_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.

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.
Copy link
Member

@alcuadrado alcuadrado left a 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.

@alcuadrado alcuadrado merged commit f7b06de into NomicFoundation:development Apr 5, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants