-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoinChooser: avoid NotEnoughFunds if zero buckets are sufficient
closes #5752 Adapted from @JeremyRand's fix
- Loading branch information
1 parent
5773097
commit 5549f3a
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from electrum.coinchooser import CoinChooserPrivacy | ||
from electrum.util import NotEnoughFunds | ||
|
||
from . import ElectrumTestCase | ||
|
||
|
||
class TestCoinChooser(ElectrumTestCase): | ||
|
||
def test_bucket_candidates_with_empty_buckets(self): | ||
def sufficient_funds(buckets, *, bucket_value_sum): | ||
return True | ||
coin_chooser = CoinChooserPrivacy() | ||
self.assertEqual([[]], coin_chooser.bucket_candidates_any([], sufficient_funds)) | ||
self.assertEqual([[]], coin_chooser.bucket_candidates_prefer_confirmed([], sufficient_funds)) | ||
def sufficient_funds(buckets, *, bucket_value_sum): | ||
return False | ||
with self.assertRaises(NotEnoughFunds): | ||
coin_chooser.bucket_candidates_any([], sufficient_funds) | ||
with self.assertRaises(NotEnoughFunds): | ||
coin_chooser.bucket_candidates_prefer_confirmed([], sufficient_funds) |