diff options
author | Felix Lange <fjl@twurst.com> | 2015-12-17 21:13:30 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-12-18 19:09:10 +0800 |
commit | 9be5d5cd90517244b239c6af4e602d898fafeaf7 (patch) | |
tree | 1c5b5ce8b26e2b5cbb399cd9d03e19e3307e9f6d /core/chain_makers.go | |
parent | 2baf1de00df56dee47161ad763788a92693b9c29 (diff) | |
download | go-tangerine-9be5d5cd90517244b239c6af4e602d898fafeaf7.tar.gz go-tangerine-9be5d5cd90517244b239c6af4e602d898fafeaf7.tar.zst go-tangerine-9be5d5cd90517244b239c6af4e602d898fafeaf7.zip |
eth/downloader: fix negative balance issue in tests
The test chain generated by makeChainFork included invalid uncle
headers, crashing the generator during the state commit.
The headers were invalid because they used the iteration counter as the
block number, even though makeChainFork uses a block with number > 0 as
the parent. Fix this by introducing BlockGen.Number, which allows
accessing the actual number of the block being generated.
Diffstat (limited to 'core/chain_makers.go')
-rw-r--r-- | core/chain_makers.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/chain_makers.go b/core/chain_makers.go index 4f6fa3989..5a8f380a3 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -104,6 +104,11 @@ func (b *BlockGen) AddTx(tx *types.Transaction) { b.receipts = append(b.receipts, receipt) } +// Number returns the block number of the block being generated. +func (b *BlockGen) Number() *big.Int { + return new(big.Int).Set(b.header.Number) +} + // AddUncheckedReceipts forcefully adds a receipts to the block without a // backing transaction. // |