Skip to content
43 changes: 1 addition & 42 deletions chia/_tests/cmds/cmd_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from chia.full_node.full_node_rpc_client import FullNodeRpcClient
from chia.rpc.rpc_client import RpcClient
from chia.simulator.simulator_full_node_rpc_client import SimulatorFullNodeRpcClient
from chia.types.coin_record import CoinRecord
from chia.types.signing_mode import SigningMode
from chia.util.bech32m import encode_puzzle_hash
from chia.util.config import load_config
Expand All @@ -31,7 +30,7 @@
from chia.wallet.nft_wallet.nft_wallet import NFTWallet
from chia.wallet.transaction_record import TransactionRecord
from chia.wallet.util.transaction_type import TransactionType
from chia.wallet.util.tx_config import CoinSelectionConfig, TXConfig
from chia.wallet.util.tx_config import TXConfig
from chia.wallet.util.wallet_types import WalletType
from chia.wallet.wallet_request_types import (
GetSyncStatusResponse,
Expand Down Expand Up @@ -232,46 +231,6 @@ async def nft_calculate_royalties(
)
)

async def get_spendable_coins(
self,
wallet_id: int,
coin_selection_config: CoinSelectionConfig,
) -> tuple[list[CoinRecord], list[CoinRecord], list[Coin]]:
"""
We return a tuple containing: (confirmed records, unconfirmed removals, unconfirmed additions)
"""
self.add_to_log(
"get_spendable_coins",
(wallet_id, coin_selection_config),
)
confirmed_records = [
CoinRecord(
Coin(bytes32([1] * 32), bytes32([2] * 32), uint64(1234560000)),
uint32(123456),
uint32(0),
False,
uint64(0),
),
CoinRecord(
Coin(bytes32([3] * 32), bytes32([4] * 32), uint64(1234560000)),
uint32(123456),
uint32(0),
False,
uint64(0),
),
]
unconfirmed_removals = [
CoinRecord(
Coin(bytes32([5] * 32), bytes32([6] * 32), uint64(1234570000)),
uint32(123457),
uint32(0),
True,
uint64(0),
)
]
unconfirmed_additions = [Coin(bytes32([7] * 32), bytes32([8] * 32), uint64(1234580000))]
return confirmed_records, unconfirmed_removals, unconfirmed_additions

async def send_transaction_multi(
self,
wallet_id: int,
Expand Down
30 changes: 17 additions & 13 deletions chia/_tests/cmds/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
RoyaltyAsset,
SendTransaction,
SendTransactionResponse,
SpendClawbackCoins,
SpendClawbackCoinsResponse,
TakeOfferResponse,
TransactionRecordWithMetadata,
WalletInfoResponse,
Expand Down Expand Up @@ -539,23 +541,25 @@ def test_clawback(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
class ClawbackWalletRpcClient(TestWalletRpcClient):
async def spend_clawback_coins(
self,
coin_ids: list[bytes32],
fee: int = 0,
force: bool = False,
push: bool = True,
request: SpendClawbackCoins,
tx_config: TXConfig,
extra_conditions: tuple[Condition, ...] = tuple(),
timelock_info: ConditionValidTimes = ConditionValidTimes(),
) -> dict[str, Any]:
self.add_to_log("spend_clawback_coins", (coin_ids, fee, force, push, timelock_info))
tx_hex_list = [get_bytes32(6).hex(), get_bytes32(7).hex(), get_bytes32(8).hex()]
return {
"transaction_ids": tx_hex_list,
"transactions": [STD_TX.to_json_dict()],
}
) -> SpendClawbackCoinsResponse:
self.add_to_log(
"spend_clawback_coins", (request.coin_ids, request.fee, request.force, request.push, timelock_info)
)
tx_list = [get_bytes32(6), get_bytes32(7), get_bytes32(8)]
return SpendClawbackCoinsResponse(
transaction_ids=tx_list,
transactions=[STD_TX],
unsigned_transactions=[STD_UTX],
)

inst_rpc_client = ClawbackWalletRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
tx_ids = [get_bytes32(3), get_bytes32(4), get_bytes32(5)]
r_tx_ids_hex = [get_bytes32(6).hex(), get_bytes32(7).hex(), get_bytes32(8).hex()]
r_tx_ids_hex = ["0x" + get_bytes32(6).hex(), "0x" + get_bytes32(7).hex(), "0x" + get_bytes32(8).hex()]
command_args = [
"wallet",
"clawback",
Expand All @@ -569,7 +573,7 @@ async def spend_clawback_coins(
"--expires-at",
"150",
]
run_cli_command_and_assert(capsys, root_dir, command_args, ["transaction_ids", str(r_tx_ids_hex)])
run_cli_command_and_assert(capsys, root_dir, command_args, ["transaction_ids", *r_tx_ids_hex])
# these are various things that should be in the output
expected_calls: logType = {
"spend_clawback_coins": [(tx_ids, 500000000000, False, True, test_condition_valid_times)],
Expand Down
27 changes: 15 additions & 12 deletions chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT
from chia.wallet.transaction_record import TransactionRecord
from chia.wallet.util.address_type import AddressType
from chia.wallet.wallet_request_types import NFTGetNFTs, NFTMintBulk, NFTMintMetadata, PushTransactions
from chia.wallet.wallet_request_types import NFTGetNFTs, NFTMintBulk, NFTMintMetadata, PushTransactions, SelectCoins


async def nft_count(wallet: NFTWallet) -> int:
Expand Down Expand Up @@ -291,22 +291,25 @@ async def test_nft_mint_rpc(wallet_environments: WalletTestFramework, zero_royal
fee = 100
num_chunks = int(n / chunk) + (1 if n % chunk > 0 else 0)
required_amount = n + (fee * num_chunks)
xch_coins = await env_0.rpc_client.select_coins(
amount=required_amount,
coin_selection_config=wallet_environments.tx_config.coin_selection_config,
wallet_id=wallet_0.id(),
select_coins_response = await env_0.rpc_client.select_coins(
SelectCoins.from_coin_selection_config(
amount=uint64(required_amount),
coin_selection_config=wallet_environments.tx_config.coin_selection_config,
wallet_id=wallet_0.id(),
)
)
funding_coin = xch_coins[0]
funding_coin = select_coins_response.coins[0]
assert funding_coin.amount >= required_amount
funding_coin_dict = xch_coins[0].to_json_dict()
next_coin = funding_coin
did_coin = (
await env_0.rpc_client.select_coins(
amount=1,
coin_selection_config=wallet_environments.tx_config.coin_selection_config,
wallet_id=env_0.wallet_aliases["did"],
SelectCoins.from_coin_selection_config(
amount=uint64(1),
coin_selection_config=wallet_environments.tx_config.coin_selection_config,
wallet_id=uint32(env_0.wallet_aliases["did"]),
)
)
)[0]
).coins[0]
did_lineage_parent: Optional[bytes32] = None
txs: list[TransactionRecord] = []
nft_ids = set()
Expand All @@ -321,7 +324,7 @@ async def test_nft_mint_rpc(wallet_environments: WalletTestFramework, zero_royal
mint_number_start=uint16(i + 1),
mint_total=uint16(n),
xch_coins=[next_coin],
xch_change_target=funding_coin_dict["puzzle_hash"],
xch_change_target=funding_coin.puzzle_hash.hex(),
did_coin=did_coin if with_did else None,
did_lineage_parent=did_lineage_parent if with_did else None,
mint_from_did=with_did,
Expand Down
Loading
Loading