github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/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  //go:build integration
    18  // +build integration
    19  
    20  package tests
    21  
    22  import (
    23  	"testing"
    24  
    25  	"github.com/ethereum/go-ethereum/params"
    26  )
    27  
    28  func TestTransaction(t *testing.T) {
    29  	t.Parallel()
    30  
    31  	txt := new(testMatcher)
    32  	// These can't be parsed, invalid hex in RLP
    33  	txt.skipLoad("^ttWrongRLP/.*")
    34  	// We don't allow more than uint64 in gas amount
    35  	// This is a pseudo-consensus vulnerability, but not in practice
    36  	// because of the gas limit
    37  	txt.skipLoad("^ttGasLimit/TransactionWithGasLimitxPriceOverflow.json")
    38  	// We _do_ allow more than uint64 in gas price, as opposed to the tests
    39  	// This is also not a concern, as long as tx.Cost() uses big.Int for
    40  	// calculating the final cozt
    41  	txt.skipLoad(".*TransactionWithGasPriceOverflow.*")
    42  
    43  	// The nonce is too large for uint64. Not a concern, it means geth won't
    44  	// accept transactions at a certain point in the distant future
    45  	txt.skipLoad("^ttNonce/TransactionWithHighNonce256.json")
    46  
    47  	// The value is larger than uint64, which according to the test is invalid.
    48  	// Geth accepts it, which is not a consensus issue since we use big.Int's
    49  	// internally to calculate the cost
    50  	txt.skipLoad("^ttValue/TransactionWithHighValueOverflow.json")
    51  	txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
    52  		cfg := params.MainnetChainConfig
    53  		if err := txt.checkFailure(t, test.Run(cfg)); err != nil {
    54  			t.Errorf("in 'transaction_test.go', test '%s' failed with error: '%v'", name, err)
    55  		}
    56  	})
    57  }