Skip to content

Commit

Permalink
Revert "add MPTAmount support in Payment tx and binary-codec"
Browse files Browse the repository at this point in the history
This reverts commit 9fdee49.
  • Loading branch information
khancode committed Aug 14, 2024
1 parent bc6ea59 commit 6a55a1d
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 528 deletions.
52 changes: 0 additions & 52 deletions tests/integration/transactions/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
test_async_and_sync,
)
from tests.integration.reusable_values import DESTINATION, WALLET

# from xrpl.models.amounts.mpt_amount import MPTAmount
from xrpl.models.exceptions import XRPLModelException

# from xrpl.models.requests.account_objects import AccountObjects, AccountObjectType
from xrpl.models.transactions import Payment

# from xrpl.models.transactions.mptoken_issuance_create import MPTokenIssuanceCreate
# from xrpl.utils import int_to_hex


class TestPayment(IntegrationTestCase):
@test_async_and_sync(globals())
Expand Down Expand Up @@ -141,48 +134,3 @@ async def test_deliver_max_alias_field(self, client):
client,
)
self.assertFalse(response.is_successful())

# TODO: uncomment test module when rippled Docker image supports MPT feature
# @test_async_and_sync(globals())
# async def test_mpt_payment(self, client):
# tx = MPTokenIssuanceCreate(
# account=WALLET.classic_address,
# maximum_amount=int_to_hex(9223372036854775807), # "7fffffffffffffff"
# asset_scale=2,
# )

# response = await sign_and_reliable_submission_async(
# tx,
# WALLET,
# client,
# )

# self.assertTrue(response.is_successful())
# self.assertEqual(response.result["engine_result"], "tesSUCCESS")

# # confirm MPTokenIssuance ledger object was created
# account_objects_response = await client.request(
# AccountObjects(
# account=WALLET.address, type=AccountObjectType.MPT_ISSUANCE
# )
# )

# # subsequent integration tests (sync/async + json/websocket) add one
# # MPTokenIssuance object to the account
# account_objects = account_objects_response.result["account_objects"]
# self.assertTrue(len(account_objects) > 0)

# mpt_issuance_id = account_objects[0]["mpt_issuance_id"]

# payment = Payment(
# account=WALLET.address,
# amount=MPTAmount(mpt_issuance_id=mpt_issuance_id, value="10"),
# destination=DESTINATION.address,
# )

# response = await sign_and_reliable_submission_async(
# payment,
# WALLET,
# client,
# )
# self.assertTrue(response.is_successful())
172 changes: 0 additions & 172 deletions tests/unit/core/binarycodec/fixtures/data/data-driven-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2762,14 +2762,6 @@
"expected_hex": "4000000000000001",
"is_negative": false
},
{
"test_json": "-1",
"type_id": 6,
"is_native": true,
"type": "Amount",
"error": "Value is negative",
"is_negative": true
},
{
"test_json": {
"currency": "USD",
Expand Down Expand Up @@ -3955,170 +3947,6 @@
"type_specialisation_field": "TransactionResult",
"type": "UInt8",
"expected_hex": "8D"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "9223372036854775808"
},
"type": "Amount",
"error": "Value is too large"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "18446744073709551615"
},
"type": "Amount",
"error": "Value is too large"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "-1"
},
"type": "Amount",
"error": "Value is negative"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "10.1"
},
"type": "Amount",
"error": "Value has decimal point"
},
{
"test_json": {
"mpt_issuance_id": "10",
"value": "10"
},
"type": "Amount",
"error": "mpt_issuance_id has invalid hash length"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "10",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji"
},
"type": "Amount",
"error": "Issuer not valid for MPT"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "10",
"currency": "USD"
},
"type": "Amount",
"error": "Currency not valid for MPT"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "a"
},
"type": "Amount",
"error": "Value has incorrect hex format"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0xy"
},
"type": "Amount",
"error": "Value has bad hex character"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "/"
},
"type": "Amount",
"error": "Value has bad character"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0x8000000000000000"
},
"type": "Amount",
"error": "Hex value out of range"
},
{
"test_json": {
"mpt_issuance_id": "00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0xFFFFFFFFFFFFFFFF"
},
"type": "Amount",
"error": "Hex value out of range"
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "9223372036854775807"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "607FFFFFFFFFFFFFFF00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "60000000000000000000002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "-0"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "60000000000000000000002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "100"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "60000000000000006400002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0xa"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "60000000000000000A00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
},
{
"test_json": {
"mpt_issuance_id":"00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"value": "0x7FFFFFFFFFFFFFFF"
},
"type_id": 6,
"is_native": false,
"type": "Amount",
"expected_hex": "607FFFFFFFFFFFFFFF00002403C84A0A28E0190E208E982C352BBD5006600555CF",
"is_negative": false
}
]
}
29 changes: 0 additions & 29 deletions tests/unit/core/binarycodec/types/test_amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@
["100000000000000000", "416345785D8A0000"],
]

# [MPT dict, expected serialized hex]
MPT_CASES = [
[
{
"mpt_issuance_id": "0000012FFD9EE5DA93AC614B4DB94D7E0FCE415CA51BED47",
"value": "1",
},
"6000000000000000010000012FFD9EE5DA93AC614B4DB94D7E0FCE415CA51BED47",
],
[
{
"value": "9223372036854775807",
"mpt_issuance_id": "0000012FFD9EE5DA93AC614B4DB94D7E0FCE415CA51BED47",
},
"607FFFFFFFFFFFFFFF0000012FFD9EE5DA93AC614B4DB94D7E0FCE415CA51BED47",
],
]


class TestAmount(TestSerializedType):
def test_assert_xrp_is_valid_passes(self):
Expand Down Expand Up @@ -166,11 +148,6 @@ def test_from_value_xrp(self):
amount_object = amount.Amount.from_value(json)
self.assertEqual(amount_object.to_hex(), serialized)

def test_from_value_mpt(self):
for json, serialized in MPT_CASES:
amount_object = amount.Amount.from_value(json)
self.assertEqual(amount_object.to_hex(), serialized)

def test_to_json_issued_currency(self):
for json, serialized in IOU_CASES:
parser = BinaryParser(serialized)
Expand All @@ -183,12 +160,6 @@ def test_to_json_xrp(self):
amount_object = amount.Amount.from_parser(parser)
self.assertEqual(amount_object.to_json(), json)

def test_to_json_mpt(self):
for json, serialized in MPT_CASES:
parser = BinaryParser(serialized)
amount_object = amount.Amount.from_parser(parser)
self.assertEqual(amount_object.to_json(), json)

def test_fixtures(self):
for fixture in data_driven_fixtures_for_type("Amount"):
self.fixture_test(fixture)
Expand Down
29 changes: 0 additions & 29 deletions tests/unit/core/binarycodec/types/test_hash_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException
from xrpl.core.binarycodec.types.hash128 import Hash128
from xrpl.core.binarycodec.types.hash160 import Hash160
from xrpl.core.binarycodec.types.hash192 import Hash192
from xrpl.core.binarycodec.types.hash256 import Hash256


Expand Down Expand Up @@ -68,34 +67,6 @@ def test_raises_invalid_value_type(self):
self.assertRaises(XRPLBinaryCodecException, Hash160.from_value, invalid_value)


class TestHash192(TestCase):
def setUp(self):
# 24 bytes, 48 nibbles
self.hex_192_bits = "100000000020000000003000000000400000000050000000"
self.parser = BinaryParser(self.hex_192_bits)
self.expected_width = 24

def test_constructors(self):
from_constructor = Hash192(bytes.fromhex(self.hex_192_bits))
from_value = Hash192.from_value(self.hex_192_bits)
from_parser = Hash192.from_parser(self.parser)

self.assertEqual(from_constructor.to_hex(), self.hex_192_bits)
self.assertEqual(from_value.to_hex(), self.hex_192_bits)
self.assertEqual(from_parser.to_hex(), self.hex_192_bits)

def test_constructor_raises_invalid_length(self):
# 25 bytes, 50 nibbles
too_many_bytes_hex = "10000000002000000000300000000040000000005000000012"
self.assertRaises(
XRPLBinaryCodecException, Hash192.from_value, too_many_bytes_hex
)

def test_raises_invalid_value_type(self):
invalid_value = 1
self.assertRaises(XRPLBinaryCodecException, Hash192.from_value, invalid_value)


class TestHash256(TestCase):
def setUp(self):
# 32 bytes, 64 nibbles
Expand Down
14 changes: 0 additions & 14 deletions tests/unit/models/transactions/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,3 @@ def test_destination_wallet(self):
}
with self.assertRaises(XRPLModelException):
Payment(**transaction_dict)

def test_mpt_payment(self):
transaction_dict = {
"account": _ACCOUNT,
"fee": _FEE,
"sequence": _SEQUENCE,
"amount": {
"mpt_issuance_id": "000004C463C52827307480341125DA0577DEFC38405B0E3E",
"value": "10",
},
"destination": _DESTINATION,
}
tx = Payment(**transaction_dict)
self.assertTrue(tx.is_valid())
2 changes: 0 additions & 2 deletions xrpl/core/binarycodec/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from xrpl.core.binarycodec.types.hash import Hash
from xrpl.core.binarycodec.types.hash128 import Hash128
from xrpl.core.binarycodec.types.hash160 import Hash160
from xrpl.core.binarycodec.types.hash192 import Hash192
from xrpl.core.binarycodec.types.hash256 import Hash256
from xrpl.core.binarycodec.types.issue import Issue
from xrpl.core.binarycodec.types.path_set import PathSet
Expand All @@ -28,7 +27,6 @@
"Hash",
"Hash128",
"Hash160",
"Hash192",
"Hash256",
"Issue",
"PathSet",
Expand Down
Loading

0 comments on commit 6a55a1d

Please sign in to comment.