55
66 "github.com/codegangsta/cli"
77 "github.com/ethereum/go-ethereum/cmd/utils"
8+ "github.com/ethereum/go-ethereum/common"
89 "github.com/ethereum/go-ethereum/eth"
910 "github.com/ethereum/go-ethereum/ethdb"
10- "github.com/ethereum/go-ethereum/common"
1111 "github.com/ethereum/go-ethereum/tests"
1212)
1313
@@ -26,10 +26,10 @@ be able to interact with the chain defined by the test.
2626}
2727
2828func runblocktest (ctx * cli.Context ) {
29- if len (ctx .Args ()) != 2 {
30- utils .Fatalf ("This command requires two arguments. " )
29+ if len (ctx .Args ()) != 3 {
30+ utils .Fatalf ("Usage: ethereum blocktest <path-to-test-file> <test-name> {rpc, norpc} " )
3131 }
32- file , testname := ctx .Args ()[0 ], ctx .Args ()[1 ]
32+ file , testname , startrpc := ctx .Args ()[0 ], ctx .Args ()[1 ], ctx . Args ()[ 2 ]
3333
3434 bt , err := tests .LoadBlockTests (file )
3535 if err != nil {
@@ -42,6 +42,7 @@ func runblocktest(ctx *cli.Context) {
4242
4343 cfg := utils .MakeEthConfig (ClientIdentifier , Version , ctx )
4444 cfg .NewDB = func (path string ) (common.Database , error ) { return ethdb .NewMemDatabase () }
45+ cfg .MaxPeers = 0 // disable network
4546 ethereum , err := eth .New (cfg )
4647 if err != nil {
4748 utils .Fatalf ("%v" , err )
@@ -51,7 +52,8 @@ func runblocktest(ctx *cli.Context) {
5152 ethereum .ResetWithGenesisBlock (test .Genesis )
5253
5354 // import pre accounts
54- if err := test .InsertPreState (ethereum .StateDb ()); err != nil {
55+ statedb , err := test .InsertPreState (ethereum .StateDb ())
56+ if err != nil {
5557 utils .Fatalf ("could not insert genesis accounts: %v" , err )
5658 }
5759
@@ -60,7 +62,19 @@ func runblocktest(ctx *cli.Context) {
6062 if err := chain .InsertChain (test .Blocks ); err != nil {
6163 utils .Fatalf ("Block Test load error: %v" , err )
6264 } else {
63- fmt .Println ("Block Test chain loaded, starting ethereum." )
65+ fmt .Println ("Block Test chain loaded" )
66+ }
67+
68+ if err := test .ValidatePostState (statedb ); err != nil {
69+ utils .Fatalf ("post state validation failed: %v" , err )
70+ }
71+ fmt .Println ("Block Test post state validated, starting ethereum." )
72+
73+ if startrpc == "rpc" {
74+ startEth (ctx , ethereum )
75+ utils .StartRPC (ethereum , ctx )
76+ ethereum .WaitForShutdown ()
77+ } else {
78+ startEth (ctx , ethereum )
6479 }
65- startEth (ctx , ethereum )
6680}
0 commit comments