state_test.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  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. "os"
  20. "path/filepath"
  21. "testing"
  22. "github.com/ethereum/go-ethereum/params"
  23. )
  24. func BenchmarkStateCall1024(b *testing.B) {
  25. fn := filepath.Join(stateTestDir, "stCallCreateCallCodeTest.json")
  26. if err := BenchVmTest(fn, bconf{"Call1024BalanceTooLow", true, os.Getenv("JITVM") == "true"}, b); err != nil {
  27. b.Error(err)
  28. }
  29. }
  30. func TestStateSystemOperations(t *testing.T) {
  31. chainConfig := &params.ChainConfig{
  32. HomesteadBlock: big.NewInt(1150000),
  33. }
  34. fn := filepath.Join(stateTestDir, "stSystemOperationsTest.json")
  35. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  36. t.Error(err)
  37. }
  38. }
  39. func TestStateExample(t *testing.T) {
  40. chainConfig := &params.ChainConfig{
  41. HomesteadBlock: big.NewInt(1150000),
  42. }
  43. fn := filepath.Join(stateTestDir, "stExample.json")
  44. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  45. t.Error(err)
  46. }
  47. }
  48. func TestStatePreCompiledContracts(t *testing.T) {
  49. chainConfig := &params.ChainConfig{
  50. HomesteadBlock: big.NewInt(1150000),
  51. }
  52. fn := filepath.Join(stateTestDir, "stPreCompiledContracts.json")
  53. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  54. t.Error(err)
  55. }
  56. }
  57. func TestStateRecursiveCreate(t *testing.T) {
  58. chainConfig := &params.ChainConfig{
  59. HomesteadBlock: big.NewInt(1150000),
  60. }
  61. fn := filepath.Join(stateTestDir, "stRecursiveCreate.json")
  62. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  63. t.Error(err)
  64. }
  65. }
  66. func TestStateSpecial(t *testing.T) {
  67. chainConfig := &params.ChainConfig{
  68. HomesteadBlock: big.NewInt(1150000),
  69. }
  70. fn := filepath.Join(stateTestDir, "stSpecialTest.json")
  71. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  72. t.Error(err)
  73. }
  74. }
  75. func TestStateRefund(t *testing.T) {
  76. chainConfig := &params.ChainConfig{
  77. HomesteadBlock: big.NewInt(1150000),
  78. }
  79. fn := filepath.Join(stateTestDir, "stRefundTest.json")
  80. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  81. t.Error(err)
  82. }
  83. }
  84. func TestStateBlockHash(t *testing.T) {
  85. chainConfig := &params.ChainConfig{
  86. HomesteadBlock: big.NewInt(1150000),
  87. }
  88. fn := filepath.Join(stateTestDir, "stBlockHashTest.json")
  89. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  90. t.Error(err)
  91. }
  92. }
  93. func TestStateInitCode(t *testing.T) {
  94. chainConfig := &params.ChainConfig{
  95. HomesteadBlock: big.NewInt(1150000),
  96. }
  97. fn := filepath.Join(stateTestDir, "stInitCodeTest.json")
  98. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  99. t.Error(err)
  100. }
  101. }
  102. func TestStateLog(t *testing.T) {
  103. chainConfig := &params.ChainConfig{
  104. HomesteadBlock: big.NewInt(1150000),
  105. }
  106. fn := filepath.Join(stateTestDir, "stLogTests.json")
  107. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  108. t.Error(err)
  109. }
  110. }
  111. func TestStateTransaction(t *testing.T) {
  112. chainConfig := &params.ChainConfig{
  113. HomesteadBlock: big.NewInt(1150000),
  114. }
  115. fn := filepath.Join(stateTestDir, "stTransactionTest.json")
  116. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  117. t.Error(err)
  118. }
  119. }
  120. func TestStateTransition(t *testing.T) {
  121. chainConfig := &params.ChainConfig{
  122. HomesteadBlock: big.NewInt(1150000),
  123. }
  124. fn := filepath.Join(stateTestDir, "stTransitionTest.json")
  125. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  126. t.Error(err)
  127. }
  128. }
  129. func TestCallCreateCallCode(t *testing.T) {
  130. chainConfig := &params.ChainConfig{
  131. HomesteadBlock: big.NewInt(1150000),
  132. }
  133. fn := filepath.Join(stateTestDir, "stCallCreateCallCodeTest.json")
  134. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  135. t.Error(err)
  136. }
  137. }
  138. func TestCallCodes(t *testing.T) {
  139. chainConfig := &params.ChainConfig{
  140. HomesteadBlock: big.NewInt(1150000),
  141. }
  142. fn := filepath.Join(stateTestDir, "stCallCodes.json")
  143. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  144. t.Error(err)
  145. }
  146. }
  147. func TestMemory(t *testing.T) {
  148. chainConfig := &params.ChainConfig{
  149. HomesteadBlock: big.NewInt(1150000),
  150. }
  151. fn := filepath.Join(stateTestDir, "stMemoryTest.json")
  152. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  153. t.Error(err)
  154. }
  155. }
  156. func TestMemoryStress(t *testing.T) {
  157. chainConfig := &params.ChainConfig{
  158. HomesteadBlock: big.NewInt(1150000),
  159. }
  160. if os.Getenv("TEST_VM_COMPLEX") == "" {
  161. t.Skip()
  162. }
  163. fn := filepath.Join(stateTestDir, "stMemoryStressTest.json")
  164. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  165. t.Error(err)
  166. }
  167. }
  168. func TestQuadraticComplexity(t *testing.T) {
  169. chainConfig := &params.ChainConfig{
  170. HomesteadBlock: big.NewInt(1150000),
  171. }
  172. if os.Getenv("TEST_VM_COMPLEX") == "" {
  173. t.Skip()
  174. }
  175. fn := filepath.Join(stateTestDir, "stQuadraticComplexityTest.json")
  176. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  177. t.Error(err)
  178. }
  179. }
  180. func TestSolidity(t *testing.T) {
  181. chainConfig := &params.ChainConfig{
  182. HomesteadBlock: big.NewInt(1150000),
  183. }
  184. fn := filepath.Join(stateTestDir, "stSolidityTest.json")
  185. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  186. t.Error(err)
  187. }
  188. }
  189. func TestWallet(t *testing.T) {
  190. chainConfig := &params.ChainConfig{
  191. HomesteadBlock: big.NewInt(1150000),
  192. }
  193. fn := filepath.Join(stateTestDir, "stWalletTest.json")
  194. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  195. t.Error(err)
  196. }
  197. }
  198. func TestStateTestsRandom(t *testing.T) {
  199. t.Skip()
  200. chainConfig := &params.ChainConfig{
  201. HomesteadBlock: big.NewInt(1150000),
  202. }
  203. fns, _ := filepath.Glob("./files/StateTests/RandomTests/*")
  204. for _, fn := range fns {
  205. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  206. t.Error(fn, err)
  207. }
  208. }
  209. }
  210. // homestead tests
  211. func TestHomesteadDelegateCall(t *testing.T) {
  212. chainConfig := &params.ChainConfig{
  213. HomesteadBlock: big.NewInt(1150000),
  214. }
  215. fn := filepath.Join(stateTestDir, "Homestead", "stDelegatecallTest.json")
  216. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  217. t.Error(err)
  218. }
  219. }
  220. func TestHomesteadStateSystemOperations(t *testing.T) {
  221. chainConfig := &params.ChainConfig{
  222. HomesteadBlock: new(big.Int),
  223. }
  224. fn := filepath.Join(stateTestDir, "Homestead", "stSystemOperationsTest.json")
  225. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  226. t.Error(err)
  227. }
  228. }
  229. func TestHomesteadStatePreCompiledContracts(t *testing.T) {
  230. chainConfig := &params.ChainConfig{
  231. HomesteadBlock: new(big.Int),
  232. }
  233. fn := filepath.Join(stateTestDir, "Homestead", "stPreCompiledContracts.json")
  234. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  235. t.Error(err)
  236. }
  237. }
  238. func TestHomesteadStateRecursiveCreate(t *testing.T) {
  239. chainConfig := &params.ChainConfig{
  240. HomesteadBlock: new(big.Int),
  241. }
  242. fn := filepath.Join(stateTestDir, "Homestead", "stSpecialTest.json")
  243. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  244. t.Error(err)
  245. }
  246. }
  247. func TestHomesteadStateRefund(t *testing.T) {
  248. chainConfig := &params.ChainConfig{
  249. HomesteadBlock: new(big.Int),
  250. }
  251. fn := filepath.Join(stateTestDir, "Homestead", "stRefundTest.json")
  252. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  253. t.Error(err)
  254. }
  255. }
  256. func TestHomesteadStateInitCode(t *testing.T) {
  257. chainConfig := &params.ChainConfig{
  258. HomesteadBlock: new(big.Int),
  259. }
  260. fn := filepath.Join(stateTestDir, "Homestead", "stInitCodeTest.json")
  261. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  262. t.Error(err)
  263. }
  264. }
  265. func TestHomesteadStateLog(t *testing.T) {
  266. chainConfig := &params.ChainConfig{
  267. HomesteadBlock: new(big.Int),
  268. }
  269. fn := filepath.Join(stateTestDir, "Homestead", "stLogTests.json")
  270. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  271. t.Error(err)
  272. }
  273. }
  274. func TestHomesteadStateTransaction(t *testing.T) {
  275. chainConfig := &params.ChainConfig{
  276. HomesteadBlock: new(big.Int),
  277. }
  278. fn := filepath.Join(stateTestDir, "Homestead", "stTransactionTest.json")
  279. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  280. t.Error(err)
  281. }
  282. }
  283. func TestHomesteadCallCreateCallCode(t *testing.T) {
  284. chainConfig := &params.ChainConfig{
  285. HomesteadBlock: new(big.Int),
  286. }
  287. fn := filepath.Join(stateTestDir, "Homestead", "stCallCreateCallCodeTest.json")
  288. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  289. t.Error(err)
  290. }
  291. }
  292. func TestHomesteadCallCodes(t *testing.T) {
  293. chainConfig := &params.ChainConfig{
  294. HomesteadBlock: new(big.Int),
  295. }
  296. fn := filepath.Join(stateTestDir, "Homestead", "stCallCodes.json")
  297. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  298. t.Error(err)
  299. }
  300. }
  301. func TestHomesteadMemory(t *testing.T) {
  302. chainConfig := &params.ChainConfig{
  303. HomesteadBlock: new(big.Int),
  304. }
  305. fn := filepath.Join(stateTestDir, "Homestead", "stMemoryTest.json")
  306. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  307. t.Error(err)
  308. }
  309. }
  310. func TestHomesteadMemoryStress(t *testing.T) {
  311. chainConfig := &params.ChainConfig{
  312. HomesteadBlock: new(big.Int),
  313. }
  314. if os.Getenv("TEST_VM_COMPLEX") == "" {
  315. t.Skip()
  316. }
  317. fn := filepath.Join(stateTestDir, "Homestead", "stMemoryStressTest.json")
  318. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  319. t.Error(err)
  320. }
  321. }
  322. func TestHomesteadQuadraticComplexity(t *testing.T) {
  323. chainConfig := &params.ChainConfig{
  324. HomesteadBlock: new(big.Int),
  325. }
  326. if os.Getenv("TEST_VM_COMPLEX") == "" {
  327. t.Skip()
  328. }
  329. fn := filepath.Join(stateTestDir, "Homestead", "stQuadraticComplexityTest.json")
  330. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  331. t.Error(err)
  332. }
  333. }
  334. func TestHomesteadWallet(t *testing.T) {
  335. chainConfig := &params.ChainConfig{
  336. HomesteadBlock: new(big.Int),
  337. }
  338. fn := filepath.Join(stateTestDir, "Homestead", "stWalletTest.json")
  339. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  340. t.Error(err)
  341. }
  342. }
  343. func TestHomesteadDelegateCodes(t *testing.T) {
  344. chainConfig := &params.ChainConfig{
  345. HomesteadBlock: new(big.Int),
  346. }
  347. fn := filepath.Join(stateTestDir, "Homestead", "stCallDelegateCodes.json")
  348. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  349. t.Error(err)
  350. }
  351. }
  352. func TestHomesteadDelegateCodesCallCode(t *testing.T) {
  353. chainConfig := &params.ChainConfig{
  354. HomesteadBlock: new(big.Int),
  355. }
  356. fn := filepath.Join(stateTestDir, "Homestead", "stCallDelegateCodesCallCode.json")
  357. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  358. t.Error(err)
  359. }
  360. }
  361. func TestHomesteadBounds(t *testing.T) {
  362. chainConfig := &params.ChainConfig{
  363. HomesteadBlock: new(big.Int),
  364. }
  365. fn := filepath.Join(stateTestDir, "Homestead", "stBoundsTest.json")
  366. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  367. t.Error(err)
  368. }
  369. }
  370. // EIP150 tests
  371. func TestEIP150Specific(t *testing.T) {
  372. chainConfig := &params.ChainConfig{
  373. HomesteadBlock: new(big.Int),
  374. EIP150Block: big.NewInt(2457000),
  375. }
  376. fn := filepath.Join(stateTestDir, "EIP150", "stEIPSpecificTest.json")
  377. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  378. t.Error(err)
  379. }
  380. }
  381. func TestEIP150SingleCodeGasPrice(t *testing.T) {
  382. chainConfig := &params.ChainConfig{
  383. HomesteadBlock: new(big.Int),
  384. EIP150Block: big.NewInt(2457000),
  385. }
  386. fn := filepath.Join(stateTestDir, "EIP150", "stEIPSingleCodeGasPrices.json")
  387. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  388. t.Error(err)
  389. }
  390. }
  391. func TestEIP150MemExpandingCalls(t *testing.T) {
  392. chainConfig := &params.ChainConfig{
  393. HomesteadBlock: new(big.Int),
  394. EIP150Block: big.NewInt(2457000),
  395. }
  396. fn := filepath.Join(stateTestDir, "EIP150", "stMemExpandingEIPCalls.json")
  397. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  398. t.Error(err)
  399. }
  400. }
  401. func TestEIP150HomesteadStateSystemOperations(t *testing.T) {
  402. chainConfig := &params.ChainConfig{
  403. HomesteadBlock: new(big.Int),
  404. EIP150Block: big.NewInt(2457000),
  405. }
  406. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stSystemOperationsTest.json")
  407. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  408. t.Error(err)
  409. }
  410. }
  411. func TestEIP150HomesteadStatePreCompiledContracts(t *testing.T) {
  412. chainConfig := &params.ChainConfig{
  413. HomesteadBlock: new(big.Int),
  414. EIP150Block: big.NewInt(2457000),
  415. }
  416. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stPreCompiledContracts.json")
  417. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  418. t.Error(err)
  419. }
  420. }
  421. func TestEIP150HomesteadStateRecursiveCreate(t *testing.T) {
  422. chainConfig := &params.ChainConfig{
  423. HomesteadBlock: new(big.Int),
  424. EIP150Block: big.NewInt(2457000),
  425. }
  426. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stSpecialTest.json")
  427. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  428. t.Error(err)
  429. }
  430. }
  431. func TestEIP150HomesteadStateRefund(t *testing.T) {
  432. chainConfig := &params.ChainConfig{
  433. HomesteadBlock: new(big.Int),
  434. EIP150Block: big.NewInt(2457000),
  435. }
  436. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stRefundTest.json")
  437. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  438. t.Error(err)
  439. }
  440. }
  441. func TestEIP150HomesteadStateInitCode(t *testing.T) {
  442. chainConfig := &params.ChainConfig{
  443. HomesteadBlock: new(big.Int),
  444. EIP150Block: big.NewInt(2457000),
  445. }
  446. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stInitCodeTest.json")
  447. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  448. t.Error(err)
  449. }
  450. }
  451. func TestEIP150HomesteadStateLog(t *testing.T) {
  452. chainConfig := &params.ChainConfig{
  453. HomesteadBlock: new(big.Int),
  454. EIP150Block: big.NewInt(2457000),
  455. }
  456. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stLogTests.json")
  457. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  458. t.Error(err)
  459. }
  460. }
  461. func TestEIP150HomesteadStateTransaction(t *testing.T) {
  462. chainConfig := &params.ChainConfig{
  463. HomesteadBlock: new(big.Int),
  464. EIP150Block: big.NewInt(2457000),
  465. }
  466. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stTransactionTest.json")
  467. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  468. t.Error(err)
  469. }
  470. }
  471. func TestEIP150HomesteadCallCreateCallCode(t *testing.T) {
  472. chainConfig := &params.ChainConfig{
  473. HomesteadBlock: new(big.Int),
  474. EIP150Block: big.NewInt(2457000),
  475. }
  476. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stCallCreateCallCodeTest.json")
  477. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  478. t.Error(err)
  479. }
  480. }
  481. func TestEIP150HomesteadCallCodes(t *testing.T) {
  482. chainConfig := &params.ChainConfig{
  483. HomesteadBlock: new(big.Int),
  484. EIP150Block: big.NewInt(2457000),
  485. }
  486. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stCallCodes.json")
  487. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  488. t.Error(err)
  489. }
  490. }
  491. func TestEIP150HomesteadMemory(t *testing.T) {
  492. chainConfig := &params.ChainConfig{
  493. HomesteadBlock: new(big.Int),
  494. EIP150Block: big.NewInt(2457000),
  495. }
  496. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stMemoryTest.json")
  497. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  498. t.Error(err)
  499. }
  500. }
  501. func TestEIP150HomesteadMemoryStress(t *testing.T) {
  502. chainConfig := &params.ChainConfig{
  503. HomesteadBlock: new(big.Int),
  504. EIP150Block: big.NewInt(2457000),
  505. }
  506. if os.Getenv("TEST_VM_COMPLEX") == "" {
  507. t.Skip()
  508. }
  509. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stMemoryStressTest.json")
  510. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  511. t.Error(err)
  512. }
  513. }
  514. func TestEIP150HomesteadQuadraticComplexity(t *testing.T) {
  515. chainConfig := &params.ChainConfig{
  516. HomesteadBlock: new(big.Int),
  517. EIP150Block: big.NewInt(2457000),
  518. }
  519. if os.Getenv("TEST_VM_COMPLEX") == "" {
  520. t.Skip()
  521. }
  522. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stQuadraticComplexityTest.json")
  523. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  524. t.Error(err)
  525. }
  526. }
  527. func TestEIP150HomesteadWallet(t *testing.T) {
  528. chainConfig := &params.ChainConfig{
  529. HomesteadBlock: new(big.Int),
  530. EIP150Block: big.NewInt(2457000),
  531. }
  532. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stWalletTest.json")
  533. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  534. t.Error(err)
  535. }
  536. }
  537. func TestEIP150HomesteadDelegateCodes(t *testing.T) {
  538. chainConfig := &params.ChainConfig{
  539. HomesteadBlock: new(big.Int),
  540. EIP150Block: big.NewInt(2457000),
  541. }
  542. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stCallDelegateCodes.json")
  543. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  544. t.Error(err)
  545. }
  546. }
  547. func TestEIP150HomesteadDelegateCodesCallCode(t *testing.T) {
  548. chainConfig := &params.ChainConfig{
  549. HomesteadBlock: new(big.Int),
  550. EIP150Block: big.NewInt(2457000),
  551. }
  552. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stCallDelegateCodesCallCode.json")
  553. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  554. t.Error(err)
  555. }
  556. }
  557. func TestEIP150HomesteadBounds(t *testing.T) {
  558. chainConfig := &params.ChainConfig{
  559. HomesteadBlock: new(big.Int),
  560. EIP150Block: big.NewInt(2457000),
  561. }
  562. fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stBoundsTest.json")
  563. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  564. t.Error(err)
  565. }
  566. }
  567. // EIP158 tests
  568. func TestEIP158Create(t *testing.T) {
  569. chainConfig := &params.ChainConfig{
  570. HomesteadBlock: new(big.Int),
  571. EIP150Block: big.NewInt(2457000),
  572. EIP158Block: params.MainNetSpuriousDragon,
  573. }
  574. fn := filepath.Join(stateTestDir, "EIP158", "stCreateTest.json")
  575. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  576. t.Error(err)
  577. }
  578. }
  579. func TestEIP158Specific(t *testing.T) {
  580. chainConfig := &params.ChainConfig{
  581. HomesteadBlock: new(big.Int),
  582. EIP150Block: big.NewInt(2457000),
  583. EIP158Block: params.MainNetSpuriousDragon,
  584. }
  585. fn := filepath.Join(stateTestDir, "EIP158", "stEIP158SpecificTest.json")
  586. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  587. t.Error(err)
  588. }
  589. }
  590. func TestEIP158NonZeroCalls(t *testing.T) {
  591. chainConfig := &params.ChainConfig{
  592. HomesteadBlock: new(big.Int),
  593. EIP150Block: big.NewInt(2457000),
  594. EIP158Block: params.MainNetSpuriousDragon,
  595. }
  596. fn := filepath.Join(stateTestDir, "EIP158", "stNonZeroCallsTest.json")
  597. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  598. t.Error(err)
  599. }
  600. }
  601. func TestEIP158ZeroCalls(t *testing.T) {
  602. chainConfig := &params.ChainConfig{
  603. HomesteadBlock: new(big.Int),
  604. EIP150Block: big.NewInt(2457000),
  605. EIP158Block: params.MainNetSpuriousDragon,
  606. }
  607. fn := filepath.Join(stateTestDir, "EIP158", "stZeroCallsTest.json")
  608. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  609. t.Error(err)
  610. }
  611. }
  612. func TestEIP158_150Specific(t *testing.T) {
  613. chainConfig := &params.ChainConfig{
  614. HomesteadBlock: new(big.Int),
  615. EIP150Block: big.NewInt(2457000),
  616. EIP158Block: params.MainNetSpuriousDragon,
  617. }
  618. fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stEIPSpecificTest.json")
  619. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  620. t.Error(err)
  621. }
  622. }
  623. func TestEIP158_150SingleCodeGasPrice(t *testing.T) {
  624. chainConfig := &params.ChainConfig{
  625. HomesteadBlock: new(big.Int),
  626. EIP150Block: big.NewInt(2457000),
  627. EIP158Block: params.MainNetSpuriousDragon,
  628. }
  629. fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stEIPsingleCodeGasPrices.json")
  630. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  631. t.Error(err)
  632. }
  633. }
  634. func TestEIP158_150MemExpandingCalls(t *testing.T) {
  635. chainConfig := &params.ChainConfig{
  636. HomesteadBlock: new(big.Int),
  637. EIP150Block: big.NewInt(2457000),
  638. EIP158Block: params.MainNetSpuriousDragon,
  639. }
  640. fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stMemExpandingEIPCalls.json")
  641. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  642. t.Error(err)
  643. }
  644. }
  645. func TestEIP158HomesteadStateSystemOperations(t *testing.T) {
  646. chainConfig := &params.ChainConfig{
  647. HomesteadBlock: new(big.Int),
  648. EIP150Block: big.NewInt(2457000),
  649. EIP158Block: params.MainNetSpuriousDragon,
  650. }
  651. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stSystemOperationsTest.json")
  652. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  653. t.Error(err)
  654. }
  655. }
  656. func TestEIP158HomesteadStatePreCompiledContracts(t *testing.T) {
  657. chainConfig := &params.ChainConfig{
  658. HomesteadBlock: new(big.Int),
  659. EIP150Block: big.NewInt(2457000),
  660. EIP158Block: params.MainNetSpuriousDragon,
  661. }
  662. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stPreCompiledContracts.json")
  663. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  664. t.Error(err)
  665. }
  666. }
  667. func TestEIP158HomesteadStateRecursiveCreate(t *testing.T) {
  668. chainConfig := &params.ChainConfig{
  669. HomesteadBlock: new(big.Int),
  670. EIP150Block: big.NewInt(2457000),
  671. EIP158Block: params.MainNetSpuriousDragon,
  672. }
  673. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stSpecialTest.json")
  674. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  675. t.Error(err)
  676. }
  677. }
  678. func TestEIP158HomesteadStateRefund(t *testing.T) {
  679. chainConfig := &params.ChainConfig{
  680. HomesteadBlock: new(big.Int),
  681. EIP150Block: big.NewInt(2457000),
  682. EIP158Block: params.MainNetSpuriousDragon,
  683. }
  684. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stRefundTest.json")
  685. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  686. t.Error(err)
  687. }
  688. }
  689. func TestEIP158HomesteadStateInitCode(t *testing.T) {
  690. chainConfig := &params.ChainConfig{
  691. HomesteadBlock: new(big.Int),
  692. EIP150Block: big.NewInt(2457000),
  693. EIP158Block: params.MainNetSpuriousDragon,
  694. }
  695. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stInitCodeTest.json")
  696. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  697. t.Error(err)
  698. }
  699. }
  700. func TestEIP158HomesteadStateLog(t *testing.T) {
  701. chainConfig := &params.ChainConfig{
  702. HomesteadBlock: new(big.Int),
  703. EIP150Block: big.NewInt(2457000),
  704. EIP158Block: params.MainNetSpuriousDragon,
  705. }
  706. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stLogTests.json")
  707. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  708. t.Error(err)
  709. }
  710. }
  711. func TestEIP158HomesteadStateTransaction(t *testing.T) {
  712. chainConfig := &params.ChainConfig{
  713. HomesteadBlock: new(big.Int),
  714. EIP150Block: big.NewInt(2457000),
  715. EIP158Block: params.MainNetSpuriousDragon,
  716. }
  717. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stTransactionTest.json")
  718. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  719. t.Error(err)
  720. }
  721. }
  722. func TestEIP158HomesteadCallCreateCallCode(t *testing.T) {
  723. chainConfig := &params.ChainConfig{
  724. HomesteadBlock: new(big.Int),
  725. EIP150Block: big.NewInt(2457000),
  726. EIP158Block: params.MainNetSpuriousDragon,
  727. }
  728. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallCreateCallCodeTest.json")
  729. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  730. t.Error(err)
  731. }
  732. }
  733. func TestEIP158HomesteadCallCodes(t *testing.T) {
  734. chainConfig := &params.ChainConfig{
  735. HomesteadBlock: new(big.Int),
  736. EIP150Block: big.NewInt(2457000),
  737. EIP158Block: params.MainNetSpuriousDragon,
  738. }
  739. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallCodes.json")
  740. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  741. t.Error(err)
  742. }
  743. }
  744. func TestEIP158HomesteadMemory(t *testing.T) {
  745. chainConfig := &params.ChainConfig{
  746. HomesteadBlock: new(big.Int),
  747. EIP150Block: big.NewInt(2457000),
  748. EIP158Block: params.MainNetSpuriousDragon,
  749. }
  750. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stMemoryTest.json")
  751. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  752. t.Error(err)
  753. }
  754. }
  755. func TestEIP158HomesteadMemoryStress(t *testing.T) {
  756. chainConfig := &params.ChainConfig{
  757. HomesteadBlock: new(big.Int),
  758. EIP150Block: big.NewInt(2457000),
  759. EIP158Block: params.MainNetSpuriousDragon,
  760. }
  761. if os.Getenv("TEST_VM_COMPLEX") == "" {
  762. t.Skip()
  763. }
  764. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stMemoryStressTest.json")
  765. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  766. t.Error(err)
  767. }
  768. }
  769. func TestEIP158HomesteadQuadraticComplexity(t *testing.T) {
  770. chainConfig := &params.ChainConfig{
  771. HomesteadBlock: new(big.Int),
  772. EIP150Block: big.NewInt(2457000),
  773. EIP158Block: params.MainNetSpuriousDragon,
  774. }
  775. if os.Getenv("TEST_VM_COMPLEX") == "" {
  776. t.Skip()
  777. }
  778. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stQuadraticComplexityTest.json")
  779. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  780. t.Error(err)
  781. }
  782. }
  783. func TestEIP158HomesteadWallet(t *testing.T) {
  784. chainConfig := &params.ChainConfig{
  785. HomesteadBlock: new(big.Int),
  786. EIP150Block: big.NewInt(2457000),
  787. EIP158Block: params.MainNetSpuriousDragon,
  788. }
  789. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stWalletTest.json")
  790. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  791. t.Error(err)
  792. }
  793. }
  794. func TestEIP158HomesteadDelegateCodes(t *testing.T) {
  795. chainConfig := &params.ChainConfig{
  796. HomesteadBlock: new(big.Int),
  797. EIP150Block: big.NewInt(2457000),
  798. EIP158Block: params.MainNetSpuriousDragon,
  799. }
  800. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallDelegateCodes.json")
  801. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  802. t.Error(err)
  803. }
  804. }
  805. func TestEIP158HomesteadDelegateCodesCallCode(t *testing.T) {
  806. chainConfig := &params.ChainConfig{
  807. HomesteadBlock: new(big.Int),
  808. EIP150Block: big.NewInt(2457000),
  809. EIP158Block: params.MainNetSpuriousDragon,
  810. }
  811. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallDelegateCodesCallCode.json")
  812. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  813. t.Error(err)
  814. }
  815. }
  816. func TestEIP158HomesteadBounds(t *testing.T) {
  817. chainConfig := &params.ChainConfig{
  818. HomesteadBlock: new(big.Int),
  819. EIP150Block: big.NewInt(2457000),
  820. EIP158Block: params.MainNetSpuriousDragon,
  821. }
  822. fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stBoundsTest.json")
  823. if err := RunStateTest(chainConfig, fn, StateSkipTests); err != nil {
  824. t.Error(err)
  825. }
  826. }