Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XLS-80d Permissioned Domains #773

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
c7e1a15
Update definitions.json -- generated from the tip of rippled codebase…
ckeshava Oct 15, 2024
9d549c1
Specify the CredentialCreate transaction
ckeshava Oct 16, 2024
8375c42
Files relevant to the CredentialAccept transaction
ckeshava Oct 17, 2024
8d810fc
Files pertaining to the CredentialDelete transaction
ckeshava Oct 17, 2024
0a33121
Files pertaining to DepositPreauth transaction are included in this c…
ckeshava Oct 18, 2024
fd8157d
FIX: Update deposit_preauth integration tests to validate the transac…
ckeshava Oct 18, 2024
1d85bbb
Include account_objects RPC call to verify that cred ledger-object is…
ckeshava Oct 21, 2024
8ea12c4
Updates to DepositAuthorized RPC
ckeshava Oct 21, 2024
e4293be
address PR comments
ckeshava Oct 21, 2024
60b7663
FIX: Use sum() method for error validation in DepositPreauth transact…
ckeshava Oct 22, 2024
509ecd1
Update the definitions.json file without changing the format of the d…
ckeshava Oct 22, 2024
c0151c2
Update base_model.py -- Use mypy with Python 3.8 suggestions
ckeshava Oct 22, 2024
48b8abc
include fixAMM1_1 in the rippled.cfg file
ckeshava Oct 24, 2024
f476a51
rearrange the LedgerEntryTypes in definitions.json
ckeshava Oct 24, 2024
8b82c3d
include amendments which are not in majority consensus yet
ckeshava Oct 25, 2024
a24ca5b
Update tests/unit/models/transactions/test_account_delete.py
ckeshava Oct 30, 2024
4402f6d
Update tests/unit/models/transactions/test_credential_accept.py
ckeshava Oct 30, 2024
22de7a3
refactor DepositPreauth transaction validity checks
ckeshava Oct 30, 2024
f848bbd
refactor suggestions from code-rabbit
ckeshava Oct 30, 2024
cb63c6d
Merge branch 'main' into cred
ckeshava Oct 30, 2024
ffcf1bd
Update xrpl/models/transactions/deposit_preauth.py
ckeshava Oct 31, 2024
e498721
Update xrpl/models/transactions/payment_channel_claim.py
ckeshava Oct 31, 2024
e5a0779
Update xrpl/models/transactions/payment_channel_claim.py
ckeshava Oct 31, 2024
ad4331a
remove unnecessary comments
ckeshava Oct 31, 2024
1a974fb
update error msg in CredentialDelete txn
ckeshava Oct 31, 2024
880a670
Update xrpl/models/transactions/credential_accept.py
ckeshava Oct 31, 2024
af67d78
Update xrpl/models/transactions/credential_accept.py
ckeshava Oct 31, 2024
c50d611
Update xrpl/models/transactions/credential_accept.py
ckeshava Oct 31, 2024
2c887aa
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
8468fcd
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
bba054d
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
6c0b958
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
7f68440
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
1485ae9
Update xrpl/models/transactions/credential_create.py
ckeshava Oct 31, 2024
27f8719
Update xrpl/models/transactions/credential_accept.py
ckeshava Oct 31, 2024
485d392
modified the structure of error collection
ckeshava Oct 31, 2024
562aa49
modified error msg in DepositPreauth txn
ckeshava Oct 31, 2024
d83f0d7
use _MAX_URI_LENGTH variable
ckeshava Oct 31, 2024
a188c1a
Update all the unit tests as per the changes in model files
ckeshava Oct 31, 2024
b97d6f3
Use List instead of Set to store sequence of credentials
ckeshava Oct 31, 2024
379620a
simplify DepositPreauth unit tests
ckeshava Oct 31, 2024
e63b49d
unify the regex used in DIDSet and Credentials
ckeshava Oct 31, 2024
5425b37
remove the use of lambda in collecting errors
ckeshava Oct 31, 2024
3e8b825
Update xrpl/models/transactions/account_delete.py
ckeshava Nov 1, 2024
4106236
Use variables instead of magic numbers, credential length checks
ckeshava Nov 1, 2024
6e42798
remove magic number in credential_delete txn model
ckeshava Nov 1, 2024
0719107
use filter construct for deposit_preauth validity check
ckeshava Nov 1, 2024
f1d2b4e
remove doc-strings alluding to de-duplication
ckeshava Nov 1, 2024
bf5114a
refactor credential_ids check into utils file
ckeshava Nov 1, 2024
6d8f1be
Update xrpl/models/transactions/escrow_finish.py
ckeshava Nov 4, 2024
8e496e1
address PR comments from Mayukha
ckeshava Nov 4, 2024
5656080
Update tests/integration/transactions/test_credential.py
ckeshava Nov 4, 2024
b43aa12
Update xrpl/models/utils.py
ckeshava Nov 4, 2024
6392351
Update xrpl/models/transactions/credential_create.py
ckeshava Nov 4, 2024
4ad028b
Update xrpl/models/transactions/credential_delete.py
ckeshava Nov 4, 2024
1f25b01
Update xrpl/models/transactions/deposit_preauth.py
ckeshava Nov 4, 2024
a870f2d
Merge branch 'main' into cred
ckeshava Nov 4, 2024
a6ac0f4
address PR comments; check for duplicates in the credential list
ckeshava Nov 7, 2024
111e12a
Update xrpl/models/transactions/credential_create.py
ckeshava Nov 7, 2024
8593111
Update xrpl/models/transactions/credential_delete.py
ckeshava Nov 7, 2024
7fa47e1
Update xrpl/models/transactions/credential_create.py
ckeshava Nov 7, 2024
3d66a36
address PR comments
ckeshava Nov 7, 2024
2d86ea2
address PR comments
ckeshava Nov 8, 2024
f58dc2c
update definitions.json to match rippled develop branch
ckeshava Nov 9, 2024
0f7f745
use short-circuit in an if-condition
ckeshava Nov 9, 2024
b02f902
[WIP] Fix CICD integration tests
ckeshava Nov 12, 2024
b70ac84
Merge branch 'main' into cred
ckeshava Nov 12, 2024
7f79596
CI/CD Fix: Update docker-stop command
ckeshava Nov 12, 2024
3814a94
LedgerEntry RPC: Introduce Credential functionality
ckeshava Nov 12, 2024
c721a87
Update Contributing guidelines
ckeshava Nov 12, 2024
c76b755
fix black linter errors
ckeshava Nov 12, 2024
9b7d17c
fix mypy errors
ckeshava Nov 12, 2024
5068266
re-introduce docker health checks with server_info RPC
ckeshava Nov 12, 2024
8abf7b7
Models for PD transactions
ckeshava Nov 14, 2024
26ea9b6
Update CL
ckeshava Nov 15, 2024
e5ad6c1
Update CHANGELOG.md
ckeshava Nov 18, 2024
b7cd2b0
fix: Update the ledger_entry RPC model
ckeshava Nov 20, 2024
7549e48
refactor: Use LedgerEntryType instead of AccountObjectsType; Rectify …
ckeshava Nov 20, 2024
5bdbf55
fix: Update ledger_entry unit test
ckeshava Nov 20, 2024
12d7075
update CL
ckeshava Nov 20, 2024
fb98fd5
deprecate AccountObjectType enum
ckeshava Jan 8, 2025
f65ba6b
Merge branch 'main' into xls_80d
ckeshava Jan 13, 2025
e00d485
revert the updates to AccountObjects and ledger_entry RPC method; Upd…
ckeshava Jan 15, 2025
19c3caa
update the change-log
ckeshava Jan 15, 2025
d42ebb9
revert the github CI/CD instructions
ckeshava Jan 15, 2025
cb9ec77
revert integration test suite updates to AccountObjects RPC
ckeshava Jan 15, 2025
bc8954b
suggestions from the linter
ckeshava Jan 15, 2025
adf52d3
update the Github CI/CD to use develop branch of rippled
ckeshava Jan 15, 2025
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
12 changes: 12 additions & 0 deletions .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ PriceOracle
fixEmptyDID
fixXChainRewardRounding
fixPreviousTxnID
fixAMMv1_1
Credentials
NFTokenMintOffer
fixNFTokenPageLinks
fixInnerObjTemplate2
fixEnforceNFTokenTrustline
fixReducedOffersV2
InvariantsV1_1
MPTokensV1
AMMv1_2
AMMClawback
PermissionedDomains

# This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode
[voting]
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Integration test

env:
POETRY_VERSION: 1.8.3
RIPPLED_DOCKER_IMAGE: rippleci/rippled:2.2.0-b3
RIPPLED_DOCKER_IMAGE: rippleci/rippled:2.3.0-rc1

on:
push:
Expand Down Expand Up @@ -32,7 +32,8 @@ jobs:

- name: Run docker in background
run: |
docker run --detach --rm --name rippled-service -p 5005:5005 -p 6006:6006 --volume "${{ github.workspace }}/.ci-config/":"/opt/ripple/etc/" --health-cmd="wget localhost:6006 || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true ${{ env.RIPPLED_DOCKER_IMAGE }} /opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg
docker run -dit -p 5005:5005 -p 6006:6006 -v "${{ github.workspace }}/.ci-config/":/etc/opt/ripple/ --name rippled_standalone --health-cmd="rippled server_info || exit 1" --health-interval=5s --health-retries=10 --health-timeout=2s --env GITHUB_ACTIONS=true --env CI=true --entrypoint bash ${{ env.RIPPLED_DOCKER_IMAGE }}
docker exec -d rippled_standalone rippled -a

- name: Install poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -60,4 +61,4 @@ jobs:

- name: Stop docker container
if: always()
run: docker stop rippled-service
run: docker stop rippled_standalone
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Add `include_deleted` to ledger_entry request
- Add support for the `PermissionedDomains` feature

### BREAKING CHANGE:
- Remove Python 3.7 support to fix dependency installation and use 3.8 as new default.
- Remove the AccountObjectType enum. Instead, use the LedgerEntryType enum, this reduces redundancy in the codebase.
ckeshava marked this conversation as resolved.
Show resolved Hide resolved
ckeshava marked this conversation as resolved.
Show resolved Hide resolved

### Fixed
- Grab the FeeSettings values from the latest validated ledger. Remove hard-coded reference to 10 drops as the reference transaction cost.
Expand Down Expand Up @@ -91,7 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.0.0] - 2023-07-05
### BREAKING CHANGE
- The default signing algorithm in the `Wallet` was changed from secp256k1 to ed25519
-
-
### Added:
- Wallet support for regular key compatibility
- Added new ways of wallet generation: `from_seed`, `from_secret`, `from_entropy`, `from_secret_numbers`
Expand Down
11 changes: 7 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ To run integration tests, you'll need a standalone rippled node running with WS

```bash
docker run -p 5005:5005 -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/opt/ripple/etc/ --platform linux/amd64 rippleci/rippled:2.2.0-b3 /opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg

docker run -dit -p 5005:5005 -p 6006:6006 -v $PWD/.ci-config/:/etc/opt/ripple/ --name rippled_standalone --entrypoint bash rippleci/rippled:develop
docker exec -d rippled_standalone rippled -a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistencies in Docker setup instructions

The new Docker commands have several issues that need to be addressed:

  1. Using rippleci/rippled:develop instead of a specific version tag could lead to inconsistent behavior across different development environments.
  2. The mount paths differ between the old (/opt/ripple/etc/) and new (/etc/opt/ripple/) commands without explanation of the change.
  3. The commands are now split into two steps without explaining why this approach is preferred.

Consider this revised version:

-docker run -p 5005:5005 -p 6006:6006 --interactive -t --volume $PWD/.ci-config:/opt/ripple/etc/ --platform linux/amd64 rippleci/rippled:2.2.0-b3 /opt/ripple/bin/rippled -a --conf /opt/ripple/etc/rippled.cfg
-
-docker run -dit -p 5005:5005 -p 6006:6006 -v $PWD/.ci-config/:/etc/opt/ripple/ --name rippled_standalone --entrypoint bash rippleci/rippled:develop
-docker exec -d rippled_standalone rippled -a
+# Start the rippled container in detached mode
+docker run -d \
+    --name rippled_standalone \
+    -p 5005:5005 -p 6006:6006 \
+    -v $PWD/.ci-config/:/etc/opt/ripple/ \
+    rippleci/rippled:2.3.0-rc1 \
+    rippled -a
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker run -dit -p 5005:5005 -p 6006:6006 -v $PWD/.ci-config/:/etc/opt/ripple/ --name rippled_standalone --entrypoint bash rippleci/rippled:develop
docker exec -d rippled_standalone rippled -a
# Start the rippled container in detached mode
docker run -d \
--name rippled_standalone \
-p 5005:5005 -p 6006:6006 \
-v $PWD/.ci-config/:/etc/opt/ripple/ \
rippleci/rippled:2.3.0-rc1 \
rippled -a

```

Breaking down the command:
* `docker run -p 5005:5005 -p 6006:6006` starts a Docker container with an open port for admin JsonRPC and WebSocket requests.
* `--interactive` allows you to interact with the container.
* `-it` allows you to interact with the container.
* `-d` runs the docker container in detached mode. The container will run in the background and developer gets back control of the terminal
* `-t` starts a terminal in the container for you to send commands to.
* `--volume $PWD/.ci-config:/config/` identifies the `rippled.cfg` and `validators.txt` to import. It must be an absolute path, so we use `$PWD` instead of `./`.
* `xrpllabsofficial/xrpld:1.12.0` is an image that is regularly updated with the latest `rippled` releases and can be found here: https://github.com/WietseWind/docker-rippled
* `--volume $PWD/.ci-config:/etc/opt/ripple/` mounts the directories as indicated. It must be an absolute path, so we use `$PWD` instead of `./`. `rippled` software searches the location `/etc/opt/ripple/` (default behavior) for the config files. Hence there is no need to explicitly specify the config-file path.
* `rippleci/rippled:develop` is an image that is regularly updated with the latest build of the `develop` branch of `rippled`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update and standardize Docker command explanations

The explanations need to be updated to match the new Docker command and follow consistent formatting:

  1. Use consistent bullet point style (dashes instead of asterisks)
  2. Update explanations to match the new command structure
  3. Fix grammar issues

Apply these changes:

-* `docker run -p 5005:5005 -p 6006:6006` starts a Docker container with an open port for admin JsonRPC and WebSocket requests.
-* `-it` allows you to interact with the container.
-* `-d` runs the docker container in detached mode. The container will run in the background and developer gets back control of the terminal
-* `-t` starts a terminal in the container for you to send commands to.
-* `--volume $PWD/.ci-config:/etc/opt/ripple/` mounts the directories as indicated. It must be an absolute path, so we use `$PWD` instead of `./`. `rippled` software searches the location `/etc/opt/ripple/` (default behavior) for the config files. Hence there is no need to explicitly specify the config-file path.
-* `rippleci/rippled:develop` is an image that is regularly updated with the latest build of the `develop` branch of `rippled`.
+Breaking down the command:
+- `-p 5005:5005 -p 6006:6006` exposes ports for admin JsonRPC (5005) and WebSocket (6006) requests
+- `--name rippled_standalone` assigns a name to the container for easier management
+- `-d` runs the container in detached mode (background)
+- `-v $PWD/.ci-config/:/etc/opt/ripple/` mounts the local config directory. Uses absolute path ($PWD) to mount at the default rippled config location
+- `rippleci/rippled:2.3.0-rc1` specifies the rippled image version
+- `rippled -a` starts the rippled server in standalone mode

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~104-~104: A comma may be missing after the conjunctive/linking adverb ‘Hence’.
Context: ...default behavior) for the config files. Hence there is no need to explicitly specify ...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

🪛 Markdownlint

100-100: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


101-101: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


102-102: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


103-103: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


104-104: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


105-105: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

* `-a` starts `rippled` in standalone mode
* `--start` signals to start `rippled` with the specified amendments in `rippled.cfg` enabled immediately instead of voting for 2 weeks on them.

Then to actually run the tests, run the command:

Expand Down
25 changes: 25 additions & 0 deletions tests/integration/reusable_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
XRP,
AMMDeposit,
AMMDepositFlag,
CredentialAccept,
CredentialCreate,
IssuedCurrencyAmount,
OfferCreate,
PaymentChannelCreate,
Expand All @@ -21,6 +23,7 @@
XChainBridge,
XChainCreateBridge,
)
from xrpl.utils import str_to_hex
from xrpl.wallet import Wallet


Expand Down Expand Up @@ -95,6 +98,26 @@ async def _set_up_reusable_values():
amm_asset2 = setup_amm_pool_res["asset2"]
amm_issuer_wallet = setup_amm_pool_res["issuer_wallet"]

# Create and accept one credential; This is used in the PermissionedDomain tests
ckeshava marked this conversation as resolved.
Show resolved Hide resolved
cred_type: str = str_to_hex("IdentityDocument")
await sign_and_reliable_submission_async(
CredentialCreate(
account=wallet.address,
subject=destination.address,
credential_type=cred_type,
),
wallet,
)

credential_accept_txn_response = await sign_and_reliable_submission_async(
CredentialAccept(
issuer=wallet.address,
credential_type=cred_type,
account=destination.address,
),
destination,
)
ckeshava marked this conversation as resolved.
Show resolved Hide resolved

return (
wallet,
destination,
Expand All @@ -106,6 +129,7 @@ async def _set_up_reusable_values():
amm_asset2,
amm_issuer_wallet,
bridge,
credential_accept_txn_response,
)


Expand Down Expand Up @@ -149,4 +173,5 @@ async def setup_amm_pool(
AMM_ASSET2,
AMM_ISSUER_WALLET,
BRIDGE,
CREDENTIAL_ACCEPT_RESPONSE,
) = asyncio.run(_set_up_reusable_values())
121 changes: 121 additions & 0 deletions tests/integration/transactions/test_credential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
from tests.integration.integration_test_case import IntegrationTestCase
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 import AccountObjects, LedgerEntryType
from xrpl.models.requests.ledger_entry import Credential, LedgerEntry
from xrpl.models.response import ResponseStatus
from xrpl.models.transactions.credential_accept import CredentialAccept
from xrpl.models.transactions.credential_create import CredentialCreate
from xrpl.models.transactions.credential_delete import CredentialDelete
from xrpl.utils import str_to_hex

_URI = "www.my-id.com/username"


def is_cred_object_present(
result: dict, issuer: str, subject: str, cred_type: str
) -> bool:
"""
Args:
result: JSON response from account_objects RPC
issuer: Address of the credential issuer
subject: Address of the credential subject
cred_type: Type of the credential

Returns:
bool: True if credential exists, False otherwise
"""

for val in result["account_objects"]:
if (
val["Issuer"] == issuer
and val["Subject"] == subject
and val["CredentialType"] == cred_type
):
return True

return False


class TestCredentials(IntegrationTestCase):
@test_async_and_sync(globals())
async def test_valid(self, client):
# Define entities helpful for Credential lifecycle
_ISSUER = WALLET.address
_SUBJECT = DESTINATION.address

# Disambiguate the sync/async, json/websocket tests with different
# credential type values -- this avoids tecDUPLICATE error
# self.value is defined inside the above decorator
cred_type = str_to_hex("Passport_" + str(self.value))

tx = CredentialCreate(
account=_ISSUER,
subject=_SUBJECT,
credential_type=cred_type,
uri=str_to_hex(_URI),
)
response = await sign_and_reliable_submission_async(tx, WALLET, client)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# Use the LedgerEntry RPC to validate the creation of the credential object
ledger_entry_response = await client.request(
LedgerEntry(
credential=Credential(
subject=_SUBJECT, issuer=_ISSUER, credential_type=cred_type
)
)
)

self.assertEqual(ledger_entry_response.status, ResponseStatus.SUCCESS)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove direct LedgerEntry RPC call in integration test

Integration tests should focus on testing xrpl-py library functionalities rather than underlying rippled behaviors. Remove the direct LedgerEntry RPC call used to validate the creation of the credential object to align with testing guidelines.

# Execute the CredentialAccept transaction on the above Credential ledger object
tx = CredentialAccept(
issuer=_ISSUER, account=_SUBJECT, credential_type=cred_type
)
# CredentialAccept transaction is submitted by SUBJECT
response = await sign_and_reliable_submission_async(tx, DESTINATION, client)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# Execute the CredentialDelete transaction
# Subject initiates the deletion of the Credential ledger object
tx = CredentialDelete(
issuer=_ISSUER, account=_SUBJECT, credential_type=cred_type
)

response = await sign_and_reliable_submission_async(tx, DESTINATION, client)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# The credential ledger object must be deleted from both the Issuer and Subject
# account's directory pages
account_objects_response = await client.request(
AccountObjects(account=_ISSUER, type=LedgerEntryType.CREDENTIAL)
)
self.assertFalse(
is_cred_object_present(
account_objects_response.result,
issuer=_ISSUER,
subject=_SUBJECT,
cred_type=cred_type,
)
)

# Verify that the Credential object has been deleted from the Subject's
# directory page as well
account_objects_response = await client.request(
AccountObjects(account=_SUBJECT, type=LedgerEntryType.CREDENTIAL)
)
self.assertFalse(
is_cred_object_present(
account_objects_response.result,
issuer=_ISSUER,
subject=_SUBJECT,
cred_type=cred_type,
)
)
4 changes: 2 additions & 2 deletions tests/integration/transactions/test_delete_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
test_async_and_sync,
)
from tests.integration.reusable_values import WALLET
from xrpl.models import AccountObjects, AccountObjectType, OracleDelete, OracleSet
from xrpl.models import AccountObjects, LedgerEntryType, OracleDelete, OracleSet
from xrpl.models.response import ResponseStatus
from xrpl.models.transactions.oracle_set import PriceData
from xrpl.utils import str_to_hex
Expand Down Expand Up @@ -54,6 +54,6 @@ async def test_basic(self, client):

# confirm that the PriceOracle was actually deleted
account_objects_response = await client.request(
AccountObjects(account=WALLET.address, type=AccountObjectType.ORACLE)
AccountObjects(account=WALLET.address, type=LedgerEntryType.ORACLE)
)
self.assertEqual(len(account_objects_response.result["account_objects"]), 0)
44 changes: 38 additions & 6 deletions tests/integration/transactions/test_deposit_preauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,65 @@
sign_and_reliable_submission_async,
test_async_and_sync,
)
from tests.integration.reusable_values import WALLET
from tests.integration.reusable_values import DESTINATION, WALLET
from xrpl.models.response import ResponseStatus
from xrpl.models.transactions import DepositPreauth
from xrpl.models.transactions.deposit_preauth import Credential
from xrpl.utils import str_to_hex

ACCOUNT = WALLET.address
ADDRESS = "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de"


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding tests for PermissionedDomains interaction.

Since this is part of the PermissionedDomains amendment implementation, it would be valuable to add test cases that verify the interaction between DepositPreauth and PermissionedDomains functionality. This would help ensure the features work correctly together.

Consider adding test cases that:

  1. Verify authorization behavior with and without permissioned domains
  2. Test credential authorization in the context of domain permissions
  3. Validate the complete flow from domain creation to credential authorization

class TestDepositPreauth(IntegrationTestCase):
@test_async_and_sync(globals())
async def test_authorize(self, client):
async def test_authorize_unauthorize_fields(self, client):
deposit_preauth = DepositPreauth(
account=ACCOUNT,
authorize=ADDRESS,
authorize=DESTINATION.address,
)
response = await sign_and_reliable_submission_async(
deposit_preauth, WALLET, client
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# validate the un-authorization of the same address as above
deposit_preauth = DepositPreauth(
account=ACCOUNT,
unauthorize=DESTINATION.address,
)
response = await sign_and_reliable_submission_async(
deposit_preauth, WALLET, client
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

@test_async_and_sync(globals())
async def test_unauthorize(self, client):
async def test_credentials_array_input_fields(self, client):
sample_credentials = [
Credential(
issuer=DESTINATION.address, credential_type=str_to_hex("SampleCredType")
)
]

# Test the authorize_credentials input field
deposit_preauth = DepositPreauth(
account=ACCOUNT,
authorize_credentials=sample_credentials,
)
response = await sign_and_reliable_submission_async(
deposit_preauth, WALLET, client
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# Test the unauthorize_credentials input field
deposit_preauth = DepositPreauth(
account=ACCOUNT,
unauthorize=ADDRESS,
unauthorize_credentials=sample_credentials,
)
response = await sign_and_reliable_submission_async(
deposit_preauth, WALLET, client
)
self.assertEqual(response.status, ResponseStatus.SUCCESS)
self.assertEqual(response.result["engine_result"], "tesSUCCESS")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance test coverage with additional scenarios.

The current test covers the basic flow but could be strengthened by adding:

  1. Edge cases:
    • Empty credential array
    • Multiple credentials in the array
    • Invalid credential types
  2. State validation after each operation

Example additions:

# Test empty array
empty_credentials = []
deposit_preauth = DepositPreauth(
    account=ACCOUNT,
    authorize_credentials=empty_credentials,
)

# Test multiple credentials
multiple_credentials = [
    Credential(issuer=DESTINATION.address, credential_type=str_to_hex("Type1")),
    Credential(issuer=DESTINATION.address, credential_type=str_to_hex("Type2")),
]

# Test invalid credential type
invalid_credentials = [
    Credential(issuer=DESTINATION.address, credential_type="invalid"),
]

# Add state validation
account_info = await client.request(AccountInfo(account=ACCOUNT))
# Verify credentials are properly authorized/unauthorized

6 changes: 3 additions & 3 deletions tests/integration/transactions/test_did_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
test_async_and_sync,
)
from tests.integration.reusable_values import WALLET
from xrpl.models import AccountObjects, AccountObjectType, DIDDelete, DIDSet
from xrpl.models import AccountObjects, DIDDelete, DIDSet, LedgerEntryType
from xrpl.models.response import ResponseStatus

_VALID_FIELD = "1234567890abcdefABCDEF"
Expand All @@ -26,7 +26,7 @@ async def test_basic(self, client):

# confirm that the DID was actually created
account_objects_response = await client.request(
AccountObjects(account=WALLET.address, type=AccountObjectType.DID)
AccountObjects(account=WALLET.address, type=LedgerEntryType.DID)
)
self.assertEqual(len(account_objects_response.result["account_objects"]), 1)

Expand All @@ -40,6 +40,6 @@ async def test_basic(self, client):

# confirm that the DID was actually deleted
account_objects_response = await client.request(
AccountObjects(account=WALLET.address, type=AccountObjectType.DID)
AccountObjects(account=WALLET.address, type=LedgerEntryType.DID)
)
self.assertEqual(len(account_objects_response.result["account_objects"]), 0)
Loading
Loading