Skip to content

Commit 5d35b4a

Browse files
committed
[test] package validation quits early due to non-policy, non-missing-inputs failure
1 parent be2e4d9 commit 5d35b4a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/txpackage_tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,24 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
278278
BOOST_CHECK(result_3gen_submit.m_package_feerate == std::nullopt);
279279
}
280280

281+
// Parent and child package where transactions are invalid for reasons other than fee and
282+
// missing inputs, so the package validation isn't expected to happen.
283+
{
284+
CScriptWitness bad_witness;
285+
bad_witness.stack.push_back(std::vector<unsigned char>(1));
286+
CMutableTransaction mtx_parent_invalid{mtx_parent};
287+
mtx_parent_invalid.vin[0].scriptWitness = bad_witness;
288+
CTransactionRef tx_parent_invalid = MakeTransactionRef(mtx_parent_invalid);
289+
auto result_quit_early = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
290+
{tx_parent_invalid, tx_child}, /*test_accept=*/ false);
291+
BOOST_CHECK(result_quit_early.m_state.IsInvalid());
292+
BOOST_CHECK_EQUAL(result_quit_early.m_state.GetResult(), PackageValidationResult::PCKG_TX);
293+
BOOST_CHECK(!result_quit_early.m_tx_results.empty());
294+
auto it_parent = result_quit_early.m_tx_results.find(tx_parent_invalid->GetWitnessHash());
295+
BOOST_CHECK(it_parent != result_quit_early.m_tx_results.end());
296+
BOOST_CHECK_EQUAL(it_parent->second.m_state.GetResult(), TxValidationResult::TX_WITNESS_MUTATED);
297+
}
298+
281299
// Child with missing parent.
282300
mtx_child.vin.push_back(CTxIn(COutPoint(package_unrelated[0]->GetHash(), 0)));
283301
Package package_missing_parent;

0 commit comments

Comments
 (0)