Skip to content

Commit

Permalink
Merge pull request digibyte#30 from SmartArray/tests/txindex_tests
Browse files Browse the repository at this point in the history
test: correct txindex_tests
  • Loading branch information
gto90 authored Apr 7, 2021
2 parents 1cc3eca + 9c9d1c1 commit 1855d90
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/test/test_digibyte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
{
// Generate a 100-block chain:
coinbaseKey.MakeNewKey(true);
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
for (int i = 0; i < COINBASE_MATURITY; i++)
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
for (int i = 0; i < COINBASE_MATURITY_2; i++)
{
std::vector<CMutableTransaction> noTxns;
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);
Expand All @@ -145,7 +145,7 @@ CBlock
TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns, const CScript& scriptPubKey)
{
const CChainParams& chainparams = Params();
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, 2, true);
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, ALGO_SCRYPT, true);
CBlock& block = pblocktemplate->block;

// Replace mempool-selected txns with just coinbase plus passed-in txns:
Expand All @@ -159,10 +159,12 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
}

while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
while (!CheckProofOfWork(GetPoWAlgoHash(block), block.nBits, chainparams.GetConsensus())) ++block.nNonce;

std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
ProcessNewBlock(chainparams, shared_pblock, true, nullptr);
if (!ProcessNewBlock(chainparams, shared_pblock, true, nullptr)) {
throw new std::runtime_error("Could not process new test block");
}

CBlock result = block;
return result;
Expand Down

0 comments on commit 1855d90

Please sign in to comment.