From 33c5186fd06d890e590b18cc6f8479070c2e51e8 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 20 Mar 2015 01:59:38 +0100 Subject: In blocktest cmd, disable network and add RPC flag --- cmd/ethereum/blocktest.go | 15 +++++++++++---- cmd/utils/flags.go | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/blocktest.go b/cmd/ethereum/blocktest.go index e6d701d2c..f2014acfd 100644 --- a/cmd/ethereum/blocktest.go +++ b/cmd/ethereum/blocktest.go @@ -26,10 +26,10 @@ be able to interact with the chain defined by the test. } func runblocktest(ctx *cli.Context) { - if len(ctx.Args()) != 2 { - utils.Fatalf("This command requires two arguments.") + if len(ctx.Args()) != 3 { + utils.Fatalf("Usage: ethereum blocktest {rpc, norpc}") } - file, testname := ctx.Args()[0], ctx.Args()[1] + file, testname, startrpc := ctx.Args()[0], ctx.Args()[1], ctx.Args()[2] bt, err := tests.LoadBlockTests(file) if err != nil { @@ -42,6 +42,7 @@ func runblocktest(ctx *cli.Context) { cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx) cfg.NewDB = func(path string) (common.Database, error) { return ethdb.NewMemDatabase() } + cfg.MaxPeers = 0 // disable network ethereum, err := eth.New(cfg) if err != nil { utils.Fatalf("%v", err) @@ -62,5 +63,11 @@ func runblocktest(ctx *cli.Context) { } else { fmt.Println("Block Test chain loaded, starting ethereum.") } - startEth(ctx, ethereum) + if startrpc == "rpc" { + startEth(ctx, ethereum) + utils.StartRPC(ethereum, ctx) + ethereum.WaitForShutdown() + } else { + startEth(ctx, ethereum) + } } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index f87d25ce9..9a4ab5804 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -256,7 +256,7 @@ func StartRPC(eth *eth.Ethereum, ctx *cli.Context) { addr := ctx.GlobalString(RPCListenAddrFlag.Name) port := ctx.GlobalInt(RPCPortFlag.Name) dataDir := ctx.GlobalString(DataDirFlag.Name) - + fmt.Println("Starting RPC on port: ", port) l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", addr, port)) if err != nil { Fatalf("Can't listen on %s:%d: %v", addr, port, err) -- cgit v1.2.3 From 08bb472c913a2b4cf0838785616b1ec7712d0b00 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 20 Mar 2015 09:10:13 +0100 Subject: Add validation of post state accounts to block tests --- cmd/ethereum/blocktest.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/blocktest.go b/cmd/ethereum/blocktest.go index f2014acfd..b75518138 100644 --- a/cmd/ethereum/blocktest.go +++ b/cmd/ethereum/blocktest.go @@ -52,7 +52,8 @@ func runblocktest(ctx *cli.Context) { ethereum.ResetWithGenesisBlock(test.Genesis) // import pre accounts - if err := test.InsertPreState(ethereum.StateDb()); err != nil { + statedb, err := test.InsertPreState(ethereum.StateDb()) + if err != nil { utils.Fatalf("could not insert genesis accounts: %v", err) } @@ -61,8 +62,14 @@ func runblocktest(ctx *cli.Context) { if err := chain.InsertChain(test.Blocks); err != nil { utils.Fatalf("Block Test load error: %v", err) } else { - fmt.Println("Block Test chain loaded, starting ethereum.") + fmt.Println("Block Test chain loaded") + } + + if err := test.ValidatePostState(statedb); err != nil { + utils.Fatalf("post state validation failed: %v", err) } + fmt.Println("Block Test post state validated, starting ethereum.") + if startrpc == "rpc" { startEth(ctx, ethereum) utils.StartRPC(ethereum, ctx) -- cgit v1.2.3 From 60de4d6dd1403abd4daa142bb2e43cb917fe7b15 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 20 Mar 2015 09:13:17 +0100 Subject: gofmt --- cmd/ethereum/blocktest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ethereum/blocktest.go b/cmd/ethereum/blocktest.go index b75518138..d9cdfa83f 100644 --- a/cmd/ethereum/blocktest.go +++ b/cmd/ethereum/blocktest.go @@ -5,9 +5,9 @@ import ( "github.com/codegangsta/cli" "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/tests" ) -- cgit v1.2.3 From 5d31a475e93807fb1b3a71765fe66138cacd15e7 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Sat, 21 Mar 2015 20:29:12 +0100 Subject: Fix new types for blocktests and comment out non-working log level setter --- cmd/ethtest/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go index f2f7d27f3..fdf573fd8 100644 --- a/cmd/ethtest/main.go +++ b/cmd/ethtest/main.go @@ -219,7 +219,7 @@ func RunVmTest(r io.Reader) (failed int) { } func main() { - helper.Logger.SetLogLevel(5) + //helper.Logger.SetLogLevel(5) vm.Debug = true if len(os.Args) > 1 { -- cgit v1.2.3