Fixed unit test blockchain generation.

This commit is contained in:
Jianping Wu 2019-03-21 10:31:35 -07:00
parent c301a99642
commit 70df11c1a7
4 changed files with 5 additions and 0 deletions

View File

@ -241,6 +241,7 @@ public:
block.nTime = nTime;
block.nBits = nBits;
block.nNonce = nNonce;
block.cnHeader = cnHeader;
block.SetLegacy(legacyMode);
return block;
}

View File

@ -47,6 +47,7 @@ static CBlock BuildBlockTestCase() {
bool mutated;
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
assert(!mutated);
block.cnHeader.major_version = Params().GetConsensus().GetCryptonoteMajorVersion();
block.cnHeader.prev_id = block.GetHash();
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, Params().GetConsensus())) ++block.cnHeader.nonce;
return block;
@ -293,6 +294,7 @@ BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
bool mutated;
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
assert(!mutated);
block.cnHeader.major_version = Params().GetConsensus().GetCryptonoteMajorVersion();
block.cnHeader.prev_id = block.GetHash();
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, Params().GetConsensus())) ++block.cnHeader.nonce;

View File

@ -154,6 +154,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
}
block.cnHeader.major_version = Params().GetConsensus().GetCryptonoteMajorVersion();
block.cnHeader.prev_id = block.GetHash();
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.cnHeader.nonce;

View File

@ -71,6 +71,7 @@ std::shared_ptr<CBlock> FinalizeBlock(std::shared_ptr<CBlock> pblock)
{
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
pblock->cnHeader.major_version = Params().GetConsensus().GetCryptonoteMajorVersion();
pblock->cnHeader.prev_id = pblock->GetHash();
while (!CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus())) {
++(pblock->cnHeader.nonce);