@@ -97,7 +97,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
97
97
BOOST_CHECK_EQUAL (mempool.size (), 0U );
98
98
}
99
99
100
- // Run CheckInputs (using pcoinsTip ) on the given transaction, for all script
100
+ // Run CheckInputs (using CoinsTip() ) on the given transaction, for all script
101
101
// flags. Test that CheckInputs passes for all flags that don't overlap with
102
102
// the failing_flags argument, but otherwise fails.
103
103
// CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY (and future NOP codes that may
@@ -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, pcoinsTip. get (), true , test_flags, true , add_to_cache, txdata, nullptr );
128
+ bool ret = CheckInputs (tx, state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , test_flags, true , add_to_cache, txdata, &scriptchecks));
138
+ BOOST_CHECK (CheckInputs (tx, state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , test_flags, true , add_to_cache, txdata, &scriptchecks));
144
+ BOOST_CHECK (CheckInputs (tx, state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, nullptr ));
207
+ BOOST_CHECK (!CheckInputs (CTransaction (spend_tx), state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true , true , ptd_spend_tx, &scriptchecks));
213
+ BOOST_CHECK (CheckInputs (CTransaction (spend_tx), state, &:: ChainstateActive (). CoinsTip (), true , 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
@@ -227,7 +227,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
227
227
block = CreateAndProcessBlock ({spend_tx}, p2pk_scriptPubKey);
228
228
LOCK (cs_main);
229
229
BOOST_CHECK (::ChainActive ().Tip ()->GetBlockHash () == block.GetHash ());
230
- BOOST_CHECK (pcoinsTip-> GetBestBlock () == block.GetHash ());
230
+ BOOST_CHECK (:: ChainstateActive (). CoinsTip (). GetBestBlock () == block.GetHash ());
231
231
232
232
// Test P2SH: construct a transaction that is valid without P2SH, and
233
233
// then test validity with P2SH.
@@ -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, pcoinsTip. get (), true , SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true , true , txdata, nullptr ));
275
+ BOOST_CHECK (CheckInputs (CTransaction (invalid_with_cltv_tx), state, :: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true , true , txdata, nullptr ));
303
+ BOOST_CHECK (CheckInputs (CTransaction (invalid_with_csv_tx), state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, nullptr ));
365
+ BOOST_CHECK (!CheckInputs (CTransaction (tx), state, &:: ChainstateActive (). CoinsTip (), true , 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, pcoinsTip. get (), true , SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true , true , txdata, &scriptchecks));
370
+ BOOST_CHECK (CheckInputs (CTransaction (tx), state, &:: ChainstateActive (). CoinsTip (), true , 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