Skip to content

Commit

Permalink
bench: Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Sep 27, 2023
1 parent ec638b1 commit c96fa4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ static void AssembleBlock(benchmark::Bench& bench)
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);

// Collect some loose transactions that spend the coinbases of our mined blocks
constexpr size_t NUM_BLOCKS{200};
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
constexpr size_t NUM_BLOCKS{1000};
constexpr size_t coinbaseMaturity{500};
std::array<CTransactionRef, NUM_BLOCKS - coinbaseMaturity + 1> txs;
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
CMutableTransaction tx;
tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
tx.vin.back().scriptWitness = witness;
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
if (NUM_BLOCKS - b >= coinbaseMaturity)
txs.at(b) = MakeTransactionRef(tx);
}
{
Expand Down
2 changes: 2 additions & 0 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ static void CoinSelection(benchmark::Bench& bench)
rand,
/*change_output_size=*/ 34,
/*change_spend_size=*/ 148,
/*effective_feerate=*/ CFeeRate(0),
/*discard_feerate=*/ CFeeRate(0),
/*tx_noinputs_size=*/ 0,
/*avoid_partial=*/ false,
};
Expand Down
8 changes: 4 additions & 4 deletions src/bench/wallet_create_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void generateFakeBlock(const CChainParams& params,
{
LOCK(::cs_main);
// Add it to the index
CBlockIndex* pindex{context.chainman->m_blockman.AddToBlockIndex(block, context.chainman->m_best_header)};
CBlockIndex* pindex{context.chainman->m_blockman.AddToBlockIndex(block, context.chainman->m_best_header, false)};
// add it to the chain
context.chainman->ActiveChain().SetTip(*pindex);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type

// Check available balance
auto bal = WITH_LOCK(wallet.cs_wallet, return wallet::AvailableCoins(wallet).GetTotalAmount()); // Cache
assert(bal == 50 * COIN * (chain_size - COINBASE_MATURITY));
assert(bal == 50 * COIN * (chain_size - params.GetConsensus().nCoinbaseMaturity));

wallet::CCoinControl coin_control;
coin_control.m_allow_other_inputs = allow_other_inputs;
Expand Down Expand Up @@ -162,12 +162,12 @@ static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType

// Check available balance
auto bal = WITH_LOCK(wallet.cs_wallet, return wallet::AvailableCoins(wallet).GetTotalAmount()); // Cache
assert(bal == 50 * COIN * (chain_size - COINBASE_MATURITY));
assert(bal == 50 * COIN * (chain_size - params.GetConsensus().nCoinbaseMaturity));

bench.epochIterations(2).run([&] {
LOCK(wallet.cs_wallet);
const auto& res = wallet::AvailableCoins(wallet);
assert(res.All().size() == (chain_size - COINBASE_MATURITY) * 2);
assert(res.All().size() == (chain_size - params.GetConsensus().nCoinbaseMaturity) * 2);
});
}

Expand Down

0 comments on commit c96fa4f

Please sign in to comment.