diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-11 00:04:56 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-19 04:13:42 +0800 |
commit | a67a15528aa5da902a17d49f5dad19db3975032a (patch) | |
tree | a3239cf5230a0481e85358a43c8e2eaa592f7de1 /tests/block_test.go | |
parent | 7b9fbb088a74de746dc3f0aa76dbbc8985c2b12c (diff) | |
download | dexon-a67a15528aa5da902a17d49f5dad19db3975032a.tar.gz dexon-a67a15528aa5da902a17d49f5dad19db3975032a.tar.zst dexon-a67a15528aa5da902a17d49f5dad19db3975032a.zip |
Split tests from helper code
Diffstat (limited to 'tests/block_test.go')
-rw-r--r-- | tests/block_test.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/tests/block_test.go b/tests/block_test.go index d5136efce..c017b746e 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -1,14 +1,7 @@ package tests import ( - "path/filepath" "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" ) // TODO: refactor test setup & execution to better align with vm and tx tests @@ -50,65 +43,3 @@ func TestBcTotalDifficulty(t *testing.T) { func TestBcWallet(t *testing.T) { runBlockTestsInFile("files/BlockTests/bcWalletTest.json", []string{}, t) } - -func runBlockTestsInFile(filepath string, snafus []string, t *testing.T) { - bt, err := LoadBlockTests(filepath) - if err != nil { - t.Fatal(err) - } - - notWorking := make(map[string]bool, 100) - for _, name := range snafus { - notWorking[name] = true - } - - for name, test := range bt { - if !notWorking[name] { - runBlockTest(name, test, t) - } - } -} - -func runBlockTest(name string, test *BlockTest, t *testing.T) { - 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) - if err != nil { - t.Fatalf("InsertPreState: %v", err) - } - - err = test.TryBlocksInsert(ethereum.ChainManager()) - if err != nil { - t.Fatal(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(filepath.Join(common.DefaultDataDir(), "keystore")) - - return ð.Config{ - DataDir: common.DefaultDataDir(), - Verbosity: 5, - Etherbase: "primary", - AccountManager: accounts.NewManager(ks), - NewDB: func(path string) (common.Database, error) { return ethdb.NewMemDatabase() }, - } -} |