diff options
author | brunoerg <brunoely.gc@gmail.com> | 2023-08-15 21:27:20 -0300 |
---|---|---|
committer | brunoerg <brunoely.gc@gmail.com> | 2023-08-23 14:48:27 -0300 |
commit | bf26f978ffbe7e2fc681825de631600e24e5c93e (patch) | |
tree | 1626a5372b4128308b192fc7f763cfc7661873a3 /src/wallet | |
parent | 6d9b26d56ab5295dfcfe0f80a3069046a263fb2f (diff) |
fuzz: coinselection, fix `m_cost_of_change`
`m_cost_of_change` must not be generated randomly
independent from m_change_fee. This commit changes
it to set it up according to `wallet/spend`.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/fuzz/coinselection.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet/test/fuzz/coinselection.cpp b/src/wallet/test/fuzz/coinselection.cpp index 58d47acbc6..4caf96b18d 100644 --- a/src/wallet/test/fuzz/coinselection.cpp +++ b/src/wallet/test/fuzz/coinselection.cpp @@ -84,7 +84,8 @@ FUZZ_TARGET(coinselection) const CFeeRate long_term_fee_rate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)}; const CFeeRate effective_fee_rate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)}; - const CAmount cost_of_change{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)}; + // Discard feerate must be at least dust relay feerate + const CFeeRate discard_fee_rate{fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(DUST_RELAY_TX_FEE, COIN)}; const CAmount min_viable_change{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)}; const CAmount target{fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(1, MAX_MONEY)}; const bool subtract_fee_outputs{fuzzed_data_provider.ConsumeBool()}; @@ -95,9 +96,11 @@ FUZZ_TARGET(coinselection) coin_params.m_long_term_feerate = long_term_fee_rate; coin_params.m_effective_feerate = effective_fee_rate; coin_params.min_viable_change = min_viable_change; - coin_params.m_cost_of_change = cost_of_change; coin_params.change_output_size = fuzzed_data_provider.ConsumeIntegralInRange<int>(10, 1000); coin_params.m_change_fee = effective_fee_rate.GetFee(coin_params.change_output_size); + coin_params.m_discard_feerate = discard_fee_rate; + coin_params.change_spend_size = fuzzed_data_provider.ConsumeIntegralInRange<int>(41, 1000); + coin_params.m_cost_of_change = coin_params.m_change_fee + coin_params.m_discard_feerate.GetFee(coin_params.change_spend_size); int next_locktime{0}; CAmount total_balance{CreateCoins(fuzzed_data_provider, utxo_pool, coin_params, next_locktime)}; |