diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -35,7 +35,8 @@ parentOfAll.vout.emplace_back(10 * SATOSHI, CScript() << OP_TRUE); } TxId parentOfAllId = parentOfAll.GetId(); - testPool.addUnchecked(parentOfAllId, entry.FromTx(parentOfAll)); + testPool.addUnchecked(parentOfAllId, + entry.SigOpCount(0).FromTx(parentOfAll)); // Add some outpoints to the tracking vector for (size_t i = 0; i < maxOutputs; i++) { @@ -44,6 +45,7 @@ Amount totalFee = Amount::zero(); size_t totalSize = CTransaction(parentOfAll).GetTotalSize(); + int64_t totalSigOpCount = 0; // Generate 100 transactions for (size_t totalTransactions = 0; totalTransactions < 100; @@ -56,6 +58,8 @@ Amount maxFees = Amount::zero(); uint64_t minSize = std::numeric_limits::max(); uint64_t maxSize = 0; + int64_t minSigOpCount = std::numeric_limits::max(); + int64_t maxSigOpCount = 0; // Consume random inputs, but make sure we don't consume more than // available for (size_t input = std::min(InsecureRandRange(maxOutputs) + 1, @@ -80,6 +84,9 @@ maxFees += parent.GetModFeesWithAncestors(); minSize = std::min(minSize, parent.GetSizeWithAncestors()); maxSize += parent.GetSizeWithAncestors(); + minSigOpCount = + std::min(minSigOpCount, parent.GetSigOpCountWithAncestors()); + maxSigOpCount += parent.GetSigOpCountWithAncestors(); } // Produce random number of outputs @@ -96,8 +103,10 @@ } Amount randFee = int64_t(InsecureRandRange(300)) * SATOSHI; + int randSigOpCount = InsecureRandRange(5); - testPool.addUnchecked(curId, entry.Fee(randFee).FromTx(tx)); + testPool.addUnchecked( + curId, entry.Fee(randFee).SigOpCount(randSigOpCount).FromTx(tx)); // Add this transaction to the totals. minAncestors += 1; @@ -106,10 +115,13 @@ maxFees += randFee; minSize += CTransaction(tx).GetTotalSize(); maxSize += CTransaction(tx).GetTotalSize(); + minSigOpCount += randSigOpCount; + maxSigOpCount += randSigOpCount; // Calculate overall values totalFee += randFee; totalSize += CTransaction(tx).GetTotalSize(); + totalSigOpCount += randSigOpCount; CTxMemPoolEntry parentEntry = *testPool.mapTx.find(parentOfAllId); CTxMemPoolEntry latestEntry = *testPool.mapTx.find(curId); @@ -120,6 +132,9 @@ BOOST_CHECK(latestEntry.GetSizeWithAncestors() >= minSize); BOOST_CHECK(latestEntry.GetSizeWithAncestors() <= maxSize); + BOOST_CHECK(latestEntry.GetSigOpCountWithAncestors() >= minSigOpCount); + BOOST_CHECK(latestEntry.GetSigOpCountWithAncestors() <= maxSigOpCount); + BOOST_CHECK(latestEntry.GetModFeesWithAncestors() >= minFees); BOOST_CHECK(latestEntry.GetModFeesWithAncestors() <= maxFees);