diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-03-18 08:48:32 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-03-18 08:50:43 +0100 |
| commit | 73b7eb501e6498e911321131e58ae7fbec6bc5ed (patch) | |
| tree | 3d14528d1bd3b9db17c643958085894c5a497694 /src/test/miner_tests.cpp | |
| parent | Merge #7686: [qt] Remove 0-fee from send dialog (diff) | |
| parent | RPC test for BIP9 warning logic (diff) | |
| download | discoin-73b7eb501e6498e911321131e58ae7fbec6bc5ed.tar.xz discoin-73b7eb501e6498e911321131e58ae7fbec6bc5ed.zip | |
Merge #7575: Minimal BIP9 implementation
8c74ced RPC test for BIP9 warning logic (Suhas Daftuar)
7870deb Test versionbits deployments (Suhas Daftuar)
532cbb2 Add testing of ComputeBlockVersion (Suhas Daftuar)
d23f6c6 Softfork status report in RPC (Pieter Wuille)
732e774 Versionbits tests (Pieter Wuille)
6851107 BIP9 Implementation (Pieter Wuille)
Diffstat (limited to 'src/test/miner_tests.cpp')
| -rw-r--r-- | src/test/miner_tests.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index f3297e074..ab6485081 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -247,13 +247,40 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) // subsidy changing int nHeight = chainActive.Height(); - chainActive.Tip()->nHeight = 209999; + // Create an actual 209999-long block chain (without valid blocks). + while (chainActive.Tip()->nHeight < 209999) { + CBlockIndex* prev = chainActive.Tip(); + CBlockIndex* next = new CBlockIndex(); + next->phashBlock = new uint256(GetRandHash()); + pcoinsTip->SetBestBlock(next->GetBlockHash()); + next->pprev = prev; + next->nHeight = prev->nHeight + 1; + next->BuildSkip(); + chainActive.SetTip(next); + } BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); delete pblocktemplate; - chainActive.Tip()->nHeight = 210000; + // Extend to a 210000-long block chain. + while (chainActive.Tip()->nHeight < 210000) { + CBlockIndex* prev = chainActive.Tip(); + CBlockIndex* next = new CBlockIndex(); + next->phashBlock = new uint256(GetRandHash()); + pcoinsTip->SetBestBlock(next->GetBlockHash()); + next->pprev = prev; + next->nHeight = prev->nHeight + 1; + next->BuildSkip(); + chainActive.SetTip(next); + } BOOST_CHECK(pblocktemplate = CreateNewBlock(chainparams, scriptPubKey)); delete pblocktemplate; - chainActive.Tip()->nHeight = nHeight; + // Delete the dummy blocks again. + while (chainActive.Tip()->nHeight > nHeight) { + CBlockIndex* del = chainActive.Tip(); + chainActive.SetTip(del->pprev); + pcoinsTip->SetBestBlock(del->pprev->GetBlockHash()); + delete del->phashBlock; + delete del; + } // non-final txs in mempool SetMockTime(chainActive.Tip()->GetMedianTimePast()+1); |