This repository has been archived by the owner on Mar 3, 2021. It is now read-only.
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.
In order to allow for testing of contracts sensitive to timestamps from, for example, the remix-ide recorder, this change allows a timestamp passed to rawRun to override the default behavior when running in a VM.
When a timestamp is passed as part of the arguments to txRunner.rawRun, that timestamp is recorded in the new block and new tx during runInVM. If no timestamp is provided, behavior is unchanged and the timestamp is taken from Date.now().
This will allow us to create test cases for contracts which are sensitive to the relative or absolute timestamp of particular transactions. I'm attaching a .json file from the recorder in remix-ide. Following this change and another in remix-ide, it will record in the contract, the time it was run originally, not the time that the .json was played back.
Some applications of this are a certain behavior that changes after a specific date or a contract that charges time-based interest.