From cd566266470d7b2b8f3c06b3079ba7a136d30a3a Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Tue, 19 Mar 2019 20:48:42 +0000 Subject: [PATCH] [BROKEN] Adapt existing unit tests to CA --- src/test/blockfilter_tests.cpp | 19 ++++++++-------- src/test/checkqueue_tests.cpp | 34 ++++++++++++++++------------ src/test/coins_tests.cpp | 4 ++-- src/test/miner_tests.cpp | 12 +++++----- src/test/pegin_witness_tests.cpp | 29 ++++++++++++------------ src/test/script_tests.cpp | 8 +++++-- src/test/test_bitcoin.cpp | 12 ++++++++++ src/test/transaction_tests.cpp | 6 ++--- src/test/txvalidationcache_tests.cpp | 11 +++++---- 9 files changed, 77 insertions(+), 58 deletions(-) diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp index 773de343eaefc..6fa06a1852079 100644 --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -61,13 +62,13 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test) excluded_scripts[1] << std::vector(5, 33) << OP_CHECKSIG; CMutableTransaction tx_1; - tx_1.vout.emplace_back(100, included_scripts[0]); - tx_1.vout.emplace_back(200, included_scripts[1]); + tx_1.vout.emplace_back(CTxOut(CAsset(), 100, included_scripts[0])); + tx_1.vout.emplace_back(CTxOut(CAsset(), 200, included_scripts[1])); CMutableTransaction tx_2; - tx_2.vout.emplace_back(300, included_scripts[2]); - tx_2.vout.emplace_back(0, excluded_scripts[0]); - tx_2.vout.emplace_back(400, excluded_scripts[2]); // Script is empty + tx_2.vout.emplace_back(CTxOut(CAsset(), 300, included_scripts[2])); + tx_2.vout.emplace_back(CTxOut(CAsset(), 0, excluded_scripts[0])); + tx_2.vout.emplace_back(CTxOut(CAsset(), 400, excluded_scripts[2])); // Script is empty CBlock block; block.vtx.push_back(MakeTransactionRef(tx_1)); @@ -75,9 +76,9 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test) CBlockUndo block_undo; block_undo.vtxundo.emplace_back(); - block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(500, included_scripts[3]), 1000, true); - block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(600, included_scripts[4]), 10000, false); - block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(700, excluded_scripts[2]), 100000, false); + block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(CAsset(), 500, included_scripts[3]), 1000, true); + block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(CAsset(), 600, included_scripts[4]), 10000, false); + block_undo.vtxundo.back().vprevout.emplace_back(CTxOut(CAsset(), 700, excluded_scripts[2]), 100000, false); BlockFilter block_filter(BlockFilterType::BASIC, block, block_undo); const GCSFilter& filter = block_filter.GetFilter(); @@ -125,7 +126,7 @@ BOOST_AUTO_TEST_CASE(blockfilters_json_test) const UniValue& prev_scripts = test[pos++].get_array(); for (unsigned int ii = 0; ii < prev_scripts.size(); ii++) { std::vector raw_script = ParseHex(prev_scripts[ii].get_str()); - CTxOut txout(0, CScript(raw_script.begin(), raw_script.end())); + CTxOut txout(CAsset(), 0, CScript(raw_script.begin(), raw_script.end())); tx_undo.vprevout.emplace_back(txout, 0, false); } diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp index 2732598b4f434..69590aab43132 100644 --- a/src/test/checkqueue_tests.cpp +++ b/src/test/checkqueue_tests.cpp @@ -154,7 +154,7 @@ static void Correct_Queue_range(std::vector range) tg.create_thread([&]{small_queue->Thread();}); } // Make vChecks here to save on malloc (this test can be slow...) - std::vector vChecks; + std::vector vChecks; for (const size_t i : range) { size_t total = i; FakeCheckCheckCompletion::n_calls = 0; @@ -226,10 +226,10 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure) while (remaining) { size_t r = InsecureRandRange(10); - std::vector vChecks; - vChecks.reserve(r); - for (size_t k = 0; k < r && remaining; k++, remaining--) - vChecks.emplace_back(remaining == 1); + std::vector vChecks; + for (size_t k = 0; k < r && remaining; k++, remaining--) { + vChecks.push_back(new FailingCheck(remaining == 1)); + } control.Add(vChecks); } bool success = control.Wait(); @@ -256,9 +256,11 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure) for (const bool end_fails : {true, false}) { CCheckQueueControl control(fail_queue.get()); { - std::vector vChecks; - vChecks.resize(100, false); - vChecks[99] = end_fails; + std::vector vChecks; + for (size_t i = 0; i < 100; i++) { + vChecks.push_back(new FailingCheck(false)); + } + vChecks[99] = new FailingCheck(end_fails); control.Add(vChecks); } bool r =control.Wait(); @@ -287,9 +289,10 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck) CCheckQueueControl control(queue.get()); while (total) { size_t r = InsecureRandRange(10); - std::vector vChecks; - for (size_t k = 0; k < r && total; k++) - vChecks.emplace_back(--total); + std::vector vChecks; + for (size_t k = 0; k < r && total; k++) { + vChecks.emplace_back(new UniqueCheck(--total)); + } control.Add(vChecks); } } @@ -321,12 +324,12 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory) CCheckQueueControl control(queue.get()); while (total) { size_t r = InsecureRandRange(10); - std::vector vChecks; + std::vector vChecks; for (size_t k = 0; k < r && total; k++) { total--; // Each iteration leaves data at the front, back, and middle // to catch any sort of deallocation failure - vChecks.emplace_back(total == 0 || total == i || total == i/2); + vChecks.emplace_back(new MemoryCheck(total == 0 || total == i || total == i/2)); } control.Add(vChecks); } @@ -349,11 +352,12 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup) } std::thread t0([&]() { CCheckQueueControl control(queue.get()); - std::vector vChecks(1); + std::vector vChecks; // Freezing can't be the default initialized behavior given how the queue // swaps in default initialized Checks (otherwise freezing destructor // would get called twice). - vChecks[0].should_freeze = true; + vChecks.push_back(new FrozenCleanupCheck()); + vChecks[0]->should_freeze = true; control.Add(vChecks); control.Wait(); // Hangs here }); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 61f325dbf6633..a4ae89805707a 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -499,7 +499,7 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization) ss3 >> cc3; BOOST_CHECK_EQUAL(cc3.fCoinBase, false); BOOST_CHECK_EQUAL(cc3.nHeight, 0U); - BOOST_CHECK_EQUAL(cc3.out.nValue, 0); + BOOST_CHECK_EQUAL(cc3.out.nValue.GetAmount(), 0); BOOST_CHECK_EQUAL(cc3.out.scriptPubKey.size(), 0U); // scriptPubKey that ends beyond the end of the stream @@ -577,7 +577,7 @@ void GetCoinsMapEntry(const CCoinsMap& map, CAmount& value, char& flags) if (it->second.coin.IsSpent()) { value = PRUNED; } else { - value = it->second.coin.out.nValue; + value = it->second.coin.out.nValue.GetAmount(); } flags = it->second.flags; assert(flags != NO_ENTRY); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index eff31b0f0d343..6b2efb4d3db52 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -160,7 +160,7 @@ static void TestPackageSelection(const CChainParams& chainparams, const CScript& // of the transactions is below the min relay fee // Remove the low fee transaction and replace with a higher fee transaction mempool.removeRecursive(tx); - tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() - 2; // Now we should be just over the min relay fee hashLowFeeTx = tx.GetHash(); mempool.addUnchecked(entry.Fee(feeToUse+2).FromTx(tx)); pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey); @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 1001; ++i) { - tx.vout[0].nValue -= LOWFEE; + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() - LOWFEE; hash = tx.GetHash(); bool spendsCoinbase = i == 0; // only first tx spends coinbase // If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails @@ -288,7 +288,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 1001; ++i) { - tx.vout[0].nValue -= LOWFEE; + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() - LOWFEE; hash = tx.GetHash(); bool spendsCoinbase = i == 0; // only first tx spends coinbase // If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes @@ -309,7 +309,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 128; ++i) { - tx.vout[0].nValue -= LOWFEE; + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() - LOWFEE; hash = tx.GetHash(); bool spendsCoinbase = i == 0; // only first tx spends coinbase mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); @@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vin[1].scriptSig = CScript() << OP_1; tx.vin[1].prevout.hash = txFirst[0]->GetHash(); tx.vin[1].prevout.n = 0; - tx.vout[0].nValue = tx.vout[0].nValue+BLOCKSUBSIDY-HIGHERFEE; //First txn output + fresh coinbase - new txn fee + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() + BLOCKSUBSIDY - HIGHERFEE; //First txn output + fresh coinbase - new txn fee hash = tx.GetHash(); mempool.addUnchecked(entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey)); @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vin[0].prevout.hash = hash; tx.vin[0].scriptSig = CScript() << std::vector(script.begin(), script.end()); - tx.vout[0].nValue -= LOWFEE; + tx.vout[0].nValue = tx.vout[0].nValue.GetAmount() - LOWFEE; hash = tx.GetHash(); mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); // Should throw block-validation-failed diff --git a/src/test/pegin_witness_tests.cpp b/src/test/pegin_witness_tests.cpp index 7e29205c1291c..ea76bbc64fc89 100644 --- a/src/test/pegin_witness_tests.cpp +++ b/src/test/pegin_witness_tests.cpp @@ -25,16 +25,14 @@ std::vector > witness_stack = { ParseHex("00ca9a3b00000000"), - ParseHex("e48a1a02a8f799892fda58347c2d794144311d4307dbfd10f77ffe28088c60be"), + ParseHex("ef4699c160d014d5ff79636d8a4cb990b9df4ebab649f144d19f5c495c585e47"), ParseHex("06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f"), ParseHex("00141eef6361cd1507a303834285d1521d6baf1b19ae"), ParseHex("0200000001b399292c8100b8a1b66eb23896f799c1712390d560af0f70e81acd2d17a3b06e0000000049483045022100c3c749623486ea57ea93dfaf78d85590d78c7590a25768fe80f0ea4d6047419002202a0a00a90392b86c53c0fdda908c4591ba28040c16c25734c23b7df3c8b70acd01feffffff0228196bee000000001976a914470dd41542ee1a1bd75f1a838878648c8d65622488ac00ca9a3b0000000017a914cb60b1d7f76ba12b45a116c482c165a74c5d7e388765000000"), ParseHex("000000205e3913a320cd2e3a2efa141e47419f54cb9e82320cf8dbc812fc19b9a1b2413a57f5e9fb4fa22de191454a241387f5d10cc794ee0fbf72ae2841baf3129a4eab8133025affff7f20000000000200000002f9d0be670007d38fceece999cb6144658a99c307ccc37f6d8f69129ed0f4545ff321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce0105") }; -//std::vector pegin_transaction = ParseHex("020000000101f321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce0100004000ffffffff0201e48a1a02a8f799892fda58347c2d794144311d4307dbfd10f77ffe28088c60be01000000003b9ab2e0001976a914809326f7628dc976fbe63806479a1b8dfcc8c4b988ac01e48a1a02a8f799892fda58347c2d794144311d4307dbfd10f77ffe28088c60be010000000000001720000000000000000002483045022100ae17064745d80650a6a5cbcbe15c8c45ba498d1c6f45a7c0f5f32d871b463fc60220799f2836471702c21f7cfe124651727b530ad41f7af4dc213c65f5030a2f6fc4012103a9d3c6c7c161a565a76113632fe13330cf2c0207ba79a76d1154cdc3cb94d940060800ca9a3b0000000020e48a1a02a8f799892fda58347c2d794144311d4307dbfd10f77ffe28088c60be2006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f1600141eef6361cd1507a303834285d1521d6baf1b19aebe0200000001b399292c8100b8a1b66eb23896f799c1712390d560af0f70e81acd2d17a3b06e0000000049483045022100c3c749623486ea57ea93dfaf78d85590d78c7590a25768fe80f0ea4d6047419002202a0a00a90392b86c53c0fdda908c4591ba28040c16c25734c23b7df3c8b70acd01feffffff0228196bee000000001976a914470dd41542ee1a1bd75f1a838878648c8d65622488ac00ca9a3b0000000017a914cb60b1d7f76ba12b45a116c482c165a74c5d7e38876500000097000000205e3913a320cd2e3a2efa141e47419f54cb9e82320cf8dbc812fc19b9a1b2413a57f5e9fb4fa22de191454a241387f5d10cc794ee0fbf72ae2841baf3129a4eab8133025affff7f20000000000200000002f9d0be670007d38fceece999cb6144658a99c307ccc37f6d8f69129ed0f4545ff321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce010500000000"); -std::vector pegin_transaction = ParseHex("020000000101f321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce0100004000ffffffff02e0b29a3b000000001976a914809326f7628dc976fbe63806479a1b8dfcc8c4b988ac2017000000000000000000000002483045022100ae17064745d80650a6a5cbcbe15c8c45ba498d1c6f45a7c0f5f32d871b463fc60220799f2836471702c21f7cfe124651727b530ad41f7af4dc213c65f5030a2f6fc4012103a9d3c6c7c161a565a76113632fe13330cf2c0207ba79a76d1154cdc3cb94d940060800ca9a3b0000000020e48a1a02a8f799892fda58347c2d794144311d4307dbfd10f77ffe28088c60be2006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f1600141eef6361cd1507a303834285d1521d6baf1b19aebe0200000001b399292c8100b8a1b66eb23896f799c1712390d560af0f70e81acd2d17a3b06e0000000049483045022100c3c749623486ea57ea93dfaf78d85590d78c7590a25768fe80f0ea4d6047419002202a0a00a90392b86c53c0fdda908c4591ba28040c16c25734c23b7df3c8b70acd01feffffff0228196bee000000001976a914470dd41542ee1a1bd75f1a838878648c8d65622488ac00ca9a3b0000000017a914cb60b1d7f76ba12b45a116c482c165a74c5d7e38876500000097000000205e3913a320cd2e3a2efa141e47419f54cb9e82320cf8dbc812fc19b9a1b2413a57f5e9fb4fa22de191454a241387f5d10cc794ee0fbf72ae2841baf3129a4eab8133025affff7f20000000000200000002f9d0be670007d38fceece999cb6144658a99c307ccc37f6d8f69129ed0f4545ff321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce0105"); - +std::vector pegin_transaction = ParseHex("020000000101f321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce0100004000ffffffff0201ef4699c160d014d5ff79636d8a4cb990b9df4ebab649f144d19f5c495c585e4701000000003b9ab2e0001976a914809326f7628dc976fbe63806479a1b8dfcc8c4b988ac01ef4699c160d014d5ff79636d8a4cb990b9df4ebab649f144d19f5c495c585e47010000000000001720000000000000000002483045022100ae17064745d80650a6a5cbcbe15c8c45ba498d1c6f45a7c0f5f32d871b463fc60220799f2836471702c21f7cfe124651727b530ad41f7af4dc213c65f5030a2f6fc4012103a9d3c6c7c161a565a76113632fe13330cf2c0207ba79a76d1154cdc3cb94d940060800ca9a3b0000000020ef4699c160d014d5ff79636d8a4cb990b9df4ebab649f144d19f5c495c585e472006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f1600141eef6361cd1507a303834285d1521d6baf1b19aebe0200000001b399292c8100b8a1b66eb23896f799c1712390d560af0f70e81acd2d17a3b06e0000000049483045022100c3c749623486ea57ea93dfaf78d85590d78c7590a25768fe80f0ea4d6047419002202a0a00a90392b86c53c0fdda908c4591ba28040c16c25734c23b7df3c8b70acd01feffffff0228196bee000000001976a914470dd41542ee1a1bd75f1a838878648c8d65622488ac00ca9a3b0000000017a914cb60b1d7f76ba12b45a116c482c165a74c5d7e38876500000097000000205e3913a320cd2e3a2efa141e47419f54cb9e82320cf8dbc812fc19b9a1b2413a57f5e9fb4fa22de191454a241387f5d10cc794ee0fbf72ae2841baf3129a4eab8133025affff7f20000000000200000002f9d0be670007d38fceece999cb6144658a99c307ccc37f6d8f69129ed0f4545ff321df9790633bc33c67239c4174df8142ee616ee6a2e2788fe4820fe70e9bce010500000000"); COutPoint prevout(uint256S("ce9b0ee70f82e48f78e2a2e66e61ee4281df74419c23673cc33b639097df21f3"), 1); @@ -59,10 +57,6 @@ BOOST_AUTO_TEST_CASE(witness_valid) // Missing byte on each field to make claim ill-formatted // This will break deserialization and other data-matching checks for (unsigned int i = 0; i < witness.stack.size(); i++) { - //TODO(rebase) CA remove this exception - if (i == 1) { - continue; - } witness.stack[i].pop_back(); BOOST_CHECK(!IsValidPeginWitness(witness, prevout, err, false)); witness.stack = witness_stack; @@ -95,7 +89,12 @@ BOOST_AUTO_TEST_CASE(witness_valid) // Check validation of peg-in transaction's inputs and balance CDataStream ssTx(pegin_transaction, SER_NETWORK, PROTOCOL_VERSION); CTransactionRef txRef; - ssTx >> txRef; + try { + ssTx >> txRef; + } catch (...) { + BOOST_CHECK(false); + return; + } CTransaction tx(*txRef); // Only one(valid) input witness should exist, and should match @@ -103,16 +102,16 @@ BOOST_AUTO_TEST_CASE(witness_valid) BOOST_CHECK(tx.witness.vtxinwit[0].m_pegin_witness.stack == witness_stack); BOOST_CHECK(tx.vin[0].m_is_pegin); // Check that serialization doesn't cause issuance to become non-null - //TODO(rebase) CA - //BOOST_CHECK(tx.vin[0].assetIssuance.IsNull()); + BOOST_CHECK(tx.vin[0].assetIssuance.IsNull()); BOOST_CHECK(IsValidPeginWitness(tx.witness.vtxinwit[0].m_pegin_witness, prevout, err, false)); + CAmountMap fee_map; + std::set > setPeginsSpent; CValidationState state; CCoinsView coinsDummy; CCoinsViewCache coins(&coinsDummy); - CAmount txfee; - BOOST_CHECK(Consensus::CheckTxInputs(tx, state, coins, 0, txfee, setPeginsSpent)); + BOOST_CHECK(Consensus::CheckTxInputs(tx, state, coins, 0, fee_map, setPeginsSpent, NULL, false, true)); BOOST_CHECK(setPeginsSpent.size() == 1); setPeginsSpent.clear(); @@ -120,7 +119,7 @@ BOOST_AUTO_TEST_CASE(witness_valid) CMutableTransaction mtxn(tx); mtxn.witness.vtxinwit[0].m_pegin_witness.SetNull(); CTransaction tx2(mtxn); - BOOST_CHECK(!Consensus::CheckTxInputs(tx2, state, coins, 0, txfee, setPeginsSpent)); + BOOST_CHECK(!Consensus::CheckTxInputs(tx2, state, coins, 0, fee_map, setPeginsSpent, NULL, false, true)); BOOST_CHECK(setPeginsSpent.empty()); // Invalidate peg-in (and spending) authorization by pegin marker. @@ -129,7 +128,7 @@ BOOST_AUTO_TEST_CASE(witness_valid) CMutableTransaction mtxn2(tx); mtxn2.vin[0].m_is_pegin = false; CTransaction tx3(mtxn2); - BOOST_CHECK(!Consensus::CheckTxInputs(tx3, state, coins, 0, txfee, setPeginsSpent)); + BOOST_CHECK(!Consensus::CheckTxInputs(tx3, state, coins, 0, fee_map, setPeginsSpent, NULL, false, true)); BOOST_CHECK(setPeginsSpent.empty()); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 48003ce353675..bb524779684f7 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -183,12 +183,16 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, const CScript #if defined(HAVE_CONSENSUS_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; + CDataStream streamVal(SER_NETWORK, PROTOCOL_VERSION); + streamVal << txCredit.vout[0].nValue; + CDataStream streamVal0(SER_NETWORK, PROTOCOL_VERSION); + streamVal0 << CConfidentialValue(0); int libconsensus_flags = flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL; if (libconsensus_flags == flags) { if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(scriptPubKey.data(), scriptPubKey.size(), txCredit.vout[0].nValue, (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, nullptr) == expect, message); + BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(scriptPubKey.data(), scriptPubKey.size(), (const unsigned char*)&streamVal[0], streamVal.size(), (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, nullptr) == expect, message); } else { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(scriptPubKey.data(), scriptPubKey.size(), 0, (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, nullptr) == expect, message); + BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(scriptPubKey.data(), scriptPubKey.size(), (const unsigned char*)&streamVal0[0], streamVal0.size(), (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, nullptr) == expect, message); BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(scriptPubKey.data(), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, nullptr) == expect,message); } } diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 753ed6f2a88d7..77ed9fd09f47a 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -12,6 +13,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include