-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Test] Unable to use Test.moveTime
#264
Comments
Did some further debugging. Seems like this actually works when you grab time directly from the Blockchain itself, you cannot use the testing framework's time. So anyone who uses It seems like the use of log threw some of this off when running directly in the vscode extension, once I removed all logs, things passed as expected so long as I only grabbed timestamps using a script of some kind |
Final piece I've found is that
Logs out:
|
Test.moveTime
Thanks for the report @austinkline 🙇 , You are in fact correct in both of your findings. access(all) contract TimeLocker {
access(all) let lockPeriod: UFix64
access(all) let lockedAt: UFix64
init(lockedAt: UFix64) {
self.lockedAt = lockedAt
// Lock period is 30 days, in the form of seconds.
self.lockPeriod = UFix64(30 * 24 * 60 * 60)
}
access(all)
fun isOpen(): Bool {
let currentTime = getCurrentBlock().timestamp
return currentTime > (self.lockedAt + self.lockPeriod)
}
} In the above sample contract, The reason for accepting I hope this clarifies things better 🙏 EDIT: We cannot have granularity smaller than seconds, neither in testnet/mainnet. |
The clock should probably be changed to support sub-second granularity. |
Current Behavior
Using
Test.moveTime
doesn't seem to impact the timestamp of a blockExpected Behavior
Test.moveTime should result in
getCurrentBlock().timestamp
changingSteps To Reproduce
Also fails if you use scripts to obtain the time instead of using the testing framework directly:
Script:
Environment
The text was updated successfully, but these errors were encountered: