transaction_test.go 2.1 KB

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