diff options
author | Felix Lange <fjl@twurst.com> | 2015-04-22 17:53:02 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-04-22 17:53:02 +0800 |
commit | 2f4cc72119847775d3edd5e9e74075aa9297896f (patch) | |
tree | 863bdb28565c3d85a2aad40db78aaabffd36cd28 /cmd | |
parent | 15550dc8c54d217739dbff312c0a7b4b8d581e75 (diff) | |
parent | b448390889685fc87f221c152b16b82849f7797f (diff) | |
download | dexon-2f4cc72119847775d3edd5e9e74075aa9297896f.tar.gz dexon-2f4cc72119847775d3edd5e9e74075aa9297896f.tar.zst dexon-2f4cc72119847775d3edd5e9e74075aa9297896f.zip |
Merge pull request #765 from Gustav-Simonsson/more_block_test_improvements
Further fixes to block test wrapper
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/block_go_test.go | 80 | ||||
-rw-r--r-- | cmd/geth/blocktest.go | 6 |
2 files changed, 3 insertions, 83 deletions
diff --git a/cmd/geth/block_go_test.go b/cmd/geth/block_go_test.go deleted file mode 100644 index 1980e4798..000000000 --- a/cmd/geth/block_go_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package main - -import ( - "path" - "testing" - - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/tests" -) - -// TODO: refactor test setup & execution to better align with vm and tx tests -// TODO: refactor to avoid duplication with cmd/geth/blocktest.go -func TestBcValidBlockTests(t *testing.T) { - runBlockTestsInFile("../../tests/files/BlockTests/bcValidBlockTest.json", t) -} - -/* -func TestBcUncleTests(t *testing.T) { - runBlockTestsInFile("../../tests/files/BlockTests/bcUncleTest.json", t) -} -*/ - -func runBlockTestsInFile(filepath string, t *testing.T) { - bt, err := tests.LoadBlockTests(filepath) - if err != nil { - t.Fatal(err) - } - for name, test := range bt { - runTest(name, test, t) - } -} - -func runTest(name string, test *tests.BlockTest, t *testing.T) { - t.Log("Running test: ", name) - cfg := testEthConfig() - ethereum, err := eth.New(cfg) - if err != nil { - t.Fatalf("%v", err) - } - - err = ethereum.Start() - if err != nil { - t.Fatalf("%v", err) - } - - // import the genesis block - ethereum.ResetWithGenesisBlock(test.Genesis) - - // import pre accounts - statedb, err := test.InsertPreState(ethereum.StateDb()) - if err != nil { - t.Fatalf("InsertPreState: %v", err) - } - - // insert the test blocks, which will execute all transactions - if err := test.InsertBlocks(ethereum.ChainManager()); err != nil { - t.Fatalf("Block Test load error: %v %T", err, err) - } - - if err := test.ValidatePostState(statedb); err != nil { - t.Fatal("post state validation failed: %v", err) - } - t.Log("Test passed: ", name) -} - -func testEthConfig() *eth.Config { - ks := crypto.NewKeyStorePassphrase(path.Join(common.DefaultDataDir(), "keys")) - - return ð.Config{ - DataDir: common.DefaultDataDir(), - LogLevel: 5, - Etherbase: "primary", - AccountManager: accounts.NewManager(ks), - NewDB: func(path string) (common.Database, error) { return ethdb.NewMemDatabase() }, - } -} diff --git a/cmd/geth/blocktest.go b/cmd/geth/blocktest.go index 792981ec0..343a0bf28 100644 --- a/cmd/geth/blocktest.go +++ b/cmd/geth/blocktest.go @@ -109,10 +109,10 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er return ethereum, fmt.Errorf("InsertPreState: %v", err) } - // insert the test blocks, which will execute all transactions - if err := test.InsertBlocks(ethereum.ChainManager()); err != nil { - return ethereum, fmt.Errorf("Block Test load error: %v %T", err, err) + if err := test.TryBlocksInsert(ethereum.ChainManager()); err != nil { + return ethereum, fmt.Errorf("Block Test load error: %v", err) } + fmt.Println("chain loaded") if err := test.ValidatePostState(statedb); err != nil { return ethereum, fmt.Errorf("post state validation failed: %v", err) |