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

Verifiable Credentials #759

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
78 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
c7a6e2e
remove extraneous comments
ckeshava Nov 15, 2024
344bb49
[WIP] use single docker run command
ckeshava Nov 15, 2024
ee01fc9
[WIP] Revert some changes to the CICD integration tests
ckeshava Nov 15, 2024
09b7d18
[refactor] address Ashray PR suggestion
ckeshava Nov 15, 2024
87d2af7
update release notes in CHANGELOG
ckeshava Nov 15, 2024
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
2 changes: 2 additions & 0 deletions .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@ PriceOracle
fixEmptyDID
fixXChainRewardRounding
fixPreviousTxnID
# Explicitly enable featureCredentials
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is unnecessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in f2651ca

Credentials
mvadari marked this conversation as resolved.
Show resolved Hide resolved
55 changes: 55 additions & 0 deletions tests/integration/transactions/test_credential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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.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"


class TestCredentialCreate(IntegrationTestCase):
ckeshava marked this conversation as resolved.
Show resolved Hide resolved
@test_async_and_sync(globals())
async def test_valid(self, client):
mvadari marked this conversation as resolved.
Show resolved Hide resolved
# 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")

mvadari marked this conversation as resolved.
Show resolved Hide resolved
# 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")
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"


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")
mvadari marked this conversation as resolved.
Show resolved Hide resolved
59 changes: 59 additions & 0 deletions tests/unit/models/transactions/test_credential_accept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from unittest import TestCase

from xrpl.models.exceptions import XRPLModelException
from xrpl.models.transactions.credential_accept import CredentialAccept
from xrpl.utils import str_to_hex

_ACCOUNT_ISSUER = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ"
_ACCOUNT_SUBJECT = "rNdY9XDnQ4Dr1EgefwU3CBRuAjt3sAutGg"
_VALID_CREDENTIAL_TYPE = str_to_hex("Passport")


class TestCredentialAccept(TestCase):
def test_valid(self):
tx = CredentialAccept(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
)
self.assertTrue(tx.is_valid())

ckeshava marked this conversation as resolved.
Show resolved Hide resolved
# invalid inputs to the credential_type field
def test_cred_type_field_too_long(self):
with self.assertRaises(XRPLModelException) as error:
CredentialAccept(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type=str_to_hex("A" * 65),
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must not be greater "
+ "than 64 bytes. '}",
)

def test_cred_type_field_empty(self):
with self.assertRaises(XRPLModelException) as error:
CredentialAccept(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type="",
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must be greater than "
+ "0. credential_type field must be encoded in base-16 format. '}",
)

def test_cred_type_field_not_hex(self):
with self.assertRaises(XRPLModelException) as error:
CredentialAccept(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type="Passport",
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'credential_type field must be encoded in base-16 "
+ "format. '}",
)
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 boundary test cases.

The current tests cover important invalid scenarios, but consider adding these additional test cases:

  1. Test with exactly 64 bytes (boundary condition)
  2. Test with special characters in hex string
  3. Test with mixed case hex string
def test_cred_type_field_exact_length(self):
    # Test with exactly 64 bytes
    tx = CredentialAccept(
        issuer=_ACCOUNT_ISSUER,
        account=_ACCOUNT_SUBJECT,
        credential_type=str_to_hex("A" * 32),  # 32 chars = 64 bytes in hex
    )
    self.assertTrue(tx.is_valid())

def test_cred_type_field_special_hex(self):
    # Test with valid hex containing special characters
    with self.assertRaises(XRPLModelException) as error:
        CredentialAccept(
            issuer=_ACCOUNT_ISSUER,
            account=_ACCOUNT_SUBJECT,
            credential_type="!@#$%^",
        )

def test_cred_type_field_mixed_case(self):
    # Test with mixed case hex string
    tx = CredentialAccept(
        issuer=_ACCOUNT_ISSUER,
        account=_ACCOUNT_SUBJECT,
        credential_type="aAbBcCdD",
    )
    self.assertTrue(tx.is_valid())

114 changes: 114 additions & 0 deletions tests/unit/models/transactions/test_credential_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
from unittest import TestCase

from xrpl.models.exceptions import XRPLModelException
from xrpl.models.transactions.credential_create import CredentialCreate
from xrpl.utils import str_to_hex

_ACCOUNT_ISSUER = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ"
_ACCOUNT_SUBJECT = "rNdY9XDnQ4Dr1EgefwU3CBRuAjt3sAutGg"
_VALID_CREDENTIAL_TYPE = str_to_hex("Passport")
_VALID_URI = str_to_hex("www.my-id.com/username")


class TestCredentialCreate(TestCase):
def test_valid(self):
tx = CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
uri=_VALID_URI,
)
self.assertTrue(tx.is_valid())

mvadari marked this conversation as resolved.
Show resolved Hide resolved
# invalid URI field inputs
def test_uri_field_too_long(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
uri=str_to_hex("A" * 257),
)
self.assertEqual(
error.exception.args[0],
"{'uri': 'Length of URI field must not be greater than 256 characters. '}",
)

def test_uri_field_empty(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
uri=str_to_hex(""),
)
self.assertEqual(
error.exception.args[0],
"{'uri': 'Length of URI field must be greater than 0. URI field must be "
+ "encoded in base-16 format. '}",
)

def test_uri_field_not_hex(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
uri="www.identity-repo.com/username",
)
self.assertEqual(
error.exception.args[0],
"{'uri': 'URI field must be encoded in base-16 format. '}",
)
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

Add test for URI with invalid hex characters.

The current tests verify empty, too long, and non-hex URIs, but don't test for URIs with invalid hex characters (e.g., "0x1G").

def test_uri_field_invalid_hex(self):
    """Test that a URI with invalid hex characters raises an exception."""
    with self.assertRaises(XRPLModelException) as error:
        CredentialCreate(
            account=_ACCOUNT_ISSUER,
            subject=_ACCOUNT_SUBJECT,
            credential_type=_VALID_CREDENTIAL_TYPE,
            uri="1G",  # Invalid hex character
        )
    self.assertEqual(
        error.exception.args[0],
        "{'uri': 'URI field must be encoded in base-16 format. '}"
    )


# invalid inputs to the credential_type field
def test_cred_type_field_too_long(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=str_to_hex("A" * 65),
uri=_VALID_URI,
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must not be greater "
+ "than 64 bytes. '}",
)

def test_cred_type_field_empty(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type="",
uri=_VALID_URI,
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must be greater than "
+ "0. credential_type field must be encoded in base-16 format. '}",
)

def test_cred_type_field_not_hex(self):
with self.assertRaises(XRPLModelException) as error:
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type="Passport",
uri=_VALID_URI,
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'credential_type field must be encoded in base-16 "
+ "format. '}",
)

def test_create_cred_type_object_all_empty_fields(self):
with self.assertRaises(XRPLModelException):
CredentialCreate(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type="",
uri="",
)
ckeshava marked this conversation as resolved.
Show resolved Hide resolved
79 changes: 79 additions & 0 deletions tests/unit/models/transactions/test_credential_delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from unittest import TestCase

from xrpl.models.exceptions import XRPLModelException
from xrpl.models.transactions.credential_delete import CredentialDelete
from xrpl.utils import str_to_hex

_ACCOUNT_ISSUER = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ"
_ACCOUNT_SUBJECT = "rNdY9XDnQ4Dr1EgefwU3CBRuAjt3sAutGg"
_VALID_CREDENTIAL_TYPE = str_to_hex("Passport")


class TestCredentialDelete(TestCase):
def test_valid(self):
tx = CredentialDelete(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
)
self.assertTrue(tx.is_valid())

# alternative specification of the CredentialDelete transaction
tx = CredentialDelete(
account=_ACCOUNT_ISSUER,
subject=_ACCOUNT_SUBJECT,
credential_type=_VALID_CREDENTIAL_TYPE,
)
self.assertTrue(tx.is_valid())

def test_unspecified_subject_and_issuer(self):
with self.assertRaises(XRPLModelException) as error:
CredentialDelete(
account=_ACCOUNT_SUBJECT,
credential_type=str_to_hex("DMV_ID"),
)
self.assertEqual(
error.exception.args[0],
"{'invalid_params': 'CredentialDelete transaction requires at least one "
+ "input amongst issuer or subject. '}",
)

# invalid inputs to the credential_type field
def test_cred_type_field_too_long(self):
with self.assertRaises(XRPLModelException) as error:
CredentialDelete(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type=str_to_hex("A" * 65),
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must not be greater "
+ "than 64 bytes. '}",
)

def test_cred_type_field_empty(self):
with self.assertRaises(XRPLModelException) as error:
CredentialDelete(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type="",
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'Length of credential_type field must be greater than "
+ "0. credential_type field must be encoded in base-16 format. '}",
)

def test_cred_type_field_not_hex(self):
with self.assertRaises(XRPLModelException) as error:
CredentialDelete(
issuer=_ACCOUNT_ISSUER,
account=_ACCOUNT_SUBJECT,
credential_type="Passport",
)
self.assertEqual(
error.exception.args[0],
"{'credential_type': 'credential_type field must be encoded in base-16 "
+ "format. '}",
)
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 more edge cases to improve test coverage.

The current error case tests are well-implemented, but consider adding these additional test cases for more comprehensive coverage:

  1. Test with null/None values for each field
  2. Test with invalid XRPL account addresses
  3. Test with maximum valid credential type length (63 bytes)
  4. Test with special characters in credential type (before hex encoding)

Example additional test:

def test_invalid_account_address(self):
    with self.assertRaises(XRPLModelException) as error:
        CredentialDelete(
            issuer="invalid_address",
            account=_ACCOUNT_SUBJECT,
            credential_type=_VALID_CREDENTIAL_TYPE,
        )
    self.assertEqual(
        error.exception.args[0],
        "{'issuer': 'Invalid account address format'}"
    )

Loading
Loading