3030SOURCE_TAG = 11747
3131
3232FINISH_FUNCTION = (
33- "0061736d010000000105016000017f02190108686f73745f6c69620c6765"
34- "744c656467657253716e00000302010005030100100611027f00418080c0"
35- "000b7f00418080c0000b072e04066d656d6f727902000666696e69736800"
36- "010a5f5f646174615f656e6403000b5f5f686561705f6261736503010a09"
37- "010700100041044a0b004d0970726f64756365727302086c616e67756167"
38- "65010452757374000c70726f6365737365642d6279010572757374631d31"
39- "2e38352e31202834656231363132353020323032352d30332d3135290049"
40- "0f7461726765745f6665617475726573042b0f6d757461626c652d676c6f"
41- "62616c732b087369676e2d6578742b0f7265666572656e63652d74797065"
42- "732b0a6d756c746976616c7565"
33+ "0061736d0100000001150460027f7f017f60037f7f7e017f6000017f60000002300208686f73745f6"
34+ "c69620e6765745f6c65646765725f73716e000008686f73745f6c69620974726163655f6e756d0001"
35+ "030302020305030100110619037f01418080c0000b7f00418b80c0000b7f00419080c0000b072e040"
36+ "66d656d6f727902000666696e69736800020a5f5f646174615f656e6403010b5f5f686561705f6261"
37+ "736503020a69026301027f23808080800041106b22002480808080002000410036020c02402000410"
38+ "c6a41081080808080002201417f4a0d00418080c08000410b2001ac1081808080001a108380808000"
39+ "000b200028020c2101200041106a248080808000200141044b0b0300000b0b140100418080c0000b0"
40+ "b6572726f725f636f64653d00dd01046e616d6500100f6c65646765725f73716e2e7761736d01a301"
41+ "0400355f5a4e387872706c5f73746434686f737431346765745f6c65646765725f73716e313768666"
42+ "5343539333764623461656439366245012f5f5a4e387872706c5f73746434686f7374397472616365"
43+ "5f6e756d3137686139376531613763346138636231333245020666696e69736803305f5a4e34636f7"
44+ "2653970616e69636b696e673970616e69635f666d7431376862393162616461636536656538323837"
45+ "45071201000f5f5f737461636b5f706f696e746572090a0100072e726f64617461004d0970726f647"
46+ "56365727302086c616e6775616765010452757374000c70726f6365737365642d6279010572757374"
47+ "631d312e38352e31202834656231363132353020323032352d30332d31352900490f7461726765745"
48+ "f6665617475726573042b0a6d756c746976616c75652b0f6d757461626c652d676c6f62616c732b0f"
49+ "7265666572656e63652d74797065732b087369676e2d657874"
4350)
4451
4552issuer = Wallet .create ()
5259class TestEscrow (IntegrationTestCase ):
5360 @classmethod
5461 def setUpClass (cls ):
55- global good_mpt_issuance_id , bad_mpt_issuance_id
5662 super ().setUpClass ()
5763
5864 client = JSON_RPC_CLIENT
5965
6066 # Create issuer, source, and destination wallets.
61- fund_wallet ( issuer )
62- fund_wallet ( source )
63- fund_wallet ( destination )
67+ cls . issuer = Wallet . create ( )
68+ cls . source = Wallet . create ( )
69+ cls . destination = Wallet . create ( )
6470
65- good_mpt_issuance_id = create_mpt_token_and_authorize_source (
66- issuer ,
67- source ,
71+ fund_wallet (cls .issuer )
72+ fund_wallet (cls .source )
73+ fund_wallet (cls .destination )
74+
75+ cls .good_mpt_issuance_id = create_mpt_token_and_authorize_source (
76+ cls .issuer ,
77+ cls .source ,
6878 client ,
6979 [
7080 MPTokenIssuanceCreateFlag .TF_MPT_CAN_ESCROW ,
7181 MPTokenIssuanceCreateFlag .TF_MPT_CAN_TRANSFER ,
7282 ],
7383 )
7484
75- bad_mpt_issuance_id = create_mpt_token_and_authorize_source (
76- issuer ,
77- source ,
85+ cls . bad_mpt_issuance_id = create_mpt_token_and_authorize_source (
86+ cls . issuer ,
87+ cls . source ,
7888 client ,
7989 )
8090
@@ -113,28 +123,62 @@ async def test_all_fields_cancel(self, client):
113123 self .assertEqual (response .status , ResponseStatus .SUCCESS )
114124 self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
115125
126+ @test_async_and_sync (globals ())
127+ async def test_all_fields_finish (self , client ):
128+ ledger = await client .request (Ledger (ledger_index = "validated" ))
129+ close_time = ledger .result ["ledger" ]["close_time" ]
130+ escrow_create = EscrowCreate (
131+ account = ACCOUNT ,
132+ amount = AMOUNT ,
133+ destination = DESTINATION .classic_address ,
134+ destination_tag = DESTINATION_TAG ,
135+ finish_after = close_time + 2 ,
136+ source_tag = SOURCE_TAG ,
137+ )
138+ response = await sign_and_reliable_submission_async (
139+ escrow_create , WALLET , client
140+ )
141+ self .assertEqual (response .status , ResponseStatus .SUCCESS )
142+ self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
143+ sequence = response .result ["tx_json" ]["Sequence" ]
144+ # TODO: check account_objects
145+
146+ for _ in range (2 ):
147+ await accept_ledger_async (wait = True )
148+
149+ escrow_finish = EscrowFinish (
150+ account = ACCOUNT ,
151+ owner = ACCOUNT ,
152+ offer_sequence = sequence ,
153+ )
154+ response = await sign_and_reliable_submission_async (
155+ escrow_finish , WALLET , client
156+ )
157+ self .assertEqual (response .status , ResponseStatus .SUCCESS )
158+ self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
159+
116160 @test_async_and_sync (globals ())
117161 async def test_mpt_based_escrow (self , client ):
118162 # Create Escrow with MPToken.
119163 ledger = await client .request (Ledger (ledger_index = "validated" ))
120164 close_time = ledger .result ["ledger" ]["close_time" ]
121165
122166 escrowed_amount = MPTAmount (
123- mpt_issuance_id = good_mpt_issuance_id ,
167+ mpt_issuance_id = self . good_mpt_issuance_id ,
124168 value = "1" ,
125169 )
126170
127171 finish_after = close_time + 2
128172
129173 escrow_create = EscrowCreate (
130- account = source .classic_address ,
174+ account = self . source .classic_address ,
131175 amount = escrowed_amount ,
132- destination = destination .classic_address ,
176+ destination = self . destination .classic_address ,
133177 finish_after = finish_after ,
134178 cancel_after = close_time + 1000 ,
135179 )
136180 response = await sign_and_reliable_submission_async (
137- escrow_create , source , client
181+ escrow_create , self . source , client
138182 )
139183 escrow_create_seq = response .result ["tx_json" ]["Sequence" ]
140184
@@ -143,7 +187,7 @@ async def test_mpt_based_escrow(self, client):
143187
144188 # Confirm Escrow ledger object was created.
145189 account_objects_response = await client .request (
146- AccountObjects (account = source .address , type = AccountObjectType .ESCROW )
190+ AccountObjects (account = self . source .address , type = AccountObjectType .ESCROW )
147191 )
148192
149193 escrow_objects = account_objects_response .result ["account_objects" ]
@@ -154,7 +198,7 @@ async def test_mpt_based_escrow(self, client):
154198
155199 # Confirm MPToken ledger object was created.
156200 account_objects_response = await client .request (
157- AccountObjects (account = source .address , type = AccountObjectType .MPTOKEN )
201+ AccountObjects (account = self . source .address , type = AccountObjectType .MPTOKEN )
158202 )
159203 mptoken_objects = account_objects_response .result ["account_objects" ]
160204 self .assertTrue (
@@ -168,7 +212,9 @@ async def test_mpt_based_escrow(self, client):
168212
169213 # Confirm MPTokenIssuance ledger object was created.
170214 account_objects_response = await client .request (
171- AccountObjects (account = issuer .address , type = AccountObjectType .MPT_ISSUANCE )
215+ AccountObjects (
216+ account = self .issuer .address , type = AccountObjectType .MPT_ISSUANCE
217+ )
172218 )
173219
174220 mpt_issuance_objects = account_objects_response .result ["account_objects" ]
@@ -192,19 +238,21 @@ async def test_mpt_based_escrow(self, client):
192238
193239 # Finish the escrow.
194240 escrow_finish = EscrowFinish (
195- account = destination .classic_address ,
196- owner = source .classic_address ,
241+ account = self . destination .classic_address ,
242+ owner = self . source .classic_address ,
197243 offer_sequence = escrow_create_seq ,
198244 )
199245 response = await sign_and_reliable_submission_async (
200- escrow_finish , destination , client
246+ escrow_finish , self . destination , client
201247 )
202248 self .assertEqual (response .status , ResponseStatus .SUCCESS )
203249 self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
204250
205251 # Confirm MPToken ledger object was created for destination.
206252 account_objects_response = await client .request (
207- AccountObjects (account = destination .address , type = AccountObjectType .MPTOKEN )
253+ AccountObjects (
254+ account = self .destination .address , type = AccountObjectType .MPTOKEN
255+ )
208256 )
209257
210258 dest_mptoken_objects = account_objects_response .result ["account_objects" ]
@@ -224,62 +272,28 @@ async def test_mpt_based_escrow_failure(self, client):
224272 close_time = ledger .result ["ledger" ]["close_time" ]
225273
226274 escrowed_amount = MPTAmount (
227- mpt_issuance_id = bad_mpt_issuance_id ,
275+ mpt_issuance_id = self . bad_mpt_issuance_id ,
228276 value = "1" ,
229277 )
230278
231279 finish_after = close_time + 2
232280
233281 escrow_create = EscrowCreate (
234- account = source .classic_address ,
282+ account = self . source .classic_address ,
235283 amount = escrowed_amount ,
236- destination = destination .classic_address ,
284+ destination = self . destination .classic_address ,
237285 finish_after = finish_after ,
238286 cancel_after = close_time + 1000 ,
239287 )
240288
241289 # Transaction fails with tecNO_PERMISSION because lsfMPTCanEscrow is not set.
242290 response = await sign_and_reliable_submission_async (
243- escrow_create , source , client
291+ escrow_create , self . source , client
244292 )
245293
246294 self .assertEqual (response .status , ResponseStatus .SUCCESS )
247295 self .assertEqual (response .result ["engine_result" ], "tecNO_PERMISSION" )
248296
249- @test_async_and_sync (globals ())
250- async def test_all_fields_finish (self , client ):
251- ledger = await client .request (Ledger (ledger_index = "validated" ))
252- close_time = ledger .result ["ledger" ]["close_time" ]
253- escrow_create = EscrowCreate (
254- account = ACCOUNT ,
255- amount = AMOUNT ,
256- destination = DESTINATION .classic_address ,
257- destination_tag = DESTINATION_TAG ,
258- finish_after = close_time + 2 ,
259- source_tag = SOURCE_TAG ,
260- )
261- response = await sign_and_reliable_submission_async (
262- escrow_create , WALLET , client
263- )
264- self .assertEqual (response .status , ResponseStatus .SUCCESS )
265- self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
266- sequence = response .result ["tx_json" ]["Sequence" ]
267- # TODO: check account_objects
268-
269- for _ in range (2 ):
270- await accept_ledger_async (wait = True )
271-
272- escrow_finish = EscrowFinish (
273- account = ACCOUNT ,
274- owner = ACCOUNT ,
275- offer_sequence = sequence ,
276- )
277- response = await sign_and_reliable_submission_async (
278- escrow_finish , WALLET , client
279- )
280- self .assertEqual (response .status , ResponseStatus .SUCCESS )
281- self .assertEqual (response .result ["engine_result" ], "tesSUCCESS" )
282-
283297 @test_async_and_sync (globals ())
284298 async def test_finish_function (self , client ):
285299 ledger = await client .request (Ledger (ledger_index = "validated" ))
@@ -303,7 +317,7 @@ async def test_finish_function(self, client):
303317 account = ACCOUNT ,
304318 owner = ACCOUNT ,
305319 offer_sequence = sequence ,
306- computation_allowance = 5 ,
320+ computation_allowance = 20000 ,
307321 )
308322 response = await sign_and_reliable_submission_async (
309323 escrow_finish , WALLET , client
0 commit comments