@@ -23,6 +23,7 @@ import (
23
23
"time"
24
24
25
25
"github.com/ava-labs/libevm/common/math"
26
+ "github.com/stretchr/testify/require"
26
27
)
27
28
28
29
func TestCheckCompatible (t * testing.T ) {
@@ -137,3 +138,20 @@ func TestConfigRules(t *testing.T) {
137
138
t .Errorf ("expected %v to be shanghai" , stamp )
138
139
}
139
140
}
141
+
142
+ func TestTimestampCompatError (t * testing.T ) {
143
+ require .Equal (t , new (ConfigCompatError ).Error (), "" )
144
+
145
+ errWhat := "Shanghai fork timestamp"
146
+ require .Equal (t , newTimestampCompatError (errWhat , nil , newUint64 (1681338455 )).Error (),
147
+ "mismatching Shanghai fork timestamp in database (have timestamp nil, want timestamp 1681338455, rewindto timestamp 1681338454)" )
148
+
149
+ require .Equal (t , newTimestampCompatError (errWhat , newUint64 (1681338455 ), nil ).Error (),
150
+ "mismatching Shanghai fork timestamp in database (have timestamp 1681338455, want timestamp nil, rewindto timestamp 1681338454)" )
151
+
152
+ require .Equal (t , newTimestampCompatError (errWhat , newUint64 (1681338455 ), newUint64 (600624000 )).Error (),
153
+ "mismatching Shanghai fork timestamp in database (have timestamp 1681338455, want timestamp 600624000, rewindto timestamp 600623999)" )
154
+
155
+ require .Equal (t , newTimestampCompatError (errWhat , newUint64 (0 ), newUint64 (1681338455 )).Error (),
156
+ "mismatching Shanghai fork timestamp in database (have timestamp 0, want timestamp 1681338455, rewindto timestamp 0)" )
157
+ }
0 commit comments