Skip to content

Commit

Permalink
remove AdjustTime hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Oct 30, 2024
1 parent f16b026 commit 3887776
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/chains/evm/logpoller/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ func TestLogPoller_PollAndSaveLogs(t *testing.T) {

b, err = th.Client.BlockByNumber(testutils.Context(t), nil)
require.NoError(t, err)
require.Equal(t, blockTimestamp+uint64(time.Hour)+1, b.Time())
require.Equal(t, blockTimestamp+uint64(time.Hour/time.Second)+1, b.Time())
})
}
}
Expand Down
6 changes: 1 addition & 5 deletions core/services/vrf/v2/integration_v2_plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ func newVRFCoordinatorV2PlusUniverse(t *testing.T, key ethkey.KeyV2, numConsumer
require.NoError(t, err)
blockTime := time.Unix(int64(h.Time), 0)
// Move the clock closer to the current time. We set first block to be 24 hours ago.
adjust := time.Since(blockTime) - 24*time.Hour
// hack to convert nanos durations to seconds until geth patches incorrect conversion
// remove after fix is merged: https://github.com/ethereum/go-ethereum/pull/30138
adjust = adjust / 1e9
err = backend.AdjustTime(adjust)
err = backend.AdjustTime(time.Since(blockTime) - 24*time.Hour)
require.NoError(t, err)
backend.Commit()

Expand Down
6 changes: 1 addition & 5 deletions core/services/vrf/v2/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ func newVRFCoordinatorV2Universe(t *testing.T, key ethkey.KeyV2, numConsumers in
require.NoError(t, err)
blockTime := time.Unix(int64(h.Time), 0)
// Move the clock closer to the current time. We set first block to be 24 hours ago.
adjust := time.Since(blockTime) - 24*time.Hour
// hack to convert nanos durations to seconds until geth patches incorrect conversion
// remove after fix is merged: https://github.com/ethereum/go-ethereum/pull/30138
adjust = adjust / 1e9
err = backend.AdjustTime(adjust)
err = backend.AdjustTime(time.Since(blockTime) - 24*time.Hour)
require.NoError(t, err)
backend.Commit()

Expand Down
6 changes: 1 addition & 5 deletions core/services/vrf/v2/listener_v2_log_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ func setupVRFLogPollerListenerTH(t *testing.T) *vrfLogPollerListenerTH {
blockTime := time.Unix(int64(h.Time), 0)
// VRF Listener relies on block timestamps, but SimulatedBackend uses by default clock starting from 1970-01-01
// This trick is used to move the clock closer to the current time. We set first block to be 24 hours ago.
adjust := time.Since(blockTime) - 24*time.Hour
// hack to convert nanos durations to seconds until geth patches incorrect conversion
// remove after fix is merged: https://github.com/ethereum/go-ethereum/pull/30138
adjust = adjust / 1e9
err = backend.AdjustTime(adjust)
err = backend.AdjustTime(time.Since(blockTime) - 24*time.Hour)
require.NoError(t, err)
backend.Commit()

Expand Down

0 comments on commit 3887776

Please sign in to comment.