Skip to content

Commit

Permalink
CHIA-2282 Improve some coins checks in test_select_coins_rpc (#19206)
Browse files Browse the repository at this point in the history
Improve some coins checks in test_select_coins_rpc.
  • Loading branch information
AmineKhaldi authored Feb 7, 2025
1 parent 22dce46 commit dfedada
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions chia/_tests/wallet/rpc/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,8 +1826,8 @@ async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment
wallet_id=1,
coin_selection_config=DEFAULT_COIN_SELECTION_CONFIG.override(min_coin_amount=uint64(1001)),
)
assert min_coins is not None
assert len(min_coins) == 1 and min_coins[0].amount == uint64(10000)
assert len(min_coins) == 1
assert min_coins[0].amount == uint64(10_000)

# test max coin amount
max_coins: list[Coin] = await client_2.select_coins(
Expand All @@ -1837,8 +1837,8 @@ async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment
min_coin_amount=uint64(999), max_coin_amount=uint64(9999)
),
)
assert max_coins is not None
assert len(max_coins) == 2 and max_coins[0].amount == uint64(1000)
assert len(max_coins) == 2
assert max_coins[0].amount == uint64(1000)

# test excluded coin amounts
non_1000_amt: int = sum(a for a in tx_amounts if a != 1000)
Expand All @@ -1847,11 +1847,8 @@ async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment
wallet_id=1,
coin_selection_config=DEFAULT_COIN_SELECTION_CONFIG.override(excluded_coin_amounts=[uint64(1000)]),
)
assert excluded_amt_coins is not None
assert (
len(excluded_amt_coins) == len(tuple(a for a in tx_amounts if a != 1000))
and sum(c.amount for c in excluded_amt_coins) == non_1000_amt
)
assert len(excluded_amt_coins) == len([a for a in tx_amounts if a != 1000])
assert sum(c.amount for c in excluded_amt_coins) == non_1000_amt

# test excluded coins
with pytest.raises(ValueError):
Expand Down

0 comments on commit dfedada

Please sign in to comment.