From 27c42ea93488790d1c509c3ee6f187a1edab7e0a Mon Sep 17 00:00:00 2001
From: Gustav Simonsson <gustav.simonsson@gmail.com>
Date: Fri, 6 Mar 2015 03:25:57 +0100
Subject: Add empty total difficulty to test blocks and clean up stopping the
 node

---
 cmd/blocktest/main.go | 14 +++++++++++---
 cmd/utils/cmd.go      |  9 +++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

(limited to 'cmd')

diff --git a/cmd/blocktest/main.go b/cmd/blocktest/main.go
index 4a05b8bee..579aa850a 100644
--- a/cmd/blocktest/main.go
+++ b/cmd/blocktest/main.go
@@ -168,7 +168,7 @@ func main() {
 		logger.Flush()
 	}()
 
-	utils.HandleInterrupt()
+	//utils.HandleInterrupt()
 
 	utils.InitConfig(VmType, ConfigFile, Datadir, "ethblocktest")
 
@@ -190,12 +190,17 @@ func main() {
 		MinerThreads: MinerThreads,
 	})
 
+	utils.StartEthereumForTest(ethereum)
 	utils.StartRpc(ethereum, RpcListenAddress, RpcPort)
-	utils.StartEthereum(ethereum)
 
 	ethereum.ChainManager().ResetWithGenesisBlock(blocks[0])
+	// bph := ethereum.ChainManager().GetBlock(blocks[1].Header().ParentHash)
+	// fmt.Println("bph: ", bph)
 
-	// fmt.Println("HURR: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
+	//fmt.Println("b0: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
+	//fmt.Println("b0: ", hex.EncodeToString(blocks[0].Hash()))
+	//fmt.Println("b1: ", hex.EncodeToString(ethutil.Encode(blocks[1].RlpData())))
+	//fmt.Println("b1: ", hex.EncodeToString(blocks[1].Hash()))
 
 	go ethereum.ChainManager().InsertChain(types.Blocks{blocks[1]})
 	fmt.Println("OK! ")
@@ -254,6 +259,9 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
 	}
 
 	gb := types.NewBlockWithHeader(gbh)
+	//gb.uncles = *new([]*types.Header)
+	//gb.transactions = *new(types.Transactions)
+	gb.Td = new(big.Int)
 	gb.Reward = new(big.Int)
 
 	testBlock := new(types.Block)
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index a77c6ad4d..3823ec75a 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -134,6 +134,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
 	})
 }
 
+func StartEthereumForTest(ethereum *eth.Ethereum) {
+	clilogger.Infoln("Starting ", ethereum.Name())
+	ethereum.StartForTest()
+	RegisterInterrupt(func(sig os.Signal) {
+		ethereum.Stop()
+		logger.Flush()
+	})
+}
+
 func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) {
 	var err error
 	switch {
-- 
cgit v1.2.3