From 1a0bfd80d7d633db43fa86b8bead32768f2365f0 Mon Sep 17 00:00:00 2001 From: meows Date: Tue, 20 Feb 2024 12:25:34 -0700 Subject: [PATCH] tests: go generate -skip=trezor ./...; reapply gen_genesis.go UnmarshalChainConfigurator patch Date: 2024-02-20 12:25:34-07:00 Signed-off-by: meows --- tests/gen_stenv.go | 38 ++++++++++++++++++++++---------------- tests/gen_sttransaction.go | 12 ++++++------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/gen_stenv.go b/tests/gen_stenv.go index 71f0063178..e5dbe47e4b 100644 --- a/tests/gen_stenv.go +++ b/tests/gen_stenv.go @@ -16,35 +16,38 @@ var _ = (*stEnvMarshaling)(nil) // MarshalJSON marshals as JSON. func (s stEnv) MarshalJSON() ([]byte, error) { type stEnv struct { - Coinbase common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` - Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"optional"` - Random *math.HexOrDecimal256 `json:"currentRandom" gencodec:"optional"` - GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` - Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` - Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` - BaseFee *math.HexOrDecimal256 `json:"currentBaseFee" gencodec:"optional"` + Coinbase common.Address `json:"currentCoinbase" gencodec:"required"` + Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"optional"` + Random *math.HexOrDecimal256 `json:"currentRandom,omitempty" gencodec:"optional"` + GasLimit math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` + Number math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` + Timestamp math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` + BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty" gencodec:"optional"` + Previous common.Hash `json:"previousHash,omitempty" gencodec:"optional"` } var enc stEnv - enc.Coinbase = common.UnprefixedAddress(s.Coinbase) + enc.Coinbase = s.Coinbase enc.Difficulty = (*math.HexOrDecimal256)(s.Difficulty) enc.Random = (*math.HexOrDecimal256)(s.Random) enc.GasLimit = math.HexOrDecimal64(s.GasLimit) enc.Number = math.HexOrDecimal64(s.Number) enc.Timestamp = math.HexOrDecimal64(s.Timestamp) enc.BaseFee = (*math.HexOrDecimal256)(s.BaseFee) + enc.Previous = s.Previous return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. func (s *stEnv) UnmarshalJSON(input []byte) error { type stEnv struct { - Coinbase *common.UnprefixedAddress `json:"currentCoinbase" gencodec:"required"` - Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"optional"` - Random *math.HexOrDecimal256 `json:"currentRandom" gencodec:"optional"` - GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` - Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` - Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` - BaseFee *math.HexOrDecimal256 `json:"currentBaseFee" gencodec:"optional"` + Coinbase *common.Address `json:"currentCoinbase" gencodec:"required"` + Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"optional"` + Random *math.HexOrDecimal256 `json:"currentRandom,omitempty" gencodec:"optional"` + GasLimit *math.HexOrDecimal64 `json:"currentGasLimit" gencodec:"required"` + Number *math.HexOrDecimal64 `json:"currentNumber" gencodec:"required"` + Timestamp *math.HexOrDecimal64 `json:"currentTimestamp" gencodec:"required"` + BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty" gencodec:"optional"` + Previous *common.Hash `json:"previousHash,omitempty" gencodec:"optional"` } var dec stEnv if err := json.Unmarshal(input, &dec); err != nil { @@ -53,7 +56,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { if dec.Coinbase == nil { return errors.New("missing required field 'currentCoinbase' for stEnv") } - s.Coinbase = common.Address(*dec.Coinbase) + s.Coinbase = *dec.Coinbase if dec.Difficulty != nil { s.Difficulty = (*big.Int)(dec.Difficulty) } @@ -75,5 +78,8 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { if dec.BaseFee != nil { s.BaseFee = (*big.Int)(dec.BaseFee) } + if dec.Previous != nil { + s.Previous = *dec.Previous + } return nil } diff --git a/tests/gen_sttransaction.go b/tests/gen_sttransaction.go index 9b5aecbfe6..ecb3ea59e7 100644 --- a/tests/gen_sttransaction.go +++ b/tests/gen_sttransaction.go @@ -18,8 +18,8 @@ var _ = (*stTransactionMarshaling)(nil) func (s stTransaction) MarshalJSON() ([]byte, error) { type stTransaction struct { GasPrice *math.HexOrDecimal256 `json:"gasPrice"` - MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` - MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` + MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas,omitempty"` + MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas,omitempty"` Nonce math.HexOrDecimal64 `json:"nonce"` To string `json:"to"` Data []string `json:"data"` @@ -27,7 +27,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) { GasLimit []math.HexOrDecimal64 `json:"gasLimit"` Value []string `json:"value"` PrivateKey hexutil.Bytes `json:"secretKey"` - Sender *common.Address `json:"sender"` + Sender *common.Address `json:"sender,omitempty"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"` } @@ -57,8 +57,8 @@ func (s stTransaction) MarshalJSON() ([]byte, error) { func (s *stTransaction) UnmarshalJSON(input []byte) error { type stTransaction struct { GasPrice *math.HexOrDecimal256 `json:"gasPrice"` - MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` - MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` + MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas,omitempty"` + MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas,omitempty"` Nonce *math.HexOrDecimal64 `json:"nonce"` To *string `json:"to"` Data []string `json:"data"` @@ -66,7 +66,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error { GasLimit []math.HexOrDecimal64 `json:"gasLimit"` Value []string `json:"value"` PrivateKey *hexutil.Bytes `json:"secretKey"` - Sender *common.Address `json:"sender"` + Sender *common.Address `json:"sender,omitempty"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"` }