mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-14 20:16:36 +00:00
common/hexutil: replace customized bit sizer with bit.Uintsize (#32304)
This commit is contained in:
parent
2d95ba7d15
commit
0814d991ab
2 changed files with 4 additions and 4 deletions
|
|
@ -34,11 +34,10 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/bits"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const uintBits = 32 << (uint64(^uint(0)) >> 63)
|
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
var (
|
var (
|
||||||
ErrEmptyString = &decError{"empty hex string"}
|
ErrEmptyString = &decError{"empty hex string"}
|
||||||
|
|
@ -48,7 +47,7 @@ var (
|
||||||
ErrEmptyNumber = &decError{"hex string \"0x\""}
|
ErrEmptyNumber = &decError{"hex string \"0x\""}
|
||||||
ErrLeadingZero = &decError{"hex number with leading zero digits"}
|
ErrLeadingZero = &decError{"hex number with leading zero digits"}
|
||||||
ErrUint64Range = &decError{"hex number > 64 bits"}
|
ErrUint64Range = &decError{"hex number > 64 bits"}
|
||||||
ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
|
ErrUintRange = &decError{fmt.Sprintf("hex number > %d bits", bits.UintSize)}
|
||||||
ErrBig256Range = &decError{"hex number > 256 bits"}
|
ErrBig256Range = &decError{"hex number > 256 bits"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/bits"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
|
@ -384,7 +385,7 @@ func TestUnmarshalUint(t *testing.T) {
|
||||||
for _, test := range unmarshalUintTests {
|
for _, test := range unmarshalUintTests {
|
||||||
var v Uint
|
var v Uint
|
||||||
err := json.Unmarshal([]byte(test.input), &v)
|
err := json.Unmarshal([]byte(test.input), &v)
|
||||||
if uintBits == 32 && test.wantErr32bit != nil {
|
if bits.UintSize == 32 && test.wantErr32bit != nil {
|
||||||
checkError(t, test.input, err, test.wantErr32bit)
|
checkError(t, test.input, err, test.wantErr32bit)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue