From 18d1569ce50e0348bf9649a31f711ee8037304d8 Mon Sep 17 00:00:00 2001 From: zelig Date: Wed, 25 Mar 2015 11:28:17 +0000 Subject: header check for test --- blockpool/blockpool.go | 6 +++++- blockpool/peers_test.go | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'blockpool') diff --git a/blockpool/blockpool.go b/blockpool/blockpool.go index 46eac3549..d9f8e3baa 100644 --- a/blockpool/blockpool.go +++ b/blockpool/blockpool.go @@ -238,7 +238,11 @@ func (self *BlockPool) Start() { case event := <-self.tdSub.Chan(): if ev, ok := event.(core.ChainHeadEvent); ok { td := ev.Block.Td - plog.DebugDetailf("ChainHeadEvent: height: %v, td: %v, hash: %s", ev.Block.Number(), td, hex(ev.Block.Hash())) + var height *big.Int + if (ev.Block.HeaderHash == common.Hash{}) { + height = ev.Block.Header().Number + } + plog.DebugDetailf("ChainHeadEvent: height: %v, td: %v, hash: %s", height, td, hex(ev.Block.Hash())) self.setTD(td) self.peers.lock.Lock() diff --git a/blockpool/peers_test.go b/blockpool/peers_test.go index beeb0ad1d..62e059337 100644 --- a/blockpool/peers_test.go +++ b/blockpool/peers_test.go @@ -14,7 +14,7 @@ import ( // the actual tests func TestAddPeer(t *testing.T) { test.LogInit() - _, blockPool, blockPoolTester := newTestBlockPool(t) + hashPool, blockPool, blockPoolTester := newTestBlockPool(t) peer0 := blockPoolTester.newPeer("peer0", 1, 1) peer1 := blockPoolTester.newPeer("peer1", 2, 2) peer2 := blockPoolTester.newPeer("peer2", 3, 3) @@ -119,7 +119,8 @@ func TestAddPeer(t *testing.T) { } peer0.waitBlocksRequests(3) - newblock := &types.Block{Td: common.Big3} + hash := hashPool.IndexesToHashes([]int{0})[0] + newblock := &types.Block{Td: common.Big3, HeaderHash: hash} blockPool.chainEvents.Post(core.ChainHeadEvent{newblock}) time.Sleep(100 * time.Millisecond) if blockPool.peers.best != nil { -- cgit v1.2.3