1313
1414#include < boost/test/unit_test.hpp>
1515
16- bool CheckInputs (const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks , unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks);
16+ bool CheckInputs (const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks);
1717
1818BOOST_AUTO_TEST_SUITE (tx_validationcache_tests)
1919
@@ -125,7 +125,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
125125 // WITNESS requires P2SH
126126 test_flags |= SCRIPT_VERIFY_P2SH;
127127 }
128- bool ret = CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), true , test_flags, true , add_to_cache, txdata, nullptr );
128+ bool ret = CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), test_flags, true , add_to_cache, txdata, nullptr );
129129 // CheckInputs should succeed iff test_flags doesn't intersect with
130130 // failing_flags
131131 bool expected_return_value = !(test_flags & failing_flags);
@@ -135,13 +135,13 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
135135 if (ret && add_to_cache) {
136136 // Check that we get a cache hit if the tx was valid
137137 std::vector<CScriptCheck> scriptchecks;
138- BOOST_CHECK (CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), true , test_flags, true , add_to_cache, txdata, &scriptchecks));
138+ BOOST_CHECK (CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), test_flags, true , add_to_cache, txdata, &scriptchecks));
139139 BOOST_CHECK (scriptchecks.empty ());
140140 } else {
141141 // Check that we get script executions to check, if the transaction
142142 // was invalid, or we didn't add to cache.
143143 std::vector<CScriptCheck> scriptchecks;
144- BOOST_CHECK (CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), true , test_flags, true , add_to_cache, txdata, &scriptchecks));
144+ BOOST_CHECK (CheckInputs (tx, state, &::ChainstateActive ().CoinsTip (), test_flags, true , add_to_cache, txdata, &scriptchecks));
145145 BOOST_CHECK_EQUAL (scriptchecks.size (), tx.vin .size ());
146146 }
147147 }
@@ -204,13 +204,13 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
204204 CValidationState state;
205205 PrecomputedTransactionData ptd_spend_tx (spend_tx);
206206
207- BOOST_CHECK (!CheckInputs (CTransaction (spend_tx), state, &::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, nullptr ));
207+ BOOST_CHECK (!CheckInputs (CTransaction (spend_tx), state, &::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, nullptr ));
208208
209209 // If we call again asking for scriptchecks (as happens in
210210 // ConnectBlock), we should add a script check object for this -- we're
211211 // not caching invalidity (if that changes, delete this test case).
212212 std::vector<CScriptCheck> scriptchecks;
213- BOOST_CHECK (CheckInputs (CTransaction (spend_tx), state, &::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, &scriptchecks));
213+ BOOST_CHECK (CheckInputs (CTransaction (spend_tx), state, &::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, &scriptchecks));
214214 BOOST_CHECK_EQUAL (scriptchecks.size (), 1U );
215215
216216 // Test that CheckInputs returns true iff DERSIG-enforcing flags are
@@ -272,7 +272,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
272272 invalid_with_cltv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
273273 CValidationState state;
274274 PrecomputedTransactionData txdata (invalid_with_cltv_tx);
275- BOOST_CHECK (CheckInputs (CTransaction (invalid_with_cltv_tx), state, ::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true , true , txdata, nullptr ));
275+ BOOST_CHECK (CheckInputs (CTransaction (invalid_with_cltv_tx), state, ::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true , true , txdata, nullptr ));
276276 }
277277
278278 // TEST CHECKSEQUENCEVERIFY
@@ -300,7 +300,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
300300 invalid_with_csv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
301301 CValidationState state;
302302 PrecomputedTransactionData txdata (invalid_with_csv_tx);
303- BOOST_CHECK (CheckInputs (CTransaction (invalid_with_csv_tx), state, &::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true , true , txdata, nullptr ));
303+ BOOST_CHECK (CheckInputs (CTransaction (invalid_with_csv_tx), state, &::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true , true , txdata, nullptr ));
304304 }
305305
306306 // TODO: add tests for remaining script flags
@@ -362,12 +362,12 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
362362 CValidationState state;
363363 PrecomputedTransactionData txdata (tx);
364364 // This transaction is now invalid under segwit, because of the second input.
365- BOOST_CHECK (!CheckInputs (CTransaction (tx), state, &::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, nullptr ));
365+ BOOST_CHECK (!CheckInputs (CTransaction (tx), state, &::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, nullptr ));
366366
367367 std::vector<CScriptCheck> scriptchecks;
368368 // Make sure this transaction was not cached (ie because the first
369369 // input was valid)
370- BOOST_CHECK (CheckInputs (CTransaction (tx), state, &::ChainstateActive ().CoinsTip (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, &scriptchecks));
370+ BOOST_CHECK (CheckInputs (CTransaction (tx), state, &::ChainstateActive ().CoinsTip (), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, &scriptchecks));
371371 // Should get 2 script checks back -- caching is on a whole-transaction basis.
372372 BOOST_CHECK_EQUAL (scriptchecks.size (), 2U );
373373 }
0 commit comments