mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-21 08:31:52 +03:00
fix the scenario with change
This commit is contained in:
parent
adda69eff7
commit
f47aac8b95
@ -410,7 +410,9 @@ class CCWallet:
|
||||
selected_coins: Optional[List[Coin]] = await self.select_coins(amount)
|
||||
if selected_coins is None:
|
||||
return None
|
||||
change = sum([x.amount for x in selected_coins]) - amount
|
||||
|
||||
total_amount = sum([x.amount for x in selected_coins])
|
||||
change = total_amount - amount
|
||||
|
||||
# first coin becomes the auditor special case
|
||||
auditor = selected_coins.pop()
|
||||
@ -430,7 +432,7 @@ class CCWallet:
|
||||
auditor.parent_coin_info,
|
||||
inner_puzzle.get_hash(),
|
||||
auditor.amount,
|
||||
amount + change,
|
||||
total_amount,
|
||||
)
|
||||
]
|
||||
for coin in selected_coins:
|
||||
@ -486,12 +488,15 @@ class CCWallet:
|
||||
),
|
||||
)
|
||||
list_of_solutions.append(main_coin_solution)
|
||||
# main = SpendBundle([main_coin_solution], ZERO96)
|
||||
|
||||
ephemeral_coin_solution = create_spend_for_ephemeral(auditor, auditor, amount)
|
||||
ephemeral_coin_solution = create_spend_for_ephemeral(auditor, auditor, total_amount)
|
||||
list_of_solutions.append(ephemeral_coin_solution)
|
||||
# eph = SpendBundle([ephemeral_coin_solution], ZERO96)
|
||||
|
||||
auditor_coin_colution= create_spend_for_auditor(auditor, auditor)
|
||||
list_of_solutions.append(auditor_coin_colution)
|
||||
# aud = SpendBundle([auditor_coin_colution], ZERO96)
|
||||
|
||||
# loop through remaining spends, treating them as aggregatees
|
||||
for coin in selected_coins:
|
||||
|
@ -138,7 +138,7 @@ class TestWalletSimulator:
|
||||
assert cc_wallet.cc_info.my_core == cc_wallet_2.cc_info.my_core
|
||||
|
||||
cc_2_hash = await cc_wallet_2.get_new_inner_hash()
|
||||
await cc_wallet.cc_spend(uint64(100), cc_2_hash)
|
||||
await cc_wallet.cc_spend(uint64(60), cc_2_hash)
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
await full_node_1.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
@ -147,14 +147,14 @@ class TestWalletSimulator:
|
||||
confirmed_balance = await cc_wallet.get_confirmed_balance()
|
||||
unconfirmed_balance = await cc_wallet.get_unconfirmed_balance()
|
||||
|
||||
assert confirmed_balance == 0
|
||||
assert unconfirmed_balance == 0
|
||||
assert confirmed_balance == 40
|
||||
assert unconfirmed_balance == 40
|
||||
|
||||
confirmed_balance = await cc_wallet_2.get_confirmed_balance()
|
||||
unconfirmed_balance = await cc_wallet_2.get_unconfirmed_balance()
|
||||
|
||||
assert confirmed_balance == 100
|
||||
assert unconfirmed_balance == 100
|
||||
assert confirmed_balance == 60
|
||||
assert unconfirmed_balance == 60
|
||||
"""
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_zero_val(self, two_wallet_nodes):
|
||||
|
Loading…
Reference in New Issue
Block a user