aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-03-10 19:07:34 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-03-10 19:07:34 +0800
commit0542df941f57a75fa7b699089db1d9ae40e4ff71 (patch)
tree8e1c51b0000102abb8f61b6a1e171f8843b711e6
parent56524d13b5113751539fe0a86a0a88fc4c45d2af (diff)
parent27c42ea93488790d1c509c3ee6f187a1edab7e0a (diff)
downloaddexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar.gz
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar.bz2
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar.lz
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar.xz
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.tar.zst
dexon-0542df941f57a75fa7b699089db1d9ae40e4ff71.zip
Merge pull request #449 from Gustav-Simonsson/add_blockchain_tests2
Add empty total difficulty to test blocks and clean up stopping the node
-rw-r--r--cmd/blocktest/main.go14
-rw-r--r--cmd/utils/cmd.go9
-rw-r--r--eth/backend.go11
3 files changed, 31 insertions, 3 deletions
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 4188802ac..a7e609af7 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -133,6 +133,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 {
diff --git a/eth/backend.go b/eth/backend.go
index 584d60c7e..f42ceda69 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -275,6 +275,17 @@ func (s *Ethereum) Start() error {
return nil
}
+func (s *Ethereum) StartForTest() {
+ jsonlogger.LogJson(&logger.LogStarting{
+ ClientString: s.net.Name,
+ ProtocolVersion: ProtocolVersion,
+ })
+
+ // Start services
+ s.txPool.Start()
+ s.blockPool.Start()
+}
+
func (self *Ethereum) SuggestPeer(nodeURL string) error {
n, err := discover.ParseNode(nodeURL)
if err != nil {