diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-20 20:32:33 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-20 20:32:33 +0800 |
commit | 9c69c051ba010e2323d665d2ef273773f9dd7aa3 (patch) | |
tree | e0d705729778ad60b70c6b3de9d0c3d22f9a0fa7 /tests/block_test.go | |
parent | 53e042f0c47242afa3e13cfebb35becdacdc69c0 (diff) | |
parent | d1e589289c56140144241a245e1756dbdc7280a0 (diff) | |
download | go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar.gz go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar.bz2 go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar.lz go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar.xz go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.tar.zst go-tangerine-9c69c051ba010e2323d665d2ef273773f9dd7aa3.zip |
Merge pull request #1236 from tgerring/ethtest
ethtest improvements
Diffstat (limited to 'tests/block_test.go')
-rw-r--r-- | tests/block_test.go | 111 |
1 files changed, 35 insertions, 76 deletions
diff --git a/tests/block_test.go b/tests/block_test.go index d5136efce..bdf983786 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -3,112 +3,71 @@ 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 func TestBcValidBlockTests(t *testing.T) { - // SimpleTx3 genesis block does not validate against calculated state root - // as of 2015-06-09. unskip once working /Gustav - runBlockTestsInFile("files/BlockTests/bcValidBlockTest.json", []string{"SimpleTx3"}, t) + err := RunBlockTest(filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests) + if err != nil { + t.Fatal(err) + } } func TestBcUncleTests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcUncleTest.json", []string{}, t) - runBlockTestsInFile("files/BlockTests/bcBruncleTest.json", []string{}, t) + err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests) + if err != nil { + t.Fatal(err) + } + err = RunBlockTest(filepath.Join(blockTestDir, "bcBruncleTest.json"), BlockSkipTests) + if err != nil { + t.Fatal(err) + } } func TestBcUncleHeaderValidityTests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcUncleHeaderValiditiy.json", []string{}, t) + err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests) + if err != nil { + t.Fatal(err) + } } func TestBcInvalidHeaderTests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcInvalidHeaderTest.json", []string{}, t) -} - -func TestBcInvalidRLPTests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcInvalidRLPTest.json", []string{}, t) -} - -func TestBcRPCAPITests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcRPC_API_Test.json", []string{}, t) -} - -func TestBcForkBlockTests(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcForkBlockTest.json", []string{}, t) -} - -func TestBcTotalDifficulty(t *testing.T) { - runBlockTestsInFile("files/BlockTests/bcTotalDifficultyTest.json", []string{}, 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) + err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests) 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) +func TestBcInvalidRLPTests(t *testing.T) { + err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests) if err != nil { - t.Fatalf("%v", err) + t.Fatal(err) } +} - err = ethereum.Start() +func TestBcRPCAPITests(t *testing.T) { + err := RunBlockTest(filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests) if err != nil { - t.Fatalf("%v", err) + t.Fatal(err) } +} - // import the genesis block - ethereum.ResetWithGenesisBlock(test.Genesis) - - // import pre accounts - statedb, err := test.InsertPreState(ethereum) +func TestBcForkBlockTests(t *testing.T) { + err := RunBlockTest(filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests) if err != nil { - t.Fatalf("InsertPreState: %v", err) + t.Fatal(err) } +} - err = test.TryBlocksInsert(ethereum.ChainManager()) +func TestBcTotalDifficulty(t *testing.T) { + err := RunBlockTest(filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests) 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() }, +func TestBcWallet(t *testing.T) { + err := RunBlockTest(filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests) + if err != nil { + t.Fatal(err) } } |