From f9587c6dc7ec278df136751e7f3e5c34aec3cd50 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:02:08 -0400 Subject: [PATCH 01/14] allow keypairs.sign to take a string --- xrpl/core/keypairs/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/core/keypairs/main.py b/xrpl/core/keypairs/main.py index e61dbf1a7..804087336 100644 --- a/xrpl/core/keypairs/main.py +++ b/xrpl/core/keypairs/main.py @@ -94,7 +94,7 @@ def derive_classic_address(public_key: str) -> str: return addresscodec.encode_classic_address(account_id) -def sign(message: bytes, private_key: str) -> str: +def sign(message: str | bytes, private_key: str) -> str: """ Sign a message using a given private key. @@ -105,6 +105,8 @@ def sign(message: bytes, private_key: str) -> str: Returns: Signed message, as hexadecimal. """ + if isinstance(message, str): + message = bytes.fromhex(message) return ( _get_module_from_key(private_key) .sign( From a7274bb52f0c6049b268ae728b19ab15f7ac01ba Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:02:43 -0400 Subject: [PATCH 02/14] fix SignerListSet validation --- xrpl/models/transactions/signer_list_set.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/signer_list_set.py b/xrpl/models/transactions/signer_list_set.py index 27bef23e3..b3695242e 100644 --- a/xrpl/models/transactions/signer_list_set.py +++ b/xrpl/models/transactions/signer_list_set.py @@ -97,11 +97,19 @@ def _get_errors(self: SignerListSet) -> Dict[str, str]: if self.signer_entries is None: # deletion of the SignerList object return errors - if self.signer_quorum <= 0: + if self.signer_quorum == REQUIRED: + errors["signer_quorum"] = "`signer_quorum` is not set." + elif self.signer_quorum <= 0: errors[ "signer_quorum" ] = "`signer_quorum` must be greater than or equal to 0." + if not isinstance(self.signer_entries, list): + errors[ + "signer_entries" + ] = "`signer_entries` must be a list of `SignerEntry` objects." + return errors + if ( len(self.signer_entries) < 1 or len(self.signer_entries) > MAX_SIGNER_ENTRIES From 4125c2bab9bf349a4ac2a3d8d259b9d015e49125 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:04:05 -0400 Subject: [PATCH 03/14] actually close a ledger after submitting a transaction --- .vscode/settings.json | 1 + tests/integration/it_utils.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index dbe5093cc..b6d7106dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,7 @@ "asyncio", "binarycodec", "keypair", + "keypairs", "nftoken", "rippletest", "ripplex", diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 8b46ad77a..3ffb84bc4 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -126,9 +126,11 @@ def submit_transaction( check_fee: bool = True, ) -> Response: """Signs and submits a transaction to the XRPL.""" - return safe_sign_and_submit_transaction( + response = safe_sign_and_submit_transaction( transaction, wallet, client, check_fee=check_fee ) + client.request(LEDGER_ACCEPT_REQUEST) + return response async def submit_transaction_async( @@ -137,7 +139,11 @@ async def submit_transaction_async( client: Client = ASYNC_JSON_RPC_CLIENT, check_fee: bool = True, ) -> Response: - return await sign_and_submit_async(transaction, wallet, client, check_fee=check_fee) + response = await sign_and_submit_async( + transaction, wallet, client, check_fee=check_fee + ) + await client.request(LEDGER_ACCEPT_REQUEST) + return response def sign_and_reliable_submission( From 67e1f2d1088beb5f733b7504cfdb1efc7d33e0d7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:07:11 -0400 Subject: [PATCH 04/14] actually use the websocket client in tests --- tests/integration/it_utils.py | 2 +- tests/integration/sugar/test_transaction.py | 4 ++-- tests/integration/transactions/test_account_set.py | 4 ++-- tests/integration/transactions/test_check_cancel.py | 2 +- tests/integration/transactions/test_check_cash.py | 4 ++-- tests/integration/transactions/test_check_create.py | 2 +- tests/integration/transactions/test_deposit_preauth.py | 4 ++-- tests/integration/transactions/test_escrow_cancel.py | 2 +- tests/integration/transactions/test_escrow_create.py | 2 +- tests/integration/transactions/test_escrow_finish.py | 2 +- tests/integration/transactions/test_offer_cancel.py | 1 + tests/integration/transactions/test_offer_create.py | 1 + tests/integration/transactions/test_payment.py | 1 + tests/integration/transactions/test_payment_channel_claim.py | 1 + tests/integration/transactions/test_payment_channel_create.py | 1 + tests/integration/transactions/test_payment_channel_fund.py | 1 + tests/integration/transactions/test_set_regular_key.py | 1 + tests/integration/transactions/test_signer_list_set.py | 1 + tests/integration/transactions/test_ticket_create.py | 1 + tests/integration/transactions/test_trust_set.py | 1 + 20 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 3ffb84bc4..0c23dbe7a 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -136,7 +136,7 @@ def submit_transaction( async def submit_transaction_async( transaction: Transaction, wallet: Wallet, - client: Client = ASYNC_JSON_RPC_CLIENT, + client: Client, check_fee: bool = True, ) -> Response: response = await sign_and_submit_async( diff --git a/tests/integration/sugar/test_transaction.py b/tests/integration/sugar/test_transaction.py index a0ee87d74..bb92a8eb2 100644 --- a/tests/integration/sugar/test_transaction.py +++ b/tests/integration/sugar/test_transaction.py @@ -89,7 +89,7 @@ async def test_high_fee_account_delete_unauthorized(self, client): ) # We expect an XRPLException to be raised with self.assertRaises(XRPLException): - await submit_transaction_async(account_delete, WALLET) + await submit_transaction_async(account_delete, WALLET, client) @test_async_and_sync(globals()) async def test_high_fee_account_set_unauthorized(self, client): @@ -107,7 +107,7 @@ async def test_high_fee_account_set_unauthorized(self, client): ) # We expect an XRPLException to be raised with self.assertRaises(XRPLException): - await submit_transaction_async(account_set, WALLET) + await submit_transaction_async(account_set, WALLET, client) @test_async_and_sync(globals()) async def test_payment_high_fee_authorized(self, client): diff --git a/tests/integration/transactions/test_account_set.py b/tests/integration/transactions/test_account_set.py index fe223f110..1f8f00b29 100644 --- a/tests/integration/transactions/test_account_set.py +++ b/tests/integration/transactions/test_account_set.py @@ -22,7 +22,7 @@ async def test_required_fields_and_set_flag(self, client): account=ACCOUNT, set_flag=SET_FLAG, ) - response = await submit_transaction_async(account_set, WALLET) + response = await submit_transaction_async(account_set, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") @@ -37,6 +37,6 @@ async def test_all_fields_minus_set_flag(self, client): transfer_rate=TRANSFER_RATE, tick_size=TICK_SIZE, ) - response = await submit_transaction_async(account_set, WALLET) + response = await submit_transaction_async(account_set, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") diff --git a/tests/integration/transactions/test_check_cancel.py b/tests/integration/transactions/test_check_cancel.py index 1b541eabb..37f6d5a1f 100644 --- a/tests/integration/transactions/test_check_cancel.py +++ b/tests/integration/transactions/test_check_cancel.py @@ -16,7 +16,7 @@ async def test_all_fields(self, client): account=ACCOUNT, check_id=CHECK_ID, ) - response = await submit_transaction_async(check_cancel, WALLET) + response = await submit_transaction_async(check_cancel, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) # This transaction shouldn't actually succeed, because this isn't a real check: # Docs for tecNO_ENTRY read: diff --git a/tests/integration/transactions/test_check_cash.py b/tests/integration/transactions/test_check_cash.py index 4cbad92df..19895b52c 100644 --- a/tests/integration/transactions/test_check_cash.py +++ b/tests/integration/transactions/test_check_cash.py @@ -18,7 +18,7 @@ async def test_required_fields_with_amount(self, client): check_id=CHECK_ID, amount=AMOUNT, ) - response = await submit_transaction_async(check_cash, WALLET) + response = await submit_transaction_async(check_cash, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) # Getting `tecNO_ENTRY` codes because using a non-existent check ID self.assertEqual(response.result["engine_result"], "tecNO_ENTRY") @@ -30,6 +30,6 @@ async def test_required_fields_with_deliver_min(self, client): check_id=CHECK_ID, deliver_min=DELIVER_MIN, ) - response = await submit_transaction_async(check_cash, WALLET) + response = await submit_transaction_async(check_cash, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tecNO_ENTRY") diff --git a/tests/integration/transactions/test_check_create.py b/tests/integration/transactions/test_check_create.py index cf570f80a..5af636121 100644 --- a/tests/integration/transactions/test_check_create.py +++ b/tests/integration/transactions/test_check_create.py @@ -22,6 +22,6 @@ async def test_all_fields(self, client): expiration=EXPIRATION, invoice_id=INVOICE_ID, ) - response = await submit_transaction_async(check_create, WALLET) + response = await submit_transaction_async(check_create, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") diff --git a/tests/integration/transactions/test_deposit_preauth.py b/tests/integration/transactions/test_deposit_preauth.py index c98ab277a..e75fa0b36 100644 --- a/tests/integration/transactions/test_deposit_preauth.py +++ b/tests/integration/transactions/test_deposit_preauth.py @@ -15,7 +15,7 @@ async def test_authorize(self, client): account=ACCOUNT, authorize=ADDRESS, ) - response = await submit_transaction_async(deposit_preauth, WALLET) + response = await submit_transaction_async(deposit_preauth, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) @test_async_and_sync(globals()) @@ -24,5 +24,5 @@ async def test_unauthorize(self, client): account=ACCOUNT, unauthorize=ADDRESS, ) - response = await submit_transaction_async(deposit_preauth, WALLET) + response = await submit_transaction_async(deposit_preauth, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_cancel.py b/tests/integration/transactions/test_escrow_cancel.py index a1083b294..636003e66 100644 --- a/tests/integration/transactions/test_escrow_cancel.py +++ b/tests/integration/transactions/test_escrow_cancel.py @@ -17,6 +17,6 @@ async def test_all_fields(self, client): owner=OWNER, offer_sequence=OFFER_SEQUENCE, ) - response = await submit_transaction_async(escrow_cancel, WALLET) + response = await submit_transaction_async(escrow_cancel, WALLET, client) # Actual engine_result is `tecNO_TARGET since OWNER account doesn't exist self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_create.py b/tests/integration/transactions/test_escrow_create.py index de2352ed5..e0128bcfd 100644 --- a/tests/integration/transactions/test_escrow_create.py +++ b/tests/integration/transactions/test_escrow_create.py @@ -29,7 +29,7 @@ async def test_all_fields(self, client): finish_after=FINISH_AFTER, source_tag=SOURCE_TAG, ) - response = await submit_transaction_async(escrow_create, WALLET) + response = await submit_transaction_async(escrow_create, WALLET, client) # Actual engine_result will be `tecNO_PERMISSION`... # maybe due to CONDITION or something self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_finish.py b/tests/integration/transactions/test_escrow_finish.py index 7811d156d..7d9ea85e6 100644 --- a/tests/integration/transactions/test_escrow_finish.py +++ b/tests/integration/transactions/test_escrow_finish.py @@ -27,7 +27,7 @@ async def test_all_fields(self, client): condition=CONDITION, fulfillment=FULFILLMENT, ) - response = await submit_transaction_async(escrow_finish, WALLET) + response = await submit_transaction_async(escrow_finish, WALLET, client) # Actual engine_result will be 'tecNO_TARGET' since using non-extant # account for OWNER self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_offer_cancel.py b/tests/integration/transactions/test_offer_cancel.py index a6b191047..d7f409795 100644 --- a/tests/integration/transactions/test_offer_cancel.py +++ b/tests/integration/transactions/test_offer_cancel.py @@ -13,6 +13,7 @@ async def test_all_fields(self, client): offer_sequence=OFFER.result["tx_json"]["Sequence"], ), WALLET, + client, ) self.assertTrue(response.is_successful()) # NOTE: offer cancellations are difficult to test because not diff --git a/tests/integration/transactions/test_offer_create.py b/tests/integration/transactions/test_offer_create.py index af6957814..48309e7f7 100644 --- a/tests/integration/transactions/test_offer_create.py +++ b/tests/integration/transactions/test_offer_create.py @@ -19,5 +19,6 @@ async def test_basic_functionality(self, client): ), ), WALLET, + client, ) self.assertTrue(offer.is_successful()) diff --git a/tests/integration/transactions/test_payment.py b/tests/integration/transactions/test_payment.py index 8e6d0b759..f3a446f02 100644 --- a/tests/integration/transactions/test_payment.py +++ b/tests/integration/transactions/test_payment.py @@ -14,5 +14,6 @@ async def test_basic_functionality(self, client): destination=DESTINATION.classic_address, ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_payment_channel_claim.py b/tests/integration/transactions/test_payment_channel_claim.py index 386a480b6..89b4eb681 100644 --- a/tests/integration/transactions/test_payment_channel_claim.py +++ b/tests/integration/transactions/test_payment_channel_claim.py @@ -13,5 +13,6 @@ async def test_receiver_claim(self, client): channel=PAYMENT_CHANNEL.result["tx_json"]["hash"], ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_payment_channel_create.py b/tests/integration/transactions/test_payment_channel_create.py index 36a2cea7f..e803b031d 100644 --- a/tests/integration/transactions/test_payment_channel_create.py +++ b/tests/integration/transactions/test_payment_channel_create.py @@ -16,5 +16,6 @@ async def test_basic_functionality(self, client): public_key=WALLET.public_key, ), WALLET, + client, ) self.assertTrue(payment_channel.is_successful()) diff --git a/tests/integration/transactions/test_payment_channel_fund.py b/tests/integration/transactions/test_payment_channel_fund.py index 5d7313248..8370b8fe2 100644 --- a/tests/integration/transactions/test_payment_channel_fund.py +++ b/tests/integration/transactions/test_payment_channel_fund.py @@ -14,5 +14,6 @@ async def test_basic_functionality(self, client): amount="1", ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_set_regular_key.py b/tests/integration/transactions/test_set_regular_key.py index 8441e7d57..d030fb3ed 100644 --- a/tests/integration/transactions/test_set_regular_key.py +++ b/tests/integration/transactions/test_set_regular_key.py @@ -15,5 +15,6 @@ async def test_all_fields(self, client): regular_key=regular_key, ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_signer_list_set.py b/tests/integration/transactions/test_signer_list_set.py index d4d308abd..d882fd7c2 100644 --- a/tests/integration/transactions/test_signer_list_set.py +++ b/tests/integration/transactions/test_signer_list_set.py @@ -22,5 +22,6 @@ async def test_add_signer(self, client): ], ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_ticket_create.py b/tests/integration/transactions/test_ticket_create.py index ceb17e2ef..42b05ce64 100644 --- a/tests/integration/transactions/test_ticket_create.py +++ b/tests/integration/transactions/test_ticket_create.py @@ -13,5 +13,6 @@ async def test_basic_functionality(self, client): ticket_count=2, ), WALLET, + client, ) self.assertTrue(response.is_successful()) diff --git a/tests/integration/transactions/test_trust_set.py b/tests/integration/transactions/test_trust_set.py index 1e6e5d9b1..f196e19cf 100644 --- a/tests/integration/transactions/test_trust_set.py +++ b/tests/integration/transactions/test_trust_set.py @@ -21,5 +21,6 @@ async def test_basic_functionality(self, client): ), ), WALLET, + client, ) self.assertTrue(response.is_successful()) From f9c8718f98baecb1c6936ac894feb7a8681fb6c8 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:09:00 -0400 Subject: [PATCH 05/14] add TODO --- tests/integration/it_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 0c23dbe7a..37deb564d 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -122,7 +122,7 @@ async def fund_wallet( def submit_transaction( transaction: Transaction, wallet: Wallet, - client: SyncClient = JSON_RPC_CLIENT, + client: SyncClient, check_fee: bool = True, ) -> Response: """Signs and submits a transaction to the XRPL.""" @@ -136,7 +136,7 @@ def submit_transaction( async def submit_transaction_async( transaction: Transaction, wallet: Wallet, - client: Client, + client: AsyncClient, check_fee: bool = True, ) -> Response: response = await sign_and_submit_async( @@ -146,6 +146,8 @@ async def submit_transaction_async( return response +# TODO: figure out why there are different functions for `submit_transaction` and +# `sign_and_reliable_submission` - they feel like they should be the same def sign_and_reliable_submission( transaction: Transaction, wallet: Wallet, use_json_client: bool = True ) -> Response: From ff47fe7b1bd91b5255b0580d96effdf16ef55c2e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:12:53 -0400 Subject: [PATCH 06/14] fix bugs --- tests/integration/sugar/test_transaction.py | 1 + tests/integration/transactions/test_account_delete.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/sugar/test_transaction.py b/tests/integration/sugar/test_transaction.py index bb92a8eb2..4cc2b2381 100644 --- a/tests/integration/sugar/test_transaction.py +++ b/tests/integration/sugar/test_transaction.py @@ -121,6 +121,7 @@ async def test_payment_high_fee_authorized(self, client): destination=DESTINATION, ), WALLET, + client, # WITHOUT checking the fee value check_fee=False, ) diff --git a/tests/integration/transactions/test_account_delete.py b/tests/integration/transactions/test_account_delete.py index a56cbf928..c6e01438d 100644 --- a/tests/integration/transactions/test_account_delete.py +++ b/tests/integration/transactions/test_account_delete.py @@ -25,7 +25,7 @@ async def test_all_fields(self, client): destination_tag=DESTINATION_TAG, ) response = await submit_transaction_async( - account_delete, WALLET, check_fee=False + account_delete, WALLET, client, check_fee=False ) self.assertEqual(response.status, ResponseStatus.SUCCESS) From 47a7b6cdfb7d1d0e721b61d3e1c133f0e7c5489c Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:17:16 -0400 Subject: [PATCH 07/14] fix type --- xrpl/core/keypairs/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/core/keypairs/main.py b/xrpl/core/keypairs/main.py index 804087336..e213dd8d3 100644 --- a/xrpl/core/keypairs/main.py +++ b/xrpl/core/keypairs/main.py @@ -1,6 +1,6 @@ """Interface for cryptographic key pairs for use with the XRP Ledger.""" from secrets import token_bytes -from typing import Dict, Optional, Tuple, Type +from typing import Dict, Optional, Tuple, Type, Union from typing_extensions import Final @@ -94,7 +94,7 @@ def derive_classic_address(public_key: str) -> str: return addresscodec.encode_classic_address(account_id) -def sign(message: str | bytes, private_key: str) -> str: +def sign(message: Union[str, bytes], private_key: str) -> str: """ Sign a message using a given private key. From 653ebb56da49d6af62237abda01205c33c2a9dc2 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:48:54 -0400 Subject: [PATCH 08/14] remove ledger_accept --- tests/integration/it_utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 37deb564d..794326f79 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -129,7 +129,6 @@ def submit_transaction( response = safe_sign_and_submit_transaction( transaction, wallet, client, check_fee=check_fee ) - client.request(LEDGER_ACCEPT_REQUEST) return response @@ -142,7 +141,6 @@ async def submit_transaction_async( response = await sign_and_submit_async( transaction, wallet, client, check_fee=check_fee ) - await client.request(LEDGER_ACCEPT_REQUEST) return response From 2fb18ab1f65e3fd242088a7f5936a4c073d5fb24 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:55:31 -0400 Subject: [PATCH 09/14] refactor sign_and_reliable_submission --- tests/integration/it_utils.py | 20 ++++++++++---------- tests/integration/reqs/test_subscribe.py | 8 ++++++-- tests/integration/sugar/test_account.py | 2 +- tests/integration/sugar/test_transaction.py | 4 +++- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 794326f79..a3d91cab7 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -126,10 +126,9 @@ def submit_transaction( check_fee: bool = True, ) -> Response: """Signs and submits a transaction to the XRPL.""" - response = safe_sign_and_submit_transaction( + return safe_sign_and_submit_transaction( transaction, wallet, client, check_fee=check_fee ) - return response async def submit_transaction_async( @@ -138,27 +137,28 @@ async def submit_transaction_async( client: AsyncClient, check_fee: bool = True, ) -> Response: - response = await sign_and_submit_async( - transaction, wallet, client, check_fee=check_fee - ) - return response + return await sign_and_submit_async(transaction, wallet, client, check_fee=check_fee) # TODO: figure out why there are different functions for `submit_transaction` and # `sign_and_reliable_submission` - they feel like they should be the same def sign_and_reliable_submission( - transaction: Transaction, wallet: Wallet, use_json_client: bool = True + transaction: Transaction, + wallet: Wallet, + client: SyncClient = JSON_RPC_CLIENT, + check_fee: bool = True, ) -> Response: - client = _choose_client(use_json_client) response = submit_transaction(transaction, wallet, client) client.request(LEDGER_ACCEPT_REQUEST) return response async def sign_and_reliable_submission_async( - transaction: Transaction, wallet: Wallet, use_json_client: bool = True + transaction: Transaction, + wallet: Wallet, + client: AsyncClient = ASYNC_JSON_RPC_CLIENT, + check_fee: bool = True, ) -> Response: - client = _choose_client_async(use_json_client) response = await submit_transaction_async(transaction, wallet, client) await client.request(LEDGER_ACCEPT_REQUEST) return response diff --git a/tests/integration/reqs/test_subscribe.py b/tests/integration/reqs/test_subscribe.py index a50fc9bc2..b998c59c9 100644 --- a/tests/integration/reqs/test_subscribe.py +++ b/tests/integration/reqs/test_subscribe.py @@ -83,7 +83,9 @@ async def test_transactions_subscription(self, client): count = 0 async for message in client: - await sign_and_reliable_submission_async(payment_transaction, WALLET) + await sign_and_reliable_submission_async( + payment_transaction, WALLET, client + ) if count != 0: self.assertEqual(message["type"], "transaction") if count == _MESSAGE_LIMIT: @@ -108,7 +110,9 @@ async def test_transactions_proposed_subscription(self, client): count = 0 async for message in client: - await sign_and_reliable_submission_async(payment_transaction, WALLET) + await sign_and_reliable_submission_async( + payment_transaction, WALLET, client + ) if count != 0: self.assertEqual(message["type"], "transaction") if count == _MESSAGE_LIMIT: diff --git a/tests/integration/sugar/test_account.py b/tests/integration/sugar/test_account.py index d7b9a1357..bed129100 100644 --- a/tests/integration/sugar/test_account.py +++ b/tests/integration/sugar/test_account.py @@ -47,7 +47,7 @@ async def test_get_latest_transaction(self, client): destination=DESTINATION.classic_address, amount=amount, ) - await sign_and_reliable_submission_async(payment, WALLET) + await sign_and_reliable_submission_async(payment, WALLET, client) response = await get_latest_transaction(WALLET.classic_address, client) self.assertEqual(len(response.result["transactions"]), 1) diff --git a/tests/integration/sugar/test_transaction.py b/tests/integration/sugar/test_transaction.py index 4cc2b2381..eea5c596b 100644 --- a/tests/integration/sugar/test_transaction.py +++ b/tests/integration/sugar/test_transaction.py @@ -58,7 +58,9 @@ async def test_none_as_destination_tag(self, client): ) # WHEN we sign locally, autofill, and submit the transaction - response = await sign_and_reliable_submission_async(payment_transaction, WALLET) + response = await sign_and_reliable_submission_async( + payment_transaction, WALLET, client + ) payment_hash = response.result["tx_json"]["hash"] payment_ledger_index = response.result["validated_ledger_index"] From 77ea3d1a5d13cf42bf8ef42877a38d96aff545d1 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 16:46:21 -0400 Subject: [PATCH 10/14] close ledgers after each transaction --- tests/integration/it_utils.py | 6 ++++-- tests/integration/reqs/test_subscribe.py | 8 ++++++-- tests/integration/sugar/test_transaction.py | 7 +++---- tests/integration/sugar/test_wallet.py | 1 + .../integration/transactions/test_account_delete.py | 7 +++++-- tests/integration/transactions/test_account_set.py | 9 ++++++--- tests/integration/transactions/test_check_cancel.py | 9 +++++++-- tests/integration/transactions/test_check_cash.py | 9 ++++++--- tests/integration/transactions/test_check_create.py | 9 +++++++-- .../transactions/test_deposit_preauth.py | 13 ++++++++++--- .../integration/transactions/test_escrow_cancel.py | 9 +++++++-- .../integration/transactions/test_escrow_create.py | 9 +++++++-- .../integration/transactions/test_escrow_finish.py | 9 +++++++-- tests/integration/transactions/test_offer_cancel.py | 7 +++++-- tests/integration/transactions/test_offer_create.py | 7 +++++-- tests/integration/transactions/test_payment.py | 7 +++++-- .../transactions/test_payment_channel_claim.py | 7 +++++-- .../transactions/test_payment_channel_create.py | 7 +++++-- .../transactions/test_payment_channel_fund.py | 7 +++++-- .../transactions/test_set_regular_key.py | 7 +++++-- .../transactions/test_signer_list_set.py | 7 +++++-- .../integration/transactions/test_ticket_create.py | 7 +++++-- tests/integration/transactions/test_trust_set.py | 7 +++++-- 23 files changed, 126 insertions(+), 49 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index a3d91cab7..385227c99 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -148,7 +148,7 @@ def sign_and_reliable_submission( client: SyncClient = JSON_RPC_CLIENT, check_fee: bool = True, ) -> Response: - response = submit_transaction(transaction, wallet, client) + response = submit_transaction(transaction, wallet, client, check_fee=check_fee) client.request(LEDGER_ACCEPT_REQUEST) return response @@ -159,7 +159,9 @@ async def sign_and_reliable_submission_async( client: AsyncClient = ASYNC_JSON_RPC_CLIENT, check_fee: bool = True, ) -> Response: - response = await submit_transaction_async(transaction, wallet, client) + response = await submit_transaction_async( + transaction, wallet, client, check_fee=check_fee + ) await client.request(LEDGER_ACCEPT_REQUEST) return response diff --git a/tests/integration/reqs/test_subscribe.py b/tests/integration/reqs/test_subscribe.py index b998c59c9..a52d3948b 100644 --- a/tests/integration/reqs/test_subscribe.py +++ b/tests/integration/reqs/test_subscribe.py @@ -83,8 +83,10 @@ async def test_transactions_subscription(self, client): count = 0 async for message in client: + # TODO: refactor so this can use the same client await sign_and_reliable_submission_async( - payment_transaction, WALLET, client + payment_transaction, + WALLET, ) if count != 0: self.assertEqual(message["type"], "transaction") @@ -110,8 +112,10 @@ async def test_transactions_proposed_subscription(self, client): count = 0 async for message in client: + # TODO: refactor so this can use the same client await sign_and_reliable_submission_async( - payment_transaction, WALLET, client + payment_transaction, + WALLET, ) if count != 0: self.assertEqual(message["type"], "transaction") diff --git a/tests/integration/sugar/test_transaction.py b/tests/integration/sugar/test_transaction.py index eea5c596b..d8d3259de 100644 --- a/tests/integration/sugar/test_transaction.py +++ b/tests/integration/sugar/test_transaction.py @@ -2,7 +2,6 @@ from tests.integration.it_utils import ( accept_ledger_async, sign_and_reliable_submission_async, - submit_transaction_async, test_async_and_sync, ) from tests.integration.reusable_values import DESTINATION as DESTINATION_WALLET @@ -91,7 +90,7 @@ async def test_high_fee_account_delete_unauthorized(self, client): ) # We expect an XRPLException to be raised with self.assertRaises(XRPLException): - await submit_transaction_async(account_delete, WALLET, client) + await sign_and_reliable_submission_async(account_delete, WALLET, client) @test_async_and_sync(globals()) async def test_high_fee_account_set_unauthorized(self, client): @@ -109,12 +108,12 @@ async def test_high_fee_account_set_unauthorized(self, client): ) # We expect an XRPLException to be raised with self.assertRaises(XRPLException): - await submit_transaction_async(account_set, WALLET, client) + await sign_and_reliable_submission_async(account_set, WALLET, client) @test_async_and_sync(globals()) async def test_payment_high_fee_authorized(self, client): # GIVEN a new Payment transaction - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( Payment( account=WALLET.classic_address, amount="1", diff --git a/tests/integration/sugar/test_wallet.py b/tests/integration/sugar/test_wallet.py index b2db86b48..062e79e6c 100644 --- a/tests/integration/sugar/test_wallet.py +++ b/tests/integration/sugar/test_wallet.py @@ -65,6 +65,7 @@ class TestWallet(IntegrationTestCase): async def test_generate_faucet_wallet_rel_sub(self, client): destination = await generate_faucet_wallet(client) wallet = await generate_faucet_wallet(client) + # TODO: refactor so this actually waits for validation response = await submit_transaction_async( Payment( account=wallet.classic_address, diff --git a/tests/integration/transactions/test_account_delete.py b/tests/integration/transactions/test_account_delete.py index c6e01438d..86488ab75 100644 --- a/tests/integration/transactions/test_account_delete.py +++ b/tests/integration/transactions/test_account_delete.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import DESTINATION, WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import AccountDelete @@ -24,7 +27,7 @@ async def test_all_fields(self, client): destination=DESTINATION.classic_address, destination_tag=DESTINATION_TAG, ) - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( account_delete, WALLET, client, check_fee=False ) self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_account_set.py b/tests/integration/transactions/test_account_set.py index 1f8f00b29..f77006b27 100644 --- a/tests/integration/transactions/test_account_set.py +++ b/tests/integration/transactions/test_account_set.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import AccountSet @@ -22,7 +25,7 @@ async def test_required_fields_and_set_flag(self, client): account=ACCOUNT, set_flag=SET_FLAG, ) - response = await submit_transaction_async(account_set, WALLET, client) + response = await sign_and_reliable_submission_async(account_set, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") @@ -37,6 +40,6 @@ async def test_all_fields_minus_set_flag(self, client): transfer_rate=TRANSFER_RATE, tick_size=TICK_SIZE, ) - response = await submit_transaction_async(account_set, WALLET, client) + response = await sign_and_reliable_submission_async(account_set, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") diff --git a/tests/integration/transactions/test_check_cancel.py b/tests/integration/transactions/test_check_cancel.py index 37f6d5a1f..879549cc3 100644 --- a/tests/integration/transactions/test_check_cancel.py +++ b/tests/integration/transactions/test_check_cancel.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import CheckCancel @@ -16,7 +19,9 @@ async def test_all_fields(self, client): account=ACCOUNT, check_id=CHECK_ID, ) - response = await submit_transaction_async(check_cancel, WALLET, client) + response = await sign_and_reliable_submission_async( + check_cancel, WALLET, client + ) self.assertEqual(response.status, ResponseStatus.SUCCESS) # This transaction shouldn't actually succeed, because this isn't a real check: # Docs for tecNO_ENTRY read: diff --git a/tests/integration/transactions/test_check_cash.py b/tests/integration/transactions/test_check_cash.py index 19895b52c..bd6b9c1ed 100644 --- a/tests/integration/transactions/test_check_cash.py +++ b/tests/integration/transactions/test_check_cash.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import CheckCash @@ -18,7 +21,7 @@ async def test_required_fields_with_amount(self, client): check_id=CHECK_ID, amount=AMOUNT, ) - response = await submit_transaction_async(check_cash, WALLET, client) + response = await sign_and_reliable_submission_async(check_cash, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) # Getting `tecNO_ENTRY` codes because using a non-existent check ID self.assertEqual(response.result["engine_result"], "tecNO_ENTRY") @@ -30,6 +33,6 @@ async def test_required_fields_with_deliver_min(self, client): check_id=CHECK_ID, deliver_min=DELIVER_MIN, ) - response = await submit_transaction_async(check_cash, WALLET, client) + response = await sign_and_reliable_submission_async(check_cash, WALLET, client) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tecNO_ENTRY") diff --git a/tests/integration/transactions/test_check_create.py b/tests/integration/transactions/test_check_create.py index 5af636121..83485bcc1 100644 --- a/tests/integration/transactions/test_check_create.py +++ b/tests/integration/transactions/test_check_create.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import DESTINATION, WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import CheckCreate @@ -22,6 +25,8 @@ async def test_all_fields(self, client): expiration=EXPIRATION, invoice_id=INVOICE_ID, ) - response = await submit_transaction_async(check_create, WALLET, client) + response = await sign_and_reliable_submission_async( + check_create, WALLET, client + ) self.assertEqual(response.status, ResponseStatus.SUCCESS) self.assertEqual(response.result["engine_result"], "tesSUCCESS") diff --git a/tests/integration/transactions/test_deposit_preauth.py b/tests/integration/transactions/test_deposit_preauth.py index e75fa0b36..83fbb1025 100644 --- a/tests/integration/transactions/test_deposit_preauth.py +++ b/tests/integration/transactions/test_deposit_preauth.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import DepositPreauth @@ -15,7 +18,9 @@ async def test_authorize(self, client): account=ACCOUNT, authorize=ADDRESS, ) - response = await submit_transaction_async(deposit_preauth, WALLET, client) + response = await sign_and_reliable_submission_async( + deposit_preauth, WALLET, client + ) self.assertEqual(response.status, ResponseStatus.SUCCESS) @test_async_and_sync(globals()) @@ -24,5 +29,7 @@ async def test_unauthorize(self, client): account=ACCOUNT, unauthorize=ADDRESS, ) - response = await submit_transaction_async(deposit_preauth, WALLET, client) + response = await sign_and_reliable_submission_async( + deposit_preauth, WALLET, client + ) self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_cancel.py b/tests/integration/transactions/test_escrow_cancel.py index 636003e66..e37ae0f7f 100644 --- a/tests/integration/transactions/test_escrow_cancel.py +++ b/tests/integration/transactions/test_escrow_cancel.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import EscrowCancel @@ -17,6 +20,8 @@ async def test_all_fields(self, client): owner=OWNER, offer_sequence=OFFER_SEQUENCE, ) - response = await submit_transaction_async(escrow_cancel, WALLET, client) + response = await sign_and_reliable_submission_async( + escrow_cancel, WALLET, client + ) # Actual engine_result is `tecNO_TARGET since OWNER account doesn't exist self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_create.py b/tests/integration/transactions/test_escrow_create.py index e0128bcfd..8dbe1e2f2 100644 --- a/tests/integration/transactions/test_escrow_create.py +++ b/tests/integration/transactions/test_escrow_create.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import EscrowCreate @@ -29,7 +32,9 @@ async def test_all_fields(self, client): finish_after=FINISH_AFTER, source_tag=SOURCE_TAG, ) - response = await submit_transaction_async(escrow_create, WALLET, client) + response = await sign_and_reliable_submission_async( + escrow_create, WALLET, client + ) # Actual engine_result will be `tecNO_PERMISSION`... # maybe due to CONDITION or something self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_escrow_finish.py b/tests/integration/transactions/test_escrow_finish.py index 7d9ea85e6..cb6f5ffeb 100644 --- a/tests/integration/transactions/test_escrow_finish.py +++ b/tests/integration/transactions/test_escrow_finish.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.response import ResponseStatus from xrpl.models.transactions import EscrowFinish @@ -27,7 +30,9 @@ async def test_all_fields(self, client): condition=CONDITION, fulfillment=FULFILLMENT, ) - response = await submit_transaction_async(escrow_finish, WALLET, client) + response = await sign_and_reliable_submission_async( + escrow_finish, WALLET, client + ) # Actual engine_result will be 'tecNO_TARGET' since using non-extant # account for OWNER self.assertEqual(response.status, ResponseStatus.SUCCESS) diff --git a/tests/integration/transactions/test_offer_cancel.py b/tests/integration/transactions/test_offer_cancel.py index d7f409795..e1ac21cfa 100644 --- a/tests/integration/transactions/test_offer_cancel.py +++ b/tests/integration/transactions/test_offer_cancel.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import OFFER, WALLET from xrpl.models.transactions import OfferCancel @@ -7,7 +10,7 @@ class TestOfferCancel(IntegrationTestCase): @test_async_and_sync(globals()) async def test_all_fields(self, client): - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( OfferCancel( account=WALLET.classic_address, offer_sequence=OFFER.result["tx_json"]["Sequence"], diff --git a/tests/integration/transactions/test_offer_create.py b/tests/integration/transactions/test_offer_create.py index 48309e7f7..55fc798fd 100644 --- a/tests/integration/transactions/test_offer_create.py +++ b/tests/integration/transactions/test_offer_create.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.amounts import IssuedCurrencyAmount from xrpl.models.transactions import OfferCreate @@ -8,7 +11,7 @@ class TestOfferCreate(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): - offer = await submit_transaction_async( + offer = await sign_and_reliable_submission_async( OfferCreate( account=WALLET.classic_address, taker_gets="13100000", diff --git a/tests/integration/transactions/test_payment.py b/tests/integration/transactions/test_payment.py index f3a446f02..a74f70e5a 100644 --- a/tests/integration/transactions/test_payment.py +++ b/tests/integration/transactions/test_payment.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import DESTINATION, WALLET from xrpl.models.transactions import Payment @@ -7,7 +10,7 @@ class TestPayment(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( Payment( account=WALLET.classic_address, amount="1", diff --git a/tests/integration/transactions/test_payment_channel_claim.py b/tests/integration/transactions/test_payment_channel_claim.py index 89b4eb681..87efc6a18 100644 --- a/tests/integration/transactions/test_payment_channel_claim.py +++ b/tests/integration/transactions/test_payment_channel_claim.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import PAYMENT_CHANNEL, WALLET from xrpl.models.transactions import PaymentChannelClaim @@ -7,7 +10,7 @@ class TestPaymentChannelClaim(IntegrationTestCase): @test_async_and_sync(globals()) async def test_receiver_claim(self, client): - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( PaymentChannelClaim( account=WALLET.classic_address, channel=PAYMENT_CHANNEL.result["tx_json"]["hash"], diff --git a/tests/integration/transactions/test_payment_channel_create.py b/tests/integration/transactions/test_payment_channel_create.py index e803b031d..68a757833 100644 --- a/tests/integration/transactions/test_payment_channel_create.py +++ b/tests/integration/transactions/test_payment_channel_create.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import DESTINATION, WALLET from xrpl.models.transactions import PaymentChannelCreate @@ -7,7 +10,7 @@ class TestPaymentChannelCreate(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): - payment_channel = await submit_transaction_async( + payment_channel = await sign_and_reliable_submission_async( PaymentChannelCreate( account=WALLET.classic_address, amount="1", diff --git a/tests/integration/transactions/test_payment_channel_fund.py b/tests/integration/transactions/test_payment_channel_fund.py index 8370b8fe2..e22cd366b 100644 --- a/tests/integration/transactions/test_payment_channel_fund.py +++ b/tests/integration/transactions/test_payment_channel_fund.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import PAYMENT_CHANNEL, WALLET from xrpl.models.transactions import PaymentChannelFund @@ -7,7 +10,7 @@ class TestPaymentChannelFund(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( PaymentChannelFund( account=WALLET.classic_address, channel=PAYMENT_CHANNEL.result["tx_json"]["hash"], diff --git a/tests/integration/transactions/test_set_regular_key.py b/tests/integration/transactions/test_set_regular_key.py index d030fb3ed..beb212609 100644 --- a/tests/integration/transactions/test_set_regular_key.py +++ b/tests/integration/transactions/test_set_regular_key.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.transactions import SetRegularKey from xrpl.wallet import Wallet @@ -9,7 +12,7 @@ class TestSetRegularKey(IntegrationTestCase): @test_async_and_sync(globals()) async def test_all_fields(self, client): regular_key = Wallet.create().classic_address - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( SetRegularKey( account=WALLET.classic_address, regular_key=regular_key, diff --git a/tests/integration/transactions/test_signer_list_set.py b/tests/integration/transactions/test_signer_list_set.py index d882fd7c2..4a226484e 100644 --- a/tests/integration/transactions/test_signer_list_set.py +++ b/tests/integration/transactions/test_signer_list_set.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.transactions import SignerEntry, SignerListSet from xrpl.wallet import Wallet @@ -10,7 +13,7 @@ class TestSignerListSet(IntegrationTestCase): async def test_add_signer(self, client): # sets up another signer for this account other_signer = Wallet.create() - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( SignerListSet( account=WALLET.classic_address, signer_quorum=1, diff --git a/tests/integration/transactions/test_ticket_create.py b/tests/integration/transactions/test_ticket_create.py index 42b05ce64..2855d6365 100644 --- a/tests/integration/transactions/test_ticket_create.py +++ b/tests/integration/transactions/test_ticket_create.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.transactions import TicketCreate @@ -7,7 +10,7 @@ class TestTicketCreate(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( TicketCreate( account=WALLET.classic_address, ticket_count=2, diff --git a/tests/integration/transactions/test_trust_set.py b/tests/integration/transactions/test_trust_set.py index f196e19cf..d30dd7496 100644 --- a/tests/integration/transactions/test_trust_set.py +++ b/tests/integration/transactions/test_trust_set.py @@ -1,5 +1,8 @@ from tests.integration.integration_test_case import IntegrationTestCase -from tests.integration.it_utils import submit_transaction_async, test_async_and_sync +from tests.integration.it_utils import ( + sign_and_reliable_submission_async, + test_async_and_sync, +) from tests.integration.reusable_values import WALLET from xrpl.models.amounts import IssuedCurrencyAmount from xrpl.models.transactions import TrustSet, TrustSetFlag @@ -10,7 +13,7 @@ class TestTrustSet(IntegrationTestCase): @test_async_and_sync(globals()) async def test_basic_functionality(self, client): issuer_wallet = Wallet.create() - response = await submit_transaction_async( + response = await sign_and_reliable_submission_async( TrustSet( account=WALLET.classic_address, flags=TrustSetFlag.TF_SET_NO_RIPPLE, From 3a40491d03bea65854481d6ade3eeafe735b1bf7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 16:53:13 -0400 Subject: [PATCH 11/14] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58a20437f..ebcfdc34a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [[Unreleased]] + +### Changed: +- Allowed keypairs.sign to take a hex string in addition to bytes + ### Fixed: - Refactored `does_account_exist` and `get_balance` to avoid deprecated methods and use `ledger_index` parameter +- Fixed crashes in the SignerListSet validation ### Removed: - RPCs and utils related to the old sidechain design From 53451e3ac5694b1b14b08e2898b15d655de48ed4 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 5 May 2023 17:26:19 -0400 Subject: [PATCH 12/14] clean up todo --- tests/integration/it_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/integration/it_utils.py b/tests/integration/it_utils.py index 385227c99..138aa95b4 100644 --- a/tests/integration/it_utils.py +++ b/tests/integration/it_utils.py @@ -119,6 +119,7 @@ async def fund_wallet( await client.request(LEDGER_ACCEPT_REQUEST) +# just submits a transaction to the ledger, synchronously def submit_transaction( transaction: Transaction, wallet: Wallet, @@ -131,6 +132,7 @@ def submit_transaction( ) +# just submits a transaction to the ledger, asynchronously async def submit_transaction_async( transaction: Transaction, wallet: Wallet, @@ -140,8 +142,7 @@ async def submit_transaction_async( return await sign_and_submit_async(transaction, wallet, client, check_fee=check_fee) -# TODO: figure out why there are different functions for `submit_transaction` and -# `sign_and_reliable_submission` - they feel like they should be the same +# submits a transaction to the ledger and closes a ledger, synchronously def sign_and_reliable_submission( transaction: Transaction, wallet: Wallet, @@ -153,6 +154,7 @@ def sign_and_reliable_submission( return response +# submits a transaction to the ledger and closes a ledger, asynchronously async def sign_and_reliable_submission_async( transaction: Transaction, wallet: Wallet, From dfb382b2f50c51756fcc1d901fad8fc90a06d1a3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 16 May 2023 11:54:08 -0400 Subject: [PATCH 13/14] fix string --- xrpl/models/transactions/signer_list_set.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl/models/transactions/signer_list_set.py b/xrpl/models/transactions/signer_list_set.py index b3695242e..cda233e71 100644 --- a/xrpl/models/transactions/signer_list_set.py +++ b/xrpl/models/transactions/signer_list_set.py @@ -115,9 +115,9 @@ def _get_errors(self: SignerListSet) -> Dict[str, str]: or len(self.signer_entries) > MAX_SIGNER_ENTRIES ): errors["signer_entries"] = ( - "`signer_entries` must have at least 1 member and no more than {} " - "members. If this transaction is deleting the SignerList, then " - "this parameter must be omitted.".format(MAX_SIGNER_ENTRIES) + "`signer_entries` must have at least 1 member and no more than " + f"{MAX_SIGNER_ENTRIES} members. If this transaction is deleting the " + "SignerList, then this parameter must be omitted." ) return errors From e3b0f0eb9f262ed3ae3cdcbc5f6c59fc47432f3c Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 16 May 2023 12:54:30 -0400 Subject: [PATCH 14/14] fix error message --- xrpl/models/transactions/signer_list_set.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xrpl/models/transactions/signer_list_set.py b/xrpl/models/transactions/signer_list_set.py index cda233e71..de1da7021 100644 --- a/xrpl/models/transactions/signer_list_set.py +++ b/xrpl/models/transactions/signer_list_set.py @@ -100,9 +100,10 @@ def _get_errors(self: SignerListSet) -> Dict[str, str]: if self.signer_quorum == REQUIRED: errors["signer_quorum"] = "`signer_quorum` is not set." elif self.signer_quorum <= 0: - errors[ - "signer_quorum" - ] = "`signer_quorum` must be greater than or equal to 0." + errors["signer_quorum"] = ( + "`signer_quorum` must be greater than or equal to 0 when not deleting " + "signer_list." + ) if not isinstance(self.signer_entries, list): errors[