diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-20 07:00:19 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-03-20 18:41:41 +0800 |
commit | 137a9c9365dd9ec76d4a4aab7475d716457d00ae (patch) | |
tree | bbd282f06b0559c53f9fe3ae7c7beb74e0cfe592 /blockpool/blockpool_util_test.go | |
parent | a9926a289dd21bcfd8e2def8f4005b43b728cb3d (diff) | |
download | go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.gz go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.bz2 go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.lz go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.xz go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.zst go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.zip |
check and penalise td misreporting
- add ErrIncorrectTD
- checkTD called after insertChain successful
- fix tests, use blockPoolTester.tds to map block index to TD
Diffstat (limited to 'blockpool/blockpool_util_test.go')
-rw-r--r-- | blockpool/blockpool_util_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
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) |