mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
tests: use big int for stAuthorization because eest needs math.HexOrDecimal256 decoding
This commit is contained in:
parent
0a129dab19
commit
6505e50d62
2 changed files with 21 additions and 19 deletions
|
|
@ -5,10 +5,10 @@ package tests
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
var _ = (*stAuthorizationMarshaling)(nil)
|
||||
|
|
@ -20,16 +20,16 @@ func (s stAuthorization) MarshalJSON() ([]byte, error) {
|
|||
Address common.Address `json:"address" gencodec:"required"`
|
||||
Nonce math.HexOrDecimal64 `json:"nonce" gencodec:"required"`
|
||||
V math.HexOrDecimal64 `json:"v" gencodec:"required"`
|
||||
R uint256.Int `json:"r" gencodec:"required"`
|
||||
S uint256.Int `json:"s" gencodec:"required"`
|
||||
R *math.HexOrDecimal256 `json:"r" gencodec:"required"`
|
||||
S *math.HexOrDecimal256 `json:"s" gencodec:"required"`
|
||||
}
|
||||
var enc stAuthorization
|
||||
enc.ChainID = math.HexOrDecimal64(s.ChainID)
|
||||
enc.Address = s.Address
|
||||
enc.Nonce = math.HexOrDecimal64(s.Nonce)
|
||||
enc.V = math.HexOrDecimal64(s.V)
|
||||
enc.R = s.R
|
||||
enc.S = s.S
|
||||
enc.R = (*math.HexOrDecimal256)(s.R)
|
||||
enc.S = (*math.HexOrDecimal256)(s.S)
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
|
|
@ -40,8 +40,8 @@ func (s *stAuthorization) UnmarshalJSON(input []byte) error {
|
|||
Address *common.Address `json:"address" gencodec:"required"`
|
||||
Nonce *math.HexOrDecimal64 `json:"nonce" gencodec:"required"`
|
||||
V *math.HexOrDecimal64 `json:"v" gencodec:"required"`
|
||||
R *uint256.Int `json:"r" gencodec:"required"`
|
||||
S *uint256.Int `json:"s" gencodec:"required"`
|
||||
R *math.HexOrDecimal256 `json:"r" gencodec:"required"`
|
||||
S *math.HexOrDecimal256 `json:"s" gencodec:"required"`
|
||||
}
|
||||
var dec stAuthorization
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
|
|
@ -65,10 +65,10 @@ func (s *stAuthorization) UnmarshalJSON(input []byte) error {
|
|||
if dec.R == nil {
|
||||
return errors.New("missing required field 'r' for stAuthorization")
|
||||
}
|
||||
s.R = *dec.R
|
||||
s.R = (*big.Int)(dec.R)
|
||||
if dec.S == nil {
|
||||
return errors.New("missing required field 's' for stAuthorization")
|
||||
}
|
||||
s.S = *dec.S
|
||||
s.S = (*big.Int)(dec.S)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,8 +144,8 @@ type stAuthorization struct {
|
|||
Address common.Address `json:"address" gencodec:"required"`
|
||||
Nonce uint64 `json:"nonce" gencodec:"required"`
|
||||
V uint8 `json:"v" gencodec:"required"`
|
||||
R uint256.Int `json:"r" gencodec:"required"`
|
||||
S uint256.Int `json:"s" gencodec:"required"`
|
||||
R *big.Int `json:"r" gencodec:"required"`
|
||||
S *big.Int `json:"s" gencodec:"required"`
|
||||
}
|
||||
|
||||
// field type overrides for gencodec
|
||||
|
|
@ -153,6 +153,8 @@ type stAuthorizationMarshaling struct {
|
|||
ChainID math.HexOrDecimal64
|
||||
Nonce math.HexOrDecimal64
|
||||
V math.HexOrDecimal64
|
||||
R *math.HexOrDecimal256
|
||||
S *math.HexOrDecimal256
|
||||
}
|
||||
|
||||
// GetChainConfig takes a fork definition and returns a chain config.
|
||||
|
|
@ -448,8 +450,8 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
|
|||
Address: auth.Address,
|
||||
Nonce: auth.Nonce,
|
||||
V: auth.V,
|
||||
R: auth.R,
|
||||
S: auth.S,
|
||||
R: *uint256.MustFromBig(auth.R),
|
||||
S: *uint256.MustFromBig(auth.S),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue