From 137a9c9365dd9ec76d4a4aab7475d716457d00ae Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 19 Mar 2015 23:00:19 +0000 Subject: check and penalise td misreporting - add ErrIncorrectTD - checkTD called after insertChain successful - fix tests, use blockPoolTester.tds to map block index to TD --- blockpool/blockpool_util_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'blockpool/blockpool_util_test.go') diff --git a/blockpool/blockpool_util_test.go b/blockpool/blockpool_util_test.go index a17bc584e..f4e5fec2f 100644 --- a/blockpool/blockpool_util_test.go +++ b/blockpool/blockpool_util_test.go @@ -40,6 +40,7 @@ type blockPoolTester struct { blockPool *BlockPool t *testing.T chainEvents *event.TypeMux + tds map[int]int } func newTestBlockPool(t *testing.T) (hashPool *test.TestHashPool, blockPool *BlockPool, b *blockPoolTester) { @@ -84,6 +85,14 @@ func (self *blockPoolTester) insertChain(blocks types.Blocks) error { var ok bool for _, block := range blocks { child = self.hashPool.HashesToIndexes([]common.Hash{block.Hash()})[0] + var td int + if self.tds != nil { + td, ok = self.tds[child] + } + if !ok { + td = child + } + block.Td = big.NewInt(int64(td)) _, ok = self.blockChain[child] if ok { fmt.Printf("block %v already in blockchain\n", child) -- cgit v1.2.3