block_test.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. "math/big"
  19. "path/filepath"
  20. "testing"
  21. )
  22. func TestBcValidBlockTests(t *testing.T) {
  23. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
  24. if err != nil {
  25. t.Fatal(err)
  26. }
  27. }
  28. func TestBcUncleHeaderValidityTests(t *testing.T) {
  29. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
  30. if err != nil {
  31. t.Fatal(err)
  32. }
  33. }
  34. func TestBcUncleTests(t *testing.T) {
  35. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
  36. if err != nil {
  37. t.Fatal(err)
  38. }
  39. }
  40. func TestBcForkUncleTests(t *testing.T) {
  41. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
  42. if err != nil {
  43. t.Fatal(err)
  44. }
  45. }
  46. func TestBcInvalidHeaderTests(t *testing.T) {
  47. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
  48. if err != nil {
  49. t.Fatal(err)
  50. }
  51. }
  52. func TestBcInvalidRLPTests(t *testing.T) {
  53. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
  54. if err != nil {
  55. t.Fatal(err)
  56. }
  57. }
  58. func TestBcRPCAPITests(t *testing.T) {
  59. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
  60. if err != nil {
  61. t.Fatal(err)
  62. }
  63. }
  64. func TestBcForkBlockTests(t *testing.T) {
  65. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
  66. if err != nil {
  67. t.Fatal(err)
  68. }
  69. }
  70. func TestBcForkStress(t *testing.T) {
  71. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
  72. if err != nil {
  73. t.Fatal(err)
  74. }
  75. }
  76. func TestBcTotalDifficulty(t *testing.T) {
  77. // skip because these will fail due to selfish mining fix
  78. t.Skip()
  79. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
  80. if err != nil {
  81. t.Fatal(err)
  82. }
  83. }
  84. func TestBcWallet(t *testing.T) {
  85. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
  86. if err != nil {
  87. t.Fatal(err)
  88. }
  89. }
  90. func TestBcGasPricer(t *testing.T) {
  91. err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests)
  92. if err != nil {
  93. t.Fatal(err)
  94. }
  95. }
  96. // TODO: iterate over files once we got more than a few
  97. func TestBcRandom(t *testing.T) {
  98. err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests)
  99. if err != nil {
  100. t.Fatal(err)
  101. }
  102. }
  103. func TestBcMultiChain(t *testing.T) {
  104. // skip due to selfish mining
  105. t.Skip()
  106. err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
  107. if err != nil {
  108. t.Fatal(err)
  109. }
  110. }
  111. func TestBcState(t *testing.T) {
  112. err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
  113. if err != nil {
  114. t.Fatal(err)
  115. }
  116. }
  117. // Homestead tests
  118. func TestHomesteadBcValidBlockTests(t *testing.T) {
  119. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
  120. if err != nil {
  121. t.Fatal(err)
  122. }
  123. }
  124. func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) {
  125. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
  126. if err != nil {
  127. t.Fatal(err)
  128. }
  129. }
  130. func TestHomesteadBcUncleTests(t *testing.T) {
  131. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
  132. if err != nil {
  133. t.Fatal(err)
  134. }
  135. }
  136. func TestHomesteadBcInvalidHeaderTests(t *testing.T) {
  137. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
  138. if err != nil {
  139. t.Fatal(err)
  140. }
  141. }
  142. func TestHomesteadBcRPCAPITests(t *testing.T) {
  143. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
  144. if err != nil {
  145. t.Fatal(err)
  146. }
  147. }
  148. func TestHomesteadBcForkStress(t *testing.T) {
  149. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
  150. if err != nil {
  151. t.Fatal(err)
  152. }
  153. }
  154. func TestHomesteadBcTotalDifficulty(t *testing.T) {
  155. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
  156. if err != nil {
  157. t.Fatal(err)
  158. }
  159. }
  160. func TestHomesteadBcWallet(t *testing.T) {
  161. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
  162. if err != nil {
  163. t.Fatal(err)
  164. }
  165. }
  166. func TestHomesteadBcGasPricer(t *testing.T) {
  167. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
  168. if err != nil {
  169. t.Fatal(err)
  170. }
  171. }
  172. func TestHomesteadBcMultiChain(t *testing.T) {
  173. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
  174. if err != nil {
  175. t.Fatal(err)
  176. }
  177. }
  178. func TestHomesteadBcState(t *testing.T) {
  179. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
  180. if err != nil {
  181. t.Fatal(err)
  182. }
  183. }
  184. // DAO hard-fork tests
  185. func TestDAOBcTheDao(t *testing.T) {
  186. err := RunBlockTest(big.NewInt(5), big.NewInt(8), nil, filepath.Join(blockTestDir, "TestNetwork", "bcTheDaoTest.json"), BlockSkipTests)
  187. if err != nil {
  188. t.Fatal(err)
  189. }
  190. }
  191. func TestEIP150Bc(t *testing.T) {
  192. err := RunBlockTest(big.NewInt(0), big.NewInt(8), big.NewInt(10), filepath.Join(blockTestDir, "TestNetwork", "bcEIP150Test.json"), BlockSkipTests)
  193. if err != nil {
  194. t.Fatal(err)
  195. }
  196. }
  197. func TestHomesteadBcExploit(t *testing.T) {
  198. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcExploitTest.json"), BlockSkipTests)
  199. if err != nil {
  200. t.Fatal(err)
  201. }
  202. }
  203. func TestHomesteadBcShanghaiLove(t *testing.T) {
  204. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcShanghaiLove.json"), BlockSkipTests)
  205. if err != nil {
  206. t.Fatal(err)
  207. }
  208. }
  209. func TestHomesteadBcSuicideIssue(t *testing.T) {
  210. err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcSuicideIssue.json"), BlockSkipTests)
  211. if err != nil {
  212. t.Fatal(err)
  213. }
  214. }