github.com/ethereum/go-ethereum@v1.16.1/tests/transaction_test.go (about) 1 // Copyright 2015 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package tests 18 19 import ( 20 "testing" 21 22 "github.com/ethereum/go-ethereum/common" 23 ) 24 25 func TestTransaction(t *testing.T) { 26 t.Parallel() 27 28 txt := new(testMatcher) 29 // We don't allow more than uint64 in gas amount 30 // This is a pseudo-consensus vulnerability, but not in practice 31 // because of the gas limit 32 txt.skipLoad("^ttGasLimit/TransactionWithGasLimitxPriceOverflow.json") 33 // We _do_ allow more than uint64 in gas price, as opposed to the tests 34 // This is also not a concern, as long as tx.Cost() uses big.Int for 35 // calculating the final cost 36 txt.skipLoad("^ttGasPrice/TransactionWithGasPriceOverflow.json") 37 38 // The maximum value of nonce is 2^64 - 1 39 txt.skipLoad("^ttNonce/TransactionWithHighNonce64Minus1.json") 40 41 // The value is larger than uint64, which according to the test is invalid. 42 // Geth accepts it, which is not a consensus issue since we use big.Int's 43 // internally to calculate the cost 44 txt.skipLoad("^ttValue/TransactionWithHighValueOverflow.json") 45 46 // The size of a create tx's initcode is only checked during the state 47 // transition 48 txt.skipLoad("^ttEIP3860/DataTestInitCodeTooBig.json") 49 50 // The following tests require the tx precheck to be performed 51 // TODO(s1na): expose stateTransition.precheck publicly to be able to run these tests 52 txt.skipLoad("^ttEIP1559/maxPriorityFeePerGass32BytesValue.json") 53 txt.skipLoad("^ttEIP1559/maxPriorityFeePerGasOverflow.json") 54 txt.skipLoad("^ttEIP1559/maxFeePerGas32BytesValue.json") 55 txt.skipLoad("^ttEIP1559/maxFeePerGasOverflow.json") 56 txt.skipLoad("^ttEIP1559/GasLimitPriceProductPlusOneOverflow.json") 57 txt.skipLoad("^ttEIP1559/GasLimitPriceProductOverflow.json") 58 59 txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) { 60 if err := txt.checkFailure(t, test.Run()); err != nil { 61 t.Error(err) 62 } 63 }) 64 } 65 66 func TestExecutionSpecTransaction(t *testing.T) { 67 if !common.FileExist(executionSpecStateTestDir) { 68 t.Skipf("directory %s does not exist", executionSpecStateTestDir) 69 } 70 st := new(testMatcher) 71 72 // Emptiness of authorization list is only validated during the tx precheck 73 st.skipLoad("^prague/eip7702_set_code_tx/invalid_tx/empty_authorization_list.json") 74 75 st.walk(t, executionSpecTransactionTestDir, func(t *testing.T, name string, test *TransactionTest) { 76 if err := st.checkFailure(t, test.Run()); err != nil { 77 t.Error(err) 78 } 79 }) 80 }