Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Allow timestamps to be passed to rawRun #1120

Merged
merged 4 commits into from
Feb 11, 2019
Merged

Conversation

LeviBarnes
Copy link
Contributor

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.

This is useful when, for example, running a recorded .json
file for cases that rely on a specific time between transactions.

If no timestamp is passed as part of the tx argument to
runRaw, behavior does not change.
@LeviBarnes
Copy link
Contributor Author

Bump.
I would love to read your comments or concerns about this change.

@yann300 yann300 merged commit db77e93 into ethereum:master Feb 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants