common/hexutil: reject big integer inputs > 256 bits

This follows the change to common/math big integer parsing in PR #3699.
This commit is contained in:
Felix Lange
2017-02-22 17:35:11 +01:00
parent c52ab932e6
commit f3b7dcc5bd
4 changed files with 30 additions and 3 deletions

View File

@ -130,6 +130,10 @@ var unmarshalBigTests = []unmarshalTest{
{input: `"0x01"`, wantErr: ErrLeadingZero},
{input: `"0xx"`, wantErr: ErrSyntax},
{input: `"0x1zz01"`, wantErr: ErrSyntax},
{
input: `"0x10000000000000000000000000000000000000000000000000000000000000000"`,
wantErr: ErrBig256Range,
},
// valid encoding
{input: `""`, want: big.NewInt(0)},
@ -148,6 +152,10 @@ var unmarshalBigTests = []unmarshalTest{
input: `"0xffffffffffffffffffffffffffffffffffff"`,
want: referenceBig("ffffffffffffffffffffffffffffffffffff"),
},
{
input: `"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"`,
want: referenceBig("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
},
}
func TestUnmarshalBig(t *testing.T) {