Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
Show First 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
// Subsidy changing. | // Subsidy changing. | ||||
int nHeight = chainActive.Height(); | int nHeight = chainActive.Height(); | ||||
// Create an actual 209999-long block chain (without valid blocks). | // Create an actual 209999-long block chain (without valid blocks). | ||||
while (chainActive.Tip()->nHeight < 209999) { | while (chainActive.Tip()->nHeight < 209999) { | ||||
CBlockIndex *prev = chainActive.Tip(); | CBlockIndex *prev = chainActive.Tip(); | ||||
CBlockIndex *next = new CBlockIndex(); | CBlockIndex *next = new CBlockIndex(); | ||||
next->phashBlock = new uint256(InsecureRand256()); | next->phashBlock = new BlockHash(InsecureRand256()); | ||||
pcoinsTip->SetBestBlock(next->GetBlockHash()); | pcoinsTip->SetBestBlock(next->GetBlockHash()); | ||||
next->pprev = prev; | next->pprev = prev; | ||||
next->nHeight = prev->nHeight + 1; | next->nHeight = prev->nHeight + 1; | ||||
next->BuildSkip(); | next->BuildSkip(); | ||||
chainActive.SetTip(next); | chainActive.SetTip(next); | ||||
} | } | ||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) | BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) | ||||
.CreateNewBlock(scriptPubKey)); | .CreateNewBlock(scriptPubKey)); | ||||
// Extend to a 210000-long block chain. | // Extend to a 210000-long block chain. | ||||
while (chainActive.Tip()->nHeight < 210000) { | while (chainActive.Tip()->nHeight < 210000) { | ||||
CBlockIndex *prev = chainActive.Tip(); | CBlockIndex *prev = chainActive.Tip(); | ||||
CBlockIndex *next = new CBlockIndex(); | CBlockIndex *next = new CBlockIndex(); | ||||
next->phashBlock = new uint256(InsecureRand256()); | next->phashBlock = new BlockHash(InsecureRand256()); | ||||
pcoinsTip->SetBestBlock(next->GetBlockHash()); | pcoinsTip->SetBestBlock(next->GetBlockHash()); | ||||
next->pprev = prev; | next->pprev = prev; | ||||
next->nHeight = prev->nHeight + 1; | next->nHeight = prev->nHeight + 1; | ||||
next->BuildSkip(); | next->BuildSkip(); | ||||
chainActive.SetTip(next); | chainActive.SetTip(next); | ||||
} | } | ||||
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) | BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) | ||||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |