@@ -23,8 +23,6 @@ import (
23
23
"errors"
24
24
"math/big"
25
25
"testing"
26
-
27
- "github.com/holiman/uint256"
28
26
)
29
27
30
28
func checkError (t * testing.T , input string , got , want error ) bool {
@@ -178,64 +176,6 @@ func TestUnmarshalBig(t *testing.T) {
178
176
}
179
177
}
180
178
181
- var unmarshalU256Tests = []unmarshalTest {
182
- // invalid encoding
183
- {input : "" , wantErr : errJSONEOF },
184
- {input : "null" , wantErr : errNonString (u256T )},
185
- {input : "10" , wantErr : errNonString (u256T )},
186
- {input : `"0"` , wantErr : wrapTypeError (ErrMissingPrefix , u256T )},
187
- {input : `"0x"` , wantErr : wrapTypeError (ErrEmptyNumber , u256T )},
188
- {input : `"0x01"` , wantErr : wrapTypeError (ErrLeadingZero , u256T )},
189
- {input : `"0xx"` , wantErr : wrapTypeError (ErrSyntax , u256T )},
190
- {input : `"0x1zz01"` , wantErr : wrapTypeError (ErrSyntax , u256T )},
191
- {
192
- input : `"0x10000000000000000000000000000000000000000000000000000000000000000"` ,
193
- wantErr : wrapTypeError (ErrBig256Range , u256T ),
194
- },
195
-
196
- // valid encoding
197
- {input : `""` , want : big .NewInt (0 )},
198
- {input : `"0x0"` , want : big .NewInt (0 )},
199
- {input : `"0x2"` , want : big .NewInt (0x2 )},
200
- {input : `"0x2F2"` , want : big .NewInt (0x2f2 )},
201
- {input : `"0X2F2"` , want : big .NewInt (0x2f2 )},
202
- {input : `"0x1122aaff"` , want : big .NewInt (0x1122aaff )},
203
- {input : `"0xbBb"` , want : big .NewInt (0xbbb )},
204
- {input : `"0xfffffffff"` , want : big .NewInt (0xfffffffff )},
205
- {
206
- input : `"0x112233445566778899aabbccddeeff"` ,
207
- want : referenceBig ("112233445566778899aabbccddeeff" ),
208
- },
209
- {
210
- input : `"0xffffffffffffffffffffffffffffffffffff"` ,
211
- want : referenceBig ("ffffffffffffffffffffffffffffffffffff" ),
212
- },
213
- {
214
- input : `"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"` ,
215
- want : referenceBig ("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" ),
216
- },
217
- }
218
-
219
- func TestUnmarshalU256 (t * testing.T ) {
220
- for _ , test := range unmarshalU256Tests {
221
- var v U256
222
- err := json .Unmarshal ([]byte (test .input ), & v )
223
- if ! checkError (t , test .input , err , test .wantErr ) {
224
- continue
225
- }
226
- if test .want == nil {
227
- continue
228
- }
229
- want := new (uint256.Int )
230
- want .SetFromBig (test .want .(* big.Int ))
231
- have := (* uint256 .Int )(& v )
232
- if want .Cmp (have ) != 0 {
233
- t .Errorf ("input %s: value mismatch: have %x, want %x" , test .input , have , want )
234
- continue
235
- }
236
- }
237
- }
238
-
239
179
func BenchmarkUnmarshalBig (b * testing.B ) {
240
180
input := []byte (`"0x123456789abcdef123456789abcdef"` )
241
181
for i := 0 ; i < b .N ; i ++ {
0 commit comments