skiptime_test.gno
0.50 Kb ยท 27 lines
1package skipheight
2
3import (
4 "chain/runtime"
5 "testing"
6 "time"
7)
8
9func TestSkipHeights(t *testing.T) {
10 oldHeight := runtime.ChainHeight()
11 shouldEQ(t, oldHeight, 123)
12
13 oldNow := time.Now().Unix()
14 shouldEQ(t, oldNow, 1234567890)
15
16 // skip 3 blocks == 15 seconds
17 testing.SkipHeights(3)
18
19 shouldEQ(t, runtime.ChainHeight()-oldHeight, 3)
20 shouldEQ(t, time.Now().Unix()-oldNow, 15)
21}
22
23func shouldEQ(t *testing.T, got, expected int64) {
24 if got != expected {
25 t.Fatalf("expected %d, got %d.", expected, got)
26 }
27}