11from tests .integration .integration_test_case import IntegrationTestCase
22from tests .integration .it_utils import (
3+ create_mpt_token_and_authorize_source_async ,
4+ fund_wallet_async ,
35 sign_and_reliable_submission_async ,
46 test_async_and_sync ,
57)
68from tests .integration .reusable_values import WALLET
9+ from xrpl .models .amounts import MPTAmount
10+ from xrpl .models .requests .account_objects import AccountObjects , AccountObjectType
711from xrpl .models .response import ResponseStatus
8- from xrpl .models .transactions import CheckCash
12+ from xrpl .models .transactions import CheckCash , CheckCreate , MPTokenIssuanceCreateFlag
13+ from xrpl .wallet import Wallet
914
1015ACCOUNT = WALLET .address
1116CHECK_ID = "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
1217AMOUNT = "100000000"
1318DELIVER_MIN = "100000000"
1419
1520
16- class TestCheckCreate (IntegrationTestCase ):
21+ class TestCheckCash (IntegrationTestCase ):
1722 @test_async_and_sync (globals ())
1823 async def test_required_fields_with_amount (self , client ):
1924 check_cash = CheckCash (
@@ -36,3 +41,65 @@ async def test_required_fields_with_deliver_min(self, client):
3641 response = await sign_and_reliable_submission_async (check_cash , WALLET , client )
3742 self .assertEqual (response .status , ResponseStatus .SUCCESS )
3843 self .assertEqual (response .result ["engine_result" ], "tecNO_ENTRY" )
44+
45+ @test_async_and_sync (globals ())
46+ async def test_check_cash_with_mpt (self , client ):
47+ issuer = Wallet .create ()
48+ await fund_wallet_async (issuer )
49+ destination_check_wallet = Wallet .create ()
50+ await fund_wallet_async (destination_check_wallet )
51+
52+ mpt_issuance_id = await create_mpt_token_and_authorize_source_async (
53+ issuer = issuer ,
54+ source = destination_check_wallet ,
55+ client = client ,
56+ flags = [
57+ MPTokenIssuanceCreateFlag .TF_MPT_CAN_TRANSFER ,
58+ MPTokenIssuanceCreateFlag .TF_MPT_CAN_TRADE ,
59+ ],
60+ )
61+
62+ # Issuer creates a check to destination for 50 MPT
63+ mpt_amount = MPTAmount (mpt_issuance_id = mpt_issuance_id , value = "50" )
64+ create_response = await sign_and_reliable_submission_async (
65+ CheckCreate (
66+ account = issuer .classic_address ,
67+ destination = destination_check_wallet .classic_address ,
68+ send_max = mpt_amount ,
69+ ),
70+ issuer ,
71+ client ,
72+ )
73+ self .assertEqual (create_response .result ["engine_result" ], "tesSUCCESS" )
74+
75+ # Find the check ID
76+ account_objects_response = await client .request (
77+ AccountObjects (
78+ account = destination_check_wallet .classic_address ,
79+ type = AccountObjectType .CHECK ,
80+ )
81+ )
82+ checks = account_objects_response .result ["account_objects" ]
83+ self .assertEqual (len (checks ), 1 )
84+ mpt_check_id = checks [0 ]["index" ]
85+
86+ # Destination cashes the check
87+ cash_response = await sign_and_reliable_submission_async (
88+ CheckCash (
89+ account = destination_check_wallet .classic_address ,
90+ check_id = mpt_check_id ,
91+ amount = mpt_amount ,
92+ ),
93+ destination_check_wallet ,
94+ client ,
95+ )
96+ self .assertEqual (cash_response .result ["engine_result" ], "tesSUCCESS" )
97+
98+ # Verify the check was consumed
99+ account_objects_response = await client .request (
100+ AccountObjects (
101+ account = destination_check_wallet .classic_address ,
102+ type = AccountObjectType .CHECK ,
103+ )
104+ )
105+ self .assertEqual (len (account_objects_response .result ["account_objects" ]), 0 )
0 commit comments