tests: fix transaction tests format

This commit is contained in:
chocovayashi 2024-08-07 17:13:00 +09:00
parent b37ac5c102
commit 9ab5529447
2 changed files with 16 additions and 9 deletions

View file

@ -41,6 +41,9 @@ func TestTransaction(t *testing.T) {
// accept transactions at a certain point in the distant future
txt.skipLoad("^ttNonce/TransactionWithHighNonce256.json")
// The maximum value of nonce is 2^64 - 1
txt.skipLoad("^ttNonce/TransactionWithHighNonce64Minus1.json")
// The value is larger than uint64, which according to the test is invalid.
// Geth accepts it, which is not a consensus issue since we use big.Int's
// internally to calculate the cost

View file

@ -29,7 +29,11 @@ import (
// TransactionTest checks RLP decoding and sender derivation of transactions.
type TransactionTest struct {
RLP hexutil.Bytes `json:"rlp"`
Txbytes hexutil.Bytes `json:"txbytes"`
Result ttResult
}
type ttResult struct {
Byzantium ttFork
Constantinople ttFork
Istanbul ttFork
@ -73,15 +77,15 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
isHomestead bool
isIstanbul bool
}{
{"Frontier", types.FrontierSigner{}, tt.Frontier, false, false},
{"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false},
{"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false},
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false},
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false},
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false},
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true},
{"Frontier", types.FrontierSigner{}, tt.Result.Frontier, false, false},
{"Homestead", types.HomesteadSigner{}, tt.Result.Homestead, true, false},
{"EIP150", types.HomesteadSigner{}, tt.Result.EIP150, true, false},
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result.EIP158, true, false},
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result.Byzantium, true, false},
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result.Constantinople, true, false},
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result.Istanbul, true, true},
} {
sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul)
sender, txhash, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul)
if testcase.fork.Sender == (common.UnprefixedAddress{}) {
if err == nil {