@@ -243,4 +243,38 @@ func TestRPCAPI(t *testing.T) {
243243 require .GreaterOrEqual (t , int64 (block .Transactions ().Len ()), txnInBlock )
244244 }
245245 })
246+
247+ t .Run ("(anvil) evm_increaseTime advances timestamp" , func (t * testing.T ) {
248+ ac , err := StartAnvil ([]string {"--no-mine" })
249+ require .NoError (t , err )
250+ client , err := ethclient .Dial (ac .URL )
251+ require .NoError (t , err )
252+
253+ anvil := New (ac .URL , nil )
254+
255+ // Mine an initial block to establish a baseline timestamp
256+ require .NoError (t , anvil .AnvilMine ([]interface {}{1 }))
257+
258+ // Read latest header/time
259+ h1 , err := client .HeaderByNumber (context .Background (), nil )
260+ require .NoError (t , err )
261+ t1 := h1 .Time // uint64 (seconds)
262+
263+ // Jump forward in time, then mine exactly one block so the new timestamp is materialized
264+ advance := uint64 (60 ) // 1 minute
265+ require .NoError (t , anvil .EVMIncreaseTime (advance ))
266+ require .NoError (t , anvil .AnvilMine ([]interface {}{1 }))
267+
268+ // Read new header/time
269+ h2 , err := client .HeaderByNumber (context .Background (), nil )
270+ require .NoError (t , err )
271+ t2 := h2 .Time
272+
273+ // Assert the delta is at least the requested advance
274+ // (Anvil should add exactly `advance`, but we allow >= to be safe.)
275+ require .GreaterOrEqual (t , t2 - t1 , advance , "timestamp did not advance by expected seconds" )
276+
277+ t .Logf ("advanced time by %d seconds: %d -> %d (Δ=%d)" , advance , t1 , t2 , t2 - t1 )
278+ })
279+
246280}
0 commit comments