Skip to content

test: proptest that LowestFee finds planted single-input optimum#45

Draft
evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:fix/1-input-solutions
Draft

test: proptest that LowestFee finds planted single-input optimum#45
evanlinjin wants to merge 1 commit into
bitcoindevkit:masterfrom
evanlinjin:fix/1-input-solutions

Conversation

@evanlinjin
Copy link
Copy Markdown
Member

Summary

Adds a constructive proptest covering an edge case that can_eventually_find_best_solution doesn't reach: BnB at large N (up to ~200 candidates) finding an obvious 1-input optimum without paying the cost of exhaustive search.

The construction:

  • Plant one candidate at index 0 with value = target_value + fee_for_1_input (computed by probing with a dummy candidate's weight).
  • Surround it with up to 200 dust candidates (value=1, P2WPKH-like weight).
  • Since (a) n_noise ≤ 200 < target_value ≥ 10_000, noise can never sum to cover the target, and (b) adding any noise to the planted candidate either makes the fee delta exceed the +1 sat value (target no longer met) or triggers drain (score strictly > fee_for_1_input), the planted candidate alone is the unique optimum.
  • BnB is expected to converge within 10 * (n_noise + 2) rounds.

No production code changes — this is a test-only addition.

Test plan

  • cargo test --release --test lowest_fee lowest_fee_finds_planted_single_input (256 proptest cases)
  • cargo test --release --test lowest_fee (full suite, all 8 tests pass)

🤖 Generated with Claude Code

…imum

Plants a candidate sized exactly target + fee_for_1_input alongside up
to 200 dust noise candidates, then asserts BnB picks just the planted
one. Since (a) noise can't sum to cover the target and (b) any noise
added to the planted candidate strictly raises the score (or
invalidates the selection), [planted] is the unique optimum. Unlike
can_eventually_find_best_solution, this stresses BnB at N > 20 without
paying for exhaustive search.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant