Skip to content

Commit d3dae66

Browse files
taikingholiman
andauthored
tests: fix TransactionTest to actually run (#30272)
Due to https://github.com/ethereum/tests/releases/tag/v10.1, the format of the TransactionTest changed, but it was not properly addressed, causing the test to pass unexpectedly. --------- Co-authored-by: Martin Holst Swende <[email protected]>
1 parent 9ea766d commit d3dae66

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

tests/transaction_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,17 @@ func TestTransaction(t *testing.T) {
2626
t.Parallel()
2727

2828
txt := new(testMatcher)
29-
// These can't be parsed, invalid hex in RLP
30-
txt.skipLoad("^ttWrongRLP/.*")
3129
// We don't allow more than uint64 in gas amount
3230
// This is a pseudo-consensus vulnerability, but not in practice
3331
// because of the gas limit
3432
txt.skipLoad("^ttGasLimit/TransactionWithGasLimitxPriceOverflow.json")
3533
// We _do_ allow more than uint64 in gas price, as opposed to the tests
3634
// This is also not a concern, as long as tx.Cost() uses big.Int for
37-
// calculating the final cozt
38-
txt.skipLoad(".*TransactionWithGasPriceOverflow.*")
35+
// calculating the final cost
36+
txt.skipLoad("^ttGasPrice/TransactionWithGasPriceOverflow.json")
3937

40-
// The nonce is too large for uint64. Not a concern, it means geth won't
41-
// accept transactions at a certain point in the distant future
42-
txt.skipLoad("^ttNonce/TransactionWithHighNonce256.json")
38+
// The maximum value of nonce is 2^64 - 1
39+
txt.skipLoad("^ttNonce/TransactionWithHighNonce64Minus1.json")
4340

4441
// The value is larger than uint64, which according to the test is invalid.
4542
// Geth accepts it, which is not a consensus issue since we use big.Int's

tests/transaction_test_util.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import (
2929

3030
// TransactionTest checks RLP decoding and sender derivation of transactions.
3131
type TransactionTest struct {
32-
RLP hexutil.Bytes `json:"rlp"`
32+
Txbytes hexutil.Bytes `json:"txbytes"`
33+
Result ttResult
34+
}
35+
36+
type ttResult struct {
3337
Byzantium ttFork
3438
Constantinople ttFork
3539
Istanbul ttFork
@@ -73,15 +77,15 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
7377
isHomestead bool
7478
isIstanbul bool
7579
}{
76-
{"Frontier", types.FrontierSigner{}, tt.Frontier, false, false},
77-
{"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false},
78-
{"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false},
79-
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false},
80-
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false},
81-
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false},
82-
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true},
80+
{"Frontier", types.FrontierSigner{}, tt.Result.Frontier, false, false},
81+
{"Homestead", types.HomesteadSigner{}, tt.Result.Homestead, true, false},
82+
{"EIP150", types.HomesteadSigner{}, tt.Result.EIP150, true, false},
83+
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result.EIP158, true, false},
84+
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result.Byzantium, true, false},
85+
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result.Constantinople, true, false},
86+
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result.Istanbul, true, true},
8387
} {
84-
sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul)
88+
sender, txhash, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul)
8589

8690
if testcase.fork.Sender == (common.UnprefixedAddress{}) {
8791
if err == nil {

0 commit comments

Comments
 (0)