diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-07-11 19:49:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 19:49:14 +0800 |
commit | 225de7ca0a9e861696a5a43b666090b574c4c769 (patch) | |
tree | 68aff6fb74fece37626ced330fa9c5da91b483a4 /tests/block_test.go | |
parent | bd01cd7183e771984fb9c008e7a7ebf0a0c3f9ba (diff) | |
download | go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.gz go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.bz2 go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.lz go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.xz go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.zst go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.zip |
tests: update tests and implement general state tests (#14734)
Tests are now included as a submodule. This should make updating easier
and removes ~60MB of JSON data from the working copy.
State tests are replaced by General State Tests, which run the same test
with multiple fork configurations.
With the new test runner, consensus tests are run as subtests by walking
json files. Many hex issues have been fixed upstream since the last
update and most custom parsing code is replaced by existing JSON hex
types. Tests can now be marked as 'expected failures', ensuring that
fixes for those tests will trigger an update to test configuration. The
new test runner also supports parallel execution and the -short flag.
Diffstat (limited to 'tests/block_test.go')
-rw-r--r-- | tests/block_test.go | 280 |
1 files changed, 57 insertions, 223 deletions
diff --git a/tests/block_test.go b/tests/block_test.go index d34161017..3245aca7d 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -18,230 +18,64 @@ package tests import ( "math/big" - "path/filepath" "testing" -) - -func TestBcValidBlockTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcUncleHeaderValidityTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcUncleTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcForkUncleTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcInvalidHeaderTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcInvalidRLPTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcRPCAPITests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcForkBlockTests(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcForkStress(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcTotalDifficulty(t *testing.T) { - // skip because these will fail due to selfish mining fix - t.Skip() - - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcWallet(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcGasPricer(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -// TODO: iterate over files once we got more than a few -func TestBcRandom(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestBcMultiChain(t *testing.T) { - // skip due to selfish mining - t.Skip() - - err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} -func TestBcState(t *testing.T) { - err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -// Homestead tests -func TestHomesteadBcValidBlockTests(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcUncleTests(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcInvalidHeaderTests(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcRPCAPITests(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcForkStress(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcTotalDifficulty(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcWallet(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcGasPricer(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcMultiChain(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestHomesteadBcState(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -// DAO hard-fork tests -func TestDAOBcTheDao(t *testing.T) { - err := RunBlockTest(big.NewInt(5), big.NewInt(8), nil, filepath.Join(blockTestDir, "TestNetwork", "bcTheDaoTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} - -func TestEIP150Bc(t *testing.T) { - err := RunBlockTest(big.NewInt(0), big.NewInt(8), big.NewInt(10), filepath.Join(blockTestDir, "TestNetwork", "bcEIP150Test.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} + "github.com/ethereum/go-ethereum/params" +) -func TestHomesteadBcExploit(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcExploitTest.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} -func TestHomesteadBcShanghaiLove(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcShanghaiLove.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } -} -func TestHomesteadBcSuicideIssue(t *testing.T) { - err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcSuicideIssue.json"), BlockSkipTests) - if err != nil { - t.Fatal(err) - } +func TestBlockchain(t *testing.T) { + t.Parallel() + + bt := new(testMatcher) + // General state tests are 'exported' as blockchain tests, but we can run them natively. + bt.skipLoad(`^GeneralStateTests/`) + // Skip random failures due to selfish mining test. + bt.skipLoad(`bcForkUncle\.json/ForkUncle`) + bt.skipLoad(`^bcMultiChainTest\.json/ChainAtoChainB_blockorder`) + bt.skipLoad(`^bcTotalDifficultyTest\.json/(lotsOfLeafs|lotsOfBranches|sideChainWithMoreTransactions)$`) + bt.skipLoad(`^bcMultiChainTest\.json/CallContractFromNotBestBlock`) + // Expected failures: + bt.fails(`(?i)metropolis`, "metropolis is not supported yet") + bt.fails(`^TestNetwork/bcTheDaoTest\.json/(DaoTransactions$|DaoTransactions_UncleExtradata$)`, "issue in test") + + bt.config(`^TestNetwork/`, params.ChainConfig{ + HomesteadBlock: big.NewInt(5), + DAOForkBlock: big.NewInt(8), + DAOForkSupport: true, + EIP150Block: big.NewInt(10), + EIP155Block: big.NewInt(10), + EIP158Block: big.NewInt(14), + // MetropolisBlock: big.NewInt(16), + }) + bt.config(`^RandomTests/.*EIP150`, params.ChainConfig{ + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + }) + bt.config(`^RandomTests/.*EIP158`, params.ChainConfig{ + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + }) + bt.config(`^RandomTests/`, params.ChainConfig{ + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(10), + }) + bt.config(`^Homestead/`, params.ChainConfig{ + HomesteadBlock: big.NewInt(0), + }) + bt.config(`^EIP150/`, params.ChainConfig{ + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + }) + bt.config(`^[^/]+\.json`, params.ChainConfig{ + HomesteadBlock: big.NewInt(1000000), + }) + + bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) { + cfg := bt.findConfig(name) + if err := bt.checkFailure(t, name, test.Run(cfg)); err != nil { + t.Error(err) + } + }) } |