aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-09-23 05:55:31 +0800
committerFelix Lange <fjl@twurst.com>2015-09-23 05:55:31 +0800
commit70b6174748585be2dd4b132203cda8655b76251b (patch)
tree21e438c0023862e331e7c9f5d10568d52faae889
parente56cbc225ee822b6b57056c690ba24201528177d (diff)
downloadgo-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar.gz
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar.bz2
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar.lz
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar.xz
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.tar.zst
go-tangerine-70b6174748585be2dd4b132203cda8655b76251b.zip
cmd/geth, core: make "geth blocktest" work again
The test genesis block was not written properly, block insertion failed immediately. While here, fix the panic when shutting down "geth blocktest" with Ctrl+C. The signal handler is now installed automatically, causing ethereum.Stop to crash because everything is already stopped.
-rw-r--r--cmd/geth/blocktestcmd.go6
-rw-r--r--core/chain_manager.go1
2 files changed, 1 insertions, 6 deletions
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go
index d3257ca4d..d6195e025 100644
--- a/cmd/geth/blocktestcmd.go
+++ b/cmd/geth/blocktestcmd.go
@@ -91,7 +91,6 @@ func runBlockTest(ctx *cli.Context) {
if err != nil {
utils.Fatalf("%v", err)
}
- defer ethereum.Stop()
if rpc {
fmt.Println("Block Test post state validated, starting RPC interface.")
startEth(ctx, ethereum)
@@ -106,7 +105,6 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
cfg.MaxPeers = 0 // disable network
cfg.Shh = false // disable whisper
cfg.NAT = nil // disable port mapping
-
ethereum, err := eth.New(cfg)
if err != nil {
return nil, err
@@ -114,7 +112,6 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
// import the genesis block
ethereum.ResetWithGenesisBlock(test.Genesis)
-
// import pre accounts
_, err = test.InsertPreState(ethereum)
if err != nil {
@@ -122,16 +119,13 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
}
cm := ethereum.ChainManager()
-
validBlocks, err := test.TryBlocksInsert(cm)
if err != nil {
return ethereum, fmt.Errorf("Block Test load error: %v", err)
}
-
newDB := cm.State()
if err := test.ValidatePostState(newDB); err != nil {
return ethereum, fmt.Errorf("post state validation failed: %v", err)
}
-
return ethereum, test.ValidateImportedHeaders(cm, validBlocks)
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 42f70af33..0ad4f86f9 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -279,6 +279,7 @@ func (bc *ChainManager) ResetWithGenesisBlock(genesis *types.Block) {
if err := WriteBlock(bc.chainDb, genesis); err != nil {
glog.Fatalf("failed to write genesis block: %v", err)
}
+ bc.genesisBlock = genesis
bc.insert(bc.genesisBlock)
bc.currentBlock = bc.genesisBlock
bc.setTotalDifficulty(genesis.Difficulty())