Skip to content

Commit f4553d4

Browse files
committed
[BROKEN] Adapt existing benchmarks to CA
1 parent 703db5b commit f4553d4

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/bench/block_assemble.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void AssembleBlock(benchmark::State& state)
9595
tx.vin.push_back(MineBlock(SCRIPT_PUB));
9696
tx.witness.vtxinwit.resize(1);
9797
tx.witness.vtxinwit.back().scriptWitness = witness;
98-
tx.vout.emplace_back(1337, SCRIPT_PUB);
98+
tx.vout.emplace_back(CTxOut(CAsset(), 1337, SCRIPT_PUB));
9999
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
100100
txs.at(b) = MakeTransactionRef(tx);
101101
}

src/bench/checkqueue.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state)
4545
// Make insecure_rand here so that each iteration is identical.
4646
FastRandomContext insecure_rand(true);
4747
CCheckQueueControl<PrevectorJob> control(&queue);
48-
std::vector<std::vector<PrevectorJob>> vBatches(BATCHES);
48+
std::vector<std::vector<PrevectorJob*>> vBatches(BATCHES);
4949
for (auto& vChecks : vBatches) {
5050
vChecks.reserve(BATCH_SIZE);
51-
for (size_t x = 0; x < BATCH_SIZE; ++x)
52-
vChecks.emplace_back(insecure_rand);
51+
for (size_t x = 0; x < BATCH_SIZE; ++x) {
52+
vChecks.emplace_back(new PrevectorJob(insecure_rand));
53+
}
5354
control.Add(vChecks);
5455
}
5556
// control waits for completion by RAII, but

src/bench/coin_selection.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <bench/bench.h>
66
#include <wallet/wallet.h>
77
#include <wallet/coinselection.h>
8+
#include <asset.h>
9+
#include <policy/policy.h>
810

911
#include <set>
1012

@@ -47,12 +49,23 @@ static void CoinSelection(benchmark::State& state)
4749
const CoinSelectionParams coin_selection_params(true, 34, 148, CFeeRate(0), 0);
4850
while (state.KeepRunning()) {
4951
std::set<CInputCoin> setCoinsRet;
50-
CAmount nValueRet;
52+
CAmountMap mapValueRet;
5153
bool bnb_used;
52-
bool success = wallet.SelectCoinsMinConf(1003 * COIN, filter_standard, groups, setCoinsRet, nValueRet, coin_selection_params, bnb_used);
54+
CAmountMap mapValue;
55+
mapValue[::policyAsset] = 1003 * COIN;
56+
bool success = wallet.SelectCoinsMinConf(mapValue, filter_standard, groups, setCoinsRet, mapValueRet, coin_selection_params, bnb_used);
5357
assert(success);
54-
assert(nValueRet == 1003 * COIN);
58+
assert(mapValueRet[::policyAsset] == 1003 * COIN);
5559
assert(setCoinsRet.size() == 2);
60+
61+
/* std::set<std::pair<const CWalletTx*, unsigned int> > setCoinsRet;
62+
CAmountMap nValueRet;
63+
CAmountMap mapValue;
64+
mapValue[CAsset()] = 1003 * COIN;
65+
bool success = wallet.SelectCoinsMinConf(mapValue, 1, 6, 0, vCoins, setCoinsRet, nValueRet);
66+
assert(success);
67+
assert(nValueRet[CAsset()] == 1003 * COIN);
68+
assert(setCoinsRet.size() == 2);*/
5669
}
5770
}
5871

src/bench/verify_script.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ static void VerifyScriptBench(benchmark::State& state)
9797
#if defined(HAVE_CONSENSUS_LIB)
9898
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
9999
stream << txSpend;
100+
CDataStream streamVal(SER_NETWORK, PROTOCOL_VERSION);
101+
streamVal << txCredit.vout[0].nValue;
100102
int csuccess = bitcoinconsensus_verify_script_with_amount(
101103
txCredit.vout[0].scriptPubKey.data(),
102104
txCredit.vout[0].scriptPubKey.size(),
103-
txCredit.vout[0].nValue,
105+
(const unsigned char*)&streamVal[0], streamVal.size(),
104106
(const unsigned char*)stream.data(), stream.size(), 0, flags, nullptr);
105107
assert(csuccess == 1);
106108
#endif

0 commit comments

Comments
 (0)