Skip to content

Commit

Permalink
[test util] CreateValidMempoolTransaction version parameter, always s…
Browse files Browse the repository at this point in the history
…ignal bip125
  • Loading branch information
glozow authored and instagibbs committed Dec 1, 2023
1 parent d4b88a4 commit e26a348
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,11 @@ std::pair<CMutableTransaction, CAmount> TestChain100Setup::CreateValidTransactio
const std::vector<CKey>& input_signing_keys,
const std::vector<CTxOut>& outputs,
const std::optional<CFeeRate>& feerate,
const std::optional<uint32_t>& fee_output)
const std::optional<uint32_t>& fee_output,
uint32_t version)
{
CMutableTransaction mempool_txn;
mempool_txn.nVersion = version;
mempool_txn.vin.reserve(inputs.size());
mempool_txn.vout.reserve(outputs.size());

Expand Down Expand Up @@ -415,9 +417,10 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(const std::
int input_height,
const std::vector<CKey>& input_signing_keys,
const std::vector<CTxOut>& outputs,
bool submit)
bool submit,
uint32_t version)
{
CMutableTransaction mempool_txn = CreateValidTransaction(input_transactions, inputs, input_height, input_signing_keys, outputs, std::nullopt, std::nullopt).first;
CMutableTransaction mempool_txn = CreateValidTransaction(input_transactions, inputs, input_height, input_signing_keys, outputs, std::nullopt, std::nullopt, version).first;
// If submit=true, add transaction to the mempool.
if (submit) {
LOCK(cs_main);
Expand All @@ -433,7 +436,8 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
CKey input_signing_key,
CScript output_destination,
CAmount output_amount,
bool submit)
bool submit,
uint32_t version)
{
COutPoint input{input_transaction->GetHash(), input_vout};
CTxOut output{output_amount, output_destination};
Expand All @@ -442,7 +446,8 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
/*input_height=*/input_height,
/*input_signing_keys=*/{input_signing_key},
/*outputs=*/{output},
/*submit=*/submit);
/*submit=*/submit,
/*version=*/version);
}

std::vector<CTransactionRef> TestChain100Setup::PopulateMempool(FastRandomContext& det_rand, size_t num_transactions, bool submit)
Expand Down
9 changes: 6 additions & 3 deletions src/test/util/setup_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ struct TestChain100Setup : public TestingSetup {
const std::vector<CKey>& input_signing_keys,
const std::vector<CTxOut>& outputs,
const std::optional<CFeeRate>& feerate,
const std::optional<uint32_t>& fee_output);
const std::optional<uint32_t>& fee_output,
uint32_t version);
/**
* Create a transaction and, optionally, submit to the mempool.
*
Expand All @@ -158,7 +159,8 @@ struct TestChain100Setup : public TestingSetup {
int input_height,
const std::vector<CKey>& input_signing_keys,
const std::vector<CTxOut>& outputs,
bool submit = true);
bool submit = true,
uint32_t version = 2);

/**
* Create a 1-in-1-out transaction and, optionally, submit to the mempool.
Expand All @@ -177,7 +179,8 @@ struct TestChain100Setup : public TestingSetup {
CKey input_signing_key,
CScript output_destination,
CAmount output_amount = CAmount(1 * COIN),
bool submit = true);
bool submit = true,
uint32_t version = 2);

/** Create transactions spending from m_coinbase_txns. These transactions will only spend coins
* that exist in the current chain, but may be premature coinbase spends, have missing
Expand Down

0 comments on commit e26a348

Please sign in to comment.