diff --git a/runtime/stdlib/test-framework.go b/runtime/stdlib/test-framework.go index 8fc3db0753..e3404f72f5 100644 --- a/runtime/stdlib/test-framework.go +++ b/runtime/stdlib/test-framework.go @@ -75,7 +75,7 @@ type Blockchain interface { Reset(uint64) - MoveTime(int64) + MoveTime(float64) CreateSnapshot(string) error diff --git a/runtime/stdlib/test_emulatorbackend.go b/runtime/stdlib/test_emulatorbackend.go index 1fa3d6eef6..7e31b8dfd3 100644 --- a/runtime/stdlib/test_emulatorbackend.go +++ b/runtime/stdlib/test_emulatorbackend.go @@ -726,7 +726,7 @@ func (t *testEmulatorBackendType) newMoveTimeFunction( if !ok { panic(errors.NewUnreachableError()) } - blockchain.MoveTime(int64(timeDelta.ToInt(invocation.LocationRange))) + blockchain.MoveTime(float64(timeDelta) / sema.Fix64Factor) return interpreter.Void }, ) diff --git a/runtime/stdlib/test_test.go b/runtime/stdlib/test_test.go index c390d0616d..a3892e6e9b 100644 --- a/runtime/stdlib/test_test.go +++ b/runtime/stdlib/test_test.go @@ -2366,7 +2366,7 @@ func TestBlockchain(t *testing.T) { // timeDelta is the representation of 35 days, // in the form of seconds. let timeDelta = Fix64(35 * 24 * 60 * 60) - Test.moveTime(by: timeDelta) + Test.moveTime(by: timeDelta + 0.5) } ` @@ -2375,9 +2375,9 @@ func TestBlockchain(t *testing.T) { testFramework := &mockedTestFramework{ emulatorBackend: func() Blockchain { return &mockedBlockchain{ - moveTime: func(timeDelta int64) { + moveTime: func(timeDelta float64) { moveTimeInvoked = true - assert.Equal(t, int64(3024000), timeDelta) + assert.Equal(t, 3024000.5, timeDelta) }, } }, @@ -2412,9 +2412,9 @@ func TestBlockchain(t *testing.T) { testFramework := &mockedTestFramework{ emulatorBackend: func() Blockchain { return &mockedBlockchain{ - moveTime: func(timeDelta int64) { + moveTime: func(timeDelta float64) { moveTimeInvoked = true - assert.Equal(t, int64(-3024000), timeDelta) + assert.Equal(t, -3024000.0, timeDelta) }, } }, @@ -2446,7 +2446,7 @@ func TestBlockchain(t *testing.T) { testFramework := &mockedTestFramework{ emulatorBackend: func() Blockchain { return &mockedBlockchain{ - moveTime: func(timeDelta int64) { + moveTime: func(timeDelta float64) { moveTimeInvoked = true }, } @@ -2876,7 +2876,7 @@ type mockedBlockchain struct { serviceAccount func() (*Account, error) events func(inter *interpreter.Interpreter, eventType interpreter.StaticType) interpreter.Value reset func(uint64) - moveTime func(int64) + moveTime func(float64) createSnapshot func(string) error loadSnapshot func(string) error } @@ -2989,7 +2989,7 @@ func (m mockedBlockchain) Reset(height uint64) { m.reset(height) } -func (m mockedBlockchain) MoveTime(timeDelta int64) { +func (m mockedBlockchain) MoveTime(timeDelta float64) { if m.moveTime == nil { panic("'SetTimestamp' is not implemented") }