Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions chia/_tests/cmds/cmd_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ async def get_wallets(self, request: GetWallets) -> GetWalletsResponse:
w_type = WalletType.POOLING_WALLET
else:
raise ValueError(f"Invalid fingerprint: {self.fingerprint}")
return GetWalletsResponse([WalletInfoResponse(id=uint32(1), name="", type=uint8(w_type.value), data="")])
return GetWalletsResponse(
wallets=[WalletInfoResponse(id=uint32(1), name="", type=uint8(w_type.value), data="")]
)

async def get_transaction(self, request: GetTransaction) -> GetTransactionResponse:
self.add_to_log("get_transaction", (request,))
return GetTransactionResponse(
TransactionRecord(
transaction=TransactionRecord(
confirmed_at_height=uint32(1),
created_at_time=uint64(1234),
to_puzzle_hash=bytes32([1] * 32),
Expand All @@ -149,12 +151,12 @@ async def get_transaction(self, request: GetTransaction) -> GetTransactionRespon
memos={bytes32([3] * 32): [bytes([4] * 32)]},
valid_times=ConditionValidTimes(),
),
bytes32([2] * 32),
transaction_id=bytes32([2] * 32),
)

async def get_cat_name(self, request: CATGetName) -> CATGetNameResponse:
self.add_to_log("get_cat_name", (request.wallet_id,))
return CATGetNameResponse(request.wallet_id, "test" + str(request.wallet_id))
return CATGetNameResponse(wallet_id=request.wallet_id, name="test" + str(request.wallet_id))

async def sign_message_by_address(self, request: SignMessageByAddress) -> SignMessageByAddressResponse:
self.add_to_log("sign_message_by_address", (request.address, request.message))
Expand All @@ -170,7 +172,7 @@ async def sign_message_by_address(self, request: SignMessageByAddress) -> SignMe
)
)
signing_mode = SigningMode.CHIP_0002.value
return SignMessageByAddressResponse(pubkey, signature, signing_mode)
return SignMessageByAddressResponse(pubkey=pubkey, signature=signature, signing_mode=signing_mode)

async def sign_message_by_id(self, request: SignMessageByID) -> SignMessageByIDResponse:
self.add_to_log("sign_message_by_id", (request.id, request.message))
Expand All @@ -186,7 +188,9 @@ async def sign_message_by_id(self, request: SignMessageByID) -> SignMessageByIDR
)
)
signing_mode = SigningMode.CHIP_0002.value
return SignMessageByIDResponse(pubkey, signature, bytes32.zeros, signing_mode)
return SignMessageByIDResponse(
pubkey=pubkey, signature=signature, latest_coin_id=bytes32.zeros, signing_mode=signing_mode
)

async def cat_asset_id_to_name(self, request: CATAssetIDToName) -> CATAssetIDToNameResponse:
"""
Expand All @@ -195,7 +199,7 @@ async def cat_asset_id_to_name(self, request: CATAssetIDToName) -> CATAssetIDToN
self.add_to_log("cat_asset_id_to_name", (request.asset_id,))
for i in range(256):
if request.asset_id == get_bytes32(i):
return CATAssetIDToNameResponse(uint32(i + 1), "test" + str(i))
return CATAssetIDToNameResponse(wallet_id=uint32(i + 1), name="test" + str(i))
return CATAssetIDToNameResponse(wallet_id=None, name=None)

async def get_nft_info(self, request: NFTGetInfo) -> NFTGetInfoResponse:
Expand Down Expand Up @@ -223,7 +227,7 @@ async def get_nft_info(self, request: NFTGetInfo) -> NFTGetInfoResponse:
supports_did=True,
p2_address=bytes32([8] * 32),
)
return NFTGetInfoResponse(nft_info)
return NFTGetInfoResponse(nft_info=nft_info)

async def nft_calculate_royalties(
self,
Expand All @@ -246,8 +250,8 @@ async def create_new_wallet(
) -> CreateNewWalletResponse:
self.add_to_log("create_new_wallet", (request, tx_config, extra_conditions, timelock_info))
return CreateNewWalletResponse(
[STD_UTX],
[STD_TX],
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
type=(
WalletType.NFT if request.wallet_type == CreateNewWalletType.NFT_WALLET else WalletType.DECENTRALIZED_ID
).name,
Expand Down
21 changes: 13 additions & 8 deletions chia/_tests/cmds/wallet/test_did.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_did_set_name(capsys: object, get_test_cli_clients: tuple[TestRpcClients
class DidSetNameRpcClient(TestWalletRpcClient):
async def did_set_wallet_name(self, request: DIDSetWalletName) -> DIDSetWalletNameResponse:
self.add_to_log("did_set_wallet_name", (request.wallet_id, request.name))
return DIDSetWalletNameResponse(request.wallet_id)
return DIDSetWalletNameResponse(wallet_id=request.wallet_id)

inst_rpc_client = DidSetNameRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -239,7 +239,10 @@ async def update_did_metadata(
(request.wallet_id, request.metadata, tx_config, request.push, extra_conditions, timelock_info),
)
return DIDUpdateMetadataResponse(
[STD_UTX], [STD_TX], WalletSpendBundle([], G2Element()), uint32(request.wallet_id)
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
spend_bundle=WalletSpendBundle([], G2Element()),
wallet_id=uint32(request.wallet_id),
)

inst_rpc_client = DidUpdateMetadataRpcClient()
Expand Down Expand Up @@ -282,7 +285,7 @@ async def find_lost_did(self, request: DIDFindLostDID) -> DIDFindLostDIDResponse
"find_lost_did",
(request.coin_id, request.recovery_list_hash, request.metadata, request.num_verification),
)
return DIDFindLostDIDResponse(get_bytes32(2))
return DIDFindLostDIDResponse(latest_coin_id=get_bytes32(2))

inst_rpc_client = DidFindLostRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -322,7 +325,9 @@ async def did_message_spend(
self.add_to_log(
"did_message_spend", (request.wallet_id, tx_config, extra_conditions, request.push, timelock_info)
)
return DIDMessageSpendResponse([STD_UTX], [STD_TX], WalletSpendBundle([], G2Element()))
return DIDMessageSpendResponse(
unsigned_transactions=[STD_UTX], transactions=[STD_TX], spend_bundle=WalletSpendBundle([], G2Element())
)

inst_rpc_client = DidMessageSpendRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -391,10 +396,10 @@ async def did_transfer_did(
),
)
return DIDTransferDIDResponse(
[STD_UTX],
[STD_TX],
STD_TX,
STD_TX.name,
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
transaction=STD_TX,
transaction_id=STD_TX.name,
)

inst_rpc_client = DidTransferRpcClient()
Expand Down
39 changes: 23 additions & 16 deletions chia/_tests/cmds/wallet/test_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def test_nft_mint(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
class NFTCreateRpcClient(TestWalletRpcClient):
async def get_nft_wallet_did(self, request: NFTGetWalletDID) -> NFTGetWalletDIDResponse:
self.add_to_log("get_nft_wallet_did", (request.wallet_id,))
return NFTGetWalletDIDResponse("did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c")
return NFTGetWalletDIDResponse(
did_id="did:chia:1qgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4msw0c"
)

async def mint_nft(
self,
Expand Down Expand Up @@ -123,11 +125,11 @@ async def mint_nft(
),
)
return NFTMintNFTResponse(
[STD_UTX],
[STD_TX],
uint32(request.wallet_id),
WalletSpendBundle([], G2Element()),
bytes32.zeros.hex(),
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
wallet_id=uint32(request.wallet_id),
spend_bundle=WalletSpendBundle([], G2Element()),
nft_id=bytes32.zeros.hex(),
)

inst_rpc_client = NFTCreateRpcClient()
Expand Down Expand Up @@ -215,7 +217,12 @@ async def add_uri_to_nft(
extra_conditions,
),
)
return NFTAddURIResponse([STD_UTX], [STD_TX], request.wallet_id, WalletSpendBundle([], G2Element()))
return NFTAddURIResponse(
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
wallet_id=request.wallet_id,
spend_bundle=WalletSpendBundle([], G2Element()),
)

inst_rpc_client = NFTAddUriRpcClient()
nft_coin_id = get_bytes32(2).hex()
Expand Down Expand Up @@ -285,10 +292,10 @@ async def transfer_nft(
),
)
return NFTTransferNFTResponse(
[STD_UTX],
[STD_TX],
request.wallet_id,
WalletSpendBundle([], G2Element()),
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
wallet_id=request.wallet_id,
spend_bundle=WalletSpendBundle([], G2Element()),
)

inst_rpc_client = NFTTransferRpcClient()
Expand Down Expand Up @@ -367,7 +374,7 @@ async def list_nfts(self, request: NFTGetNFTs) -> NFTGetNFTsResponse:
p2_address=get_bytes32(8),
)
)
return NFTGetNFTsResponse(request.wallet_id, nft_list)
return NFTGetNFTsResponse(wallet_id=request.wallet_id, nft_list=nft_list)

inst_rpc_client = NFTListRpcClient()
launcher_ids = [bytes32([i] * 32).hex() for i in range(50, 60)]
Expand Down Expand Up @@ -422,10 +429,10 @@ async def set_nft_did(
),
)
return NFTSetNFTDIDResponse(
[STD_UTX],
[STD_TX],
request.wallet_id,
WalletSpendBundle([], G2Element()),
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
wallet_id=request.wallet_id,
spend_bundle=WalletSpendBundle([], G2Element()),
)

inst_rpc_client = NFTSetDidRpcClient()
Expand Down
8 changes: 5 additions & 3 deletions chia/_tests/cmds/wallet/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def send_notification(
(request.target, request.message, request.amount, request.fee, request.push, timelock_info),
)

return SendNotificationResponse([STD_UTX], [STD_TX], tx=STD_TX)
return SendNotificationResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX], tx=STD_TX)

inst_rpc_client = NotificationsSendRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -82,7 +82,7 @@ class NotificationsGetRpcClient(TestWalletRpcClient):
async def get_notifications(self, request: GetNotifications) -> GetNotificationsResponse:
self.add_to_log("get_notifications", (request,))
return GetNotificationsResponse(
[Notification(get_bytes32(1), bytes("hello", "utf8"), uint64(1000000000), uint32(50))]
notifications=[Notification(get_bytes32(1), bytes("hello", "utf8"), uint64(1000000000), uint32(50))]
)

inst_rpc_client = NotificationsGetRpcClient()
Expand All @@ -104,7 +104,9 @@ async def get_notifications(self, request: GetNotifications) -> GetNotifications
"amount: 1000000000",
]
run_cli_command_and_assert(capsys, root_dir, command_args, assert_list)
expected_calls: logType = {"get_notifications": [(GetNotifications([get_bytes32(1)], uint32(10), uint32(10)),)]}
expected_calls: logType = {
"get_notifications": [(GetNotifications(ids=[get_bytes32(1)], start=uint32(10), end=uint32(10)),)]
}
test_rpc_clients.wallet_rpc_client.check_log(expected_calls)


Expand Down
22 changes: 11 additions & 11 deletions chia/_tests/cmds/wallet/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ async def vc_mint(
)

return VCMintResponse(
[STD_UTX],
[STD_TX],
VCRecord(
unsigned_transactions=[STD_UTX],
transactions=[STD_TX],
vc_record=VCRecord(
VerifiedCredential(
STD_TX.removals[0],
LineageProof(None, None, None),
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_vcs_get(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pat
class VcsGetRpcClient(TestWalletRpcClient):
async def vc_get_list(self, request: VCGetList) -> VCGetListResponse:
self.add_to_log("vc_get_list", (request.start, request.end))
proofs = [VCProofWithHash(get_bytes32(1), VCProofsRPC([("proof here", "")]))]
proofs = [VCProofWithHash(hash=get_bytes32(1), proof=VCProofsRPC(key_value_pairs=[("proof here", "")]))]
records = [
VCRecordWithCoinID(
VerifiedCredential(
Expand All @@ -123,10 +123,10 @@ async def vc_get_list(self, request: VCGetList) -> VCGetListResponse:
None,
),
uint32(0),
bytes32.zeros,
coin_id=bytes32.zeros,
)
]
return VCGetListResponse(records, proofs)
return VCGetListResponse(vc_records=records, proofs=proofs)

inst_rpc_client = VcsGetRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -166,7 +166,7 @@ async def vc_spend(
timelock_info,
),
)
return VCSpendResponse([STD_UTX], [STD_TX])
return VCSpendResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])

inst_rpc_client = VcsUpdateProofsRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_vcs_get_proofs_for_root(capsys: object, get_test_cli_clients: tuple[Tes
class VcsGetProofsForRootRpcClient(TestWalletRpcClient):
async def vc_get_proofs_for_root(self, request: VCGetProofsForRoot) -> VCGetProofsForRootResponse:
self.add_to_log("vc_get_proofs_for_root", (request.root,))
return VCGetProofsForRootResponse([("test_proof", "1"), ("test_proof2", "1")])
return VCGetProofsForRootResponse(key_value_pairs=[("test_proof", "1"), ("test_proof2", "1")])

inst_rpc_client = VcsGetProofsForRootRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand All @@ -264,7 +264,7 @@ async def vc_get(self, request: VCGet) -> VCGetResponse:
self.add_to_log("vc_get", (request.vc_id,))

return VCGetResponse(
VCRecord(
vc_record=VCRecord(
VerifiedCredential(
Coin(get_bytes32(1), get_bytes32(2), uint64(12345678)),
LineageProof(),
Expand All @@ -285,7 +285,7 @@ async def vc_revoke(
timelock_info: ConditionValidTimes = ConditionValidTimes(),
) -> VCRevokeResponse:
self.add_to_log("vc_revoke", (request.vc_parent_id, tx_config, request.fee, request.push, timelock_info))
return VCRevokeResponse([STD_UTX], [STD_TX])
return VCRevokeResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])

inst_rpc_client = VcsRevokeRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down Expand Up @@ -352,7 +352,7 @@ async def crcat_approve_pending(
timelock_info,
),
)
return CRCATApprovePendingResponse([STD_UTX], [STD_TX])
return CRCATApprovePendingResponse(unsigned_transactions=[STD_UTX], transactions=[STD_TX])

inst_rpc_client = VcsApproveRCATSRpcClient()
test_rpc_clients.wallet_rpc_client = inst_rpc_client
Expand Down
Loading
Loading