13
13
14
14
#include < boost/test/unit_test.hpp>
15
15
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);
17
17
18
18
BOOST_AUTO_TEST_SUITE (tx_validationcache_tests)
19
19
@@ -125,7 +125,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
125
125
// WITNESS requires P2SH
126
126
test_flags |= SCRIPT_VERIFY_P2SH;
127
127
}
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 );
129
129
// CheckInputs should succeed iff test_flags doesn't intersect with
130
130
// failing_flags
131
131
bool expected_return_value = !(test_flags & failing_flags);
@@ -135,13 +135,13 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
135
135
if (ret && add_to_cache) {
136
136
// Check that we get a cache hit if the tx was valid
137
137
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));
139
139
BOOST_CHECK (scriptchecks.empty ());
140
140
} else {
141
141
// Check that we get script executions to check, if the transaction
142
142
// was invalid, or we didn't add to cache.
143
143
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));
145
145
BOOST_CHECK_EQUAL (scriptchecks.size (), tx.vin .size ());
146
146
}
147
147
}
@@ -204,13 +204,13 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
204
204
CValidationState state;
205
205
PrecomputedTransactionData ptd_spend_tx (spend_tx);
206
206
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 ));
208
208
209
209
// If we call again asking for scriptchecks (as happens in
210
210
// ConnectBlock), we should add a script check object for this -- we're
211
211
// not caching invalidity (if that changes, delete this test case).
212
212
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));
214
214
BOOST_CHECK_EQUAL (scriptchecks.size (), 1U );
215
215
216
216
// Test that CheckInputs returns true iff DERSIG-enforcing flags are
@@ -272,7 +272,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
272
272
invalid_with_cltv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
273
273
CValidationState state;
274
274
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 ));
276
276
}
277
277
278
278
// TEST CHECKSEQUENCEVERIFY
@@ -300,7 +300,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
300
300
invalid_with_csv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
301
301
CValidationState state;
302
302
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 ));
304
304
}
305
305
306
306
// TODO: add tests for remaining script flags
@@ -362,12 +362,12 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
362
362
CValidationState state;
363
363
PrecomputedTransactionData txdata (tx);
364
364
// 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 ));
366
366
367
367
std::vector<CScriptCheck> scriptchecks;
368
368
// Make sure this transaction was not cached (ie because the first
369
369
// 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));
371
371
// Should get 2 script checks back -- caching is on a whole-transaction basis.
372
372
BOOST_CHECK_EQUAL (scriptchecks.size (), 2U );
373
373
}
0 commit comments