Skip to content

Commit ce9e9b6

Browse files
committed
address code rabbit suggestions
1 parent 935d170 commit ce9e9b6

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

tests/unit/core/binarycodec/types/test_int32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from xrpl.core.binarycodec.types.int32 import Int32
55

66

7-
class TestUInt(TestCase):
7+
class TestInt32(TestCase):
88
def test_compare_INT32(self):
99
value1 = Int32.from_value(124)
1010
value2 = Int32.from_value(123)

tests/unit/models/transactions/test_loan_pay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_invalid_flag_input(self):
3636
"{'LoanPay:Flags': 'Unrecognised flag in the LoanPay " + "transaction'}",
3737
)
3838

39-
def test_valid_loan_set(self):
39+
def test_valid_loan_pay(self):
4040
tx = LoanPay(
4141
account=_SOURCE,
4242
loan_id=_LOAN_ID,

tests/unit/models/transactions/test_vault_create.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,33 @@ def test_tx_emits_warning_for_missing_icon_metadata(self):
122122
"- uris/us: should be an array of objects each "
123123
"with uri/u, category/c, and title/t properties.",
124124
)
125+
126+
def test_scale_field_too_large(self):
127+
with self.assertRaises(XRPLModelException) as error:
128+
VaultCreate(
129+
account=_ACCOUNT,
130+
asset=IssuedCurrency(currency="USD", issuer=_ACCOUNT),
131+
assets_maximum="1000",
132+
withdrawal_policy=1,
133+
data=str_to_hex("A" * 256),
134+
scale=18 + 1,
135+
)
136+
self.assertEqual(
137+
error.exception.args[0],
138+
"{'VaultCreate': 'Scale field is higher than the allowed limit (18)'}",
139+
)
140+
141+
def test_scale_field_too_small(self):
142+
with self.assertRaises(XRPLModelException) as error:
143+
VaultCreate(
144+
account=_ACCOUNT,
145+
asset=IssuedCurrency(currency="USD", issuer=_ACCOUNT),
146+
assets_maximum="1000",
147+
withdrawal_policy=1,
148+
data=str_to_hex("A" * 256),
149+
scale=-1,
150+
)
151+
self.assertEqual(
152+
error.exception.args[0],
153+
"{'VaultCreate': 'Scale field is lower than the allowed limit (0)'}",
154+
)

tests/unit/models/transactions/test_vault_withdraw.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
_ACCOUNT = "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW"
88
_VAULT_ID = "B982D2AAEF6014E6BE3194D939865453D56D16FF7081BB1D0ED865C708ABCEEE"
9+
_DESTINATION = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"
910

1011

1112
class TestVaultWithdraw(TestCase):
@@ -22,6 +23,7 @@ def test_valid_with_destination_tag(self):
2223
account=_ACCOUNT,
2324
vault_id=_VAULT_ID,
2425
amount=IssuedCurrencyAmount(currency="USD", issuer=_ACCOUNT, value="100"),
26+
destination=_DESTINATION,
2527
destination_tag=3000,
2628
)
2729
self.assertTrue(tx.is_valid())

xrpl/models/transactions/loan_pay.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class LoanPayFlag(int, Enum):
1919
"""
20-
Enum for LoanPAY Transaction Flags.
20+
Enum for LoanPay Transaction Flags.
2121
2222
Transactions of the LoanPay type support additional values in the flags field
2323
"""
@@ -40,13 +40,13 @@ class LoanPayFlag(int, Enum):
4040

4141
class LoanPayFlagInterface(TransactionFlagInterface):
4242
"""
43-
Transactions of the LoanManage type support additional values in the Flags field.
43+
Transactions of the LoanPay type support additional values in the Flags field.
4444
This TypedDict represents those options.
4545
"""
4646

47-
TF_LOAN_DEFAULT: bool
48-
TF_LOAN_IMPAIR: bool
49-
TF_LOAN_UNIMPAIR: bool
47+
TF_LOAN_OVERPAYMENT: bool
48+
TF_LOAN_FULL_PAYMENT: bool
49+
TF_LOAN_LATE_PAYMENT: bool
5050

5151

5252
@require_kwargs_on_init
@@ -79,9 +79,7 @@ def _get_errors(self: Self) -> Dict[str, str]:
7979
if self.flags is not None and isinstance(self.flags, int):
8080
# Check for unrecognized flags (bits set outside valid mask)
8181
if self.flags & ~self._VALID_FLAGS_MASK:
82-
errors[
83-
"LoanPay:Flags"
84-
] = "Unrecognised flag in the LoanPay transaction"
82+
errors["LoanPay:Flags"] = "Unrecognised flag in the LoanPay transaction"
8583
# Check that at most one flag is enabled
8684
elif bin(self.flags & self._VALID_FLAGS_MASK).count("1") > 1:
8785
errors["LoanPay:Flags"] = (

xrpl/models/transactions/vault_create.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ def _get_errors(self: Self) -> Dict[str, str]:
132132
"Invalid domain ID: Length must be 32 characters (64 hex characters)."
133133
)
134134

135+
if self.scale is not None:
136+
if self.scale > 18:
137+
errors["VaultCreate"] = (
138+
"Scale field is higher than the allowed limit (18)"
139+
)
140+
elif self.scale < 0:
141+
errors["VaultCreate"] = (
142+
"Scale field is lower than the allowed limit (0)"
143+
)
144+
135145
if self.mptoken_metadata is not None:
136146
# Lazy import to avoid circular dependency
137147
from xrpl.utils.mptoken_metadata import validate_mptoken_metadata

0 commit comments

Comments
 (0)