예제 #1
0
    def test_pseudo_transaction(self):
        json_dict = {
            "Account": "rrrrrrrrrrrrrrrrrrrrrhoLvTp",
            "Sequence": 0,
            "Fee": "0",
            "SigningPubKey": "",
            "Signature": "",
        }

        json_blank_acct = {
            "Account": "",
            "Sequence": 0,
            "Fee": "0",
            "SigningPubKey": "",
            "Signature": "",
        }

        binary = (
            "240000000068400000000000000073007600811400000000000000000000000000"
            "00000000000000")

        self.assertEqual(encode(json_dict), binary)
        self.assertEqual(decode(encode(json_dict)), json_dict)
        self.assertEqual(encode(json_blank_acct), binary)
        self.assertEqual(decode(encode(json_blank_acct)), json_dict)
예제 #2
0
    def test_lowercase(self):
        s = (
            "1100612200000000240000000125000068652D0000000055B6632D6376A2D9319F"
            "20A1C6DCCB486432D1E4A79951229D4C3DE2946F51D56662400009184E72A00081"
            "140DD319918CD5AE792BF7EC80D63B0F01B4573BBC")
        lower = s.lower()

        binary = (
            "1100612200000000240000000125000000082D00000000550735A0B32B2A3F4C93"
            "8B76D6933003E29447DB8C7CE382BBE089402FF12A03E56240000002540BE40081"
            "1479927BAFFD3D04A26096C0C97B1B0D45B01AD3C0")
        json_dict = {
            "OwnerCount":
            0,
            "Account":
            "rUnFEsHjxqTswbivzL2DNHBb34rhAgZZZK",
            "PreviousTxnLgrSeq":
            8,
            "LedgerEntryType":
            "AccountRoot",
            "PreviousTxnID":
            ("0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5"
             ).lower(),
            "Flags":
            0,
            "Sequence":
            1,
            "Balance":
            "10000000000",
        }

        json_upper = {
            "OwnerCount":
            0,
            "Account":
            "rUnFEsHjxqTswbivzL2DNHBb34rhAgZZZK",
            "PreviousTxnLgrSeq":
            8,
            "LedgerEntryType":
            "AccountRoot",
            "PreviousTxnID":
            ("0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5"
             ),
            "Flags":
            0,
            "Sequence":
            1,
            "Balance":
            "10000000000",
        }

        self.assertEqual(decode(lower), decode(s))
        self.assertEqual(encode(decode(lower)), s)
        self.assertEqual(encode(json_dict), binary)
        self.assertEqual(decode(encode(json_dict)), json_upper)
예제 #3
0
 def test_whole_object_fixtures(self):
     whole_object_tests = get_whole_object_tests()
     for whole_object in whole_object_tests:
         self.assertEqual(encode(whole_object.tx_json),
                          whole_object.expected_hex)
         self.assertEqual(decode(whole_object.expected_hex),
                          whole_object.tx_json)
예제 #4
0
 def _check_binary_and_json(self, test):
     test_binary = test["binary"]
     test_json = test["json"]
     with self.subTest(test_binary=test_binary, test_json=test_json):
         self.assertEqual(encode(test_json), test_binary)
         self.assertEqual(decode(test_binary), test_json)
예제 #5
0
 def test_xaddress_xaddr_and_mismatched_dest_tag(self):
     with self.assertRaises(XRPLBinaryCodecException):
         encode(invalid_json_x_and_dest_tag)
예제 #6
0
 def test_xaddress_xaddr_and_matching_source_tag(self):
     self.assertEqual(encode(valid_json_x_and_tags),
                      encode(valid_json_no_x_tags))
예제 #7
0
 def test_xaddress_invalid(self):
     with self.assertRaises(ValueError):
         encode(json_invalid_x)
예제 #8
0
 def test_xaddress_invalid_field(self):
     with self.assertRaises(XRPLBinaryCodecException):
         encode(invalid_json_issuer_tagged)
예제 #9
0
 def test_xaddress_decode(self):
     self.assertEqual(decode(encode(json_x1)), json_r1)
예제 #10
0
 def test_xaddress_null_tag(self):
     self.assertEqual(encode(json_null_x), encode(json_null_r))
예제 #11
0
 def _check_xaddress_jsons(self, test):
     x_json = test["xjson"]
     r_json = test["rjson"]
     with self.subTest(x_json=test["xjson"], r_json=test["rjson"]):
         self.assertEqual(encode(x_json), encode(r_json))
         self.assertEqual(decode(encode(x_json)), r_json)
예제 #12
0
 def test_xaddress_invalid(self):
     with self.assertRaises(XRPLBinaryCodecException):
         encode(json_invalid_x)
예제 #13
0
 def test_simple(self):
     encoded = encode(TX_JSON)
     decoded = decode(encoded)
     self.assertEqual(TX_JSON, decoded)
예제 #14
0
 def test_tx_fee_number(self):
     tx = {**TX_JSON, "Amount": "1000.789", "Fee": 10.123}
     with self.assertRaises(XRPLBinaryCodecException):
         encode(tx)
예제 #15
0
 def test_tx_amount_number(self):
     tx = {**TX_JSON, "Amount": 1000.789}
     with self.assertRaises(XRPLBinaryCodecException):
         encode(tx)
예제 #16
0
 def test_tx_invalid_amt_invalid_fee(self):
     tx = {**TX_JSON, "Amount": "1000.001", "Fee": "10"}
     with self.assertRaises(XRPLBinaryCodecException):
         encode(tx)
예제 #17
0
 def test_tx_amount_fee(self):
     tx = {**TX_JSON, "Amount": "1000", "Fee": "10"}
     self.assertEqual(decode(encode(tx)), tx)
예제 #18
0
 def test_xaddress_encode(self):
     self.assertEqual(encode(json_x1), encode(json_r1))
예제 #19
0
    def test_lowercase(self):
        s = (
            "1100612200000000240000000125000068652D0000000055B6632D6376A2D9319F"
            "20A1C6DCCB486432D1E4A79951229D4C3DE2946F51D56662400009184E72A00081"
            "140DD319918CD5AE792BF7EC80D63B0F01B4573BBC")
        lower = s.lower()

        binary = (
            "1100612200000000240000000125000000082D00000000550735A0B32B2A3F4C93"
            "8B76D6933003E29447DB8C7CE382BBE089402FF12A03E56240000002540BE40081"
            "1479927BAFFD3D04A26096C0C97B1B0D45B01AD3C0")
        json_dict = {
            "OwnerCount":
            0,
            "Account":
            "rUnFEsHjxqTswbivzL2DNHBb34rhAgZZZK",
            "PreviousTxnLgrSeq":
            8,
            "LedgerEntryType":
            "AccountRoot",
            "PreviousTxnID":
            ("0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5"
             ).lower(),
            "Flags":
            0,
            "Sequence":
            1,
            "Balance":
            "10000000000",
        }

        json_upper = {
            "OwnerCount":
            0,
            "Account":
            "rUnFEsHjxqTswbivzL2DNHBb34rhAgZZZK",
            "PreviousTxnLgrSeq":
            8,
            "LedgerEntryType":
            "AccountRoot",
            "PreviousTxnID":
            ("0735A0B32B2A3F4C938B76D6933003E29447DB8C7CE382BBE089402FF12A03E5"
             ),
            "Flags":
            0,
            "Sequence":
            1,
            "Balance":
            "10000000000",
        }

        lowerCaseIntBinary = (
            "11007222001100002501EC24873700000000000000003800000000000000A35506"
            "FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA62D4"
            "4BF89AC2A40B800000000000000000000000004A50590000000000000000000000"
            "000000000000000000000000000166D6C38D7EA4C6800000000000000000000000"
            "00004A5059000000000047C1258B4B79774B28176324068F759EDE226F68678000"
            "0000000000000000000000000000000000004A505900000000005BBC0F22F61D92"
            "24A110650CFE21CC0C4BE13098")

        lowerCaseIntJson = {
            "Balance": {
                "currency": "JPY",
                "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
                "value": "0.3369568318",
            },
            "Flags":
            1114112,
            "HighLimit": {
                "currency": "JPY",
                "issuer": "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN",
                "value": "0",
            },
            "HighNode":
            "a3",
            "LedgerEntryType":
            "RippleState",
            "LowLimit": {
                "currency": "JPY",
                "issuer": "rfYQMgj3g3Qp8VLoZNvvU35mEuuJC8nCmY",
                "value": "1000000000",
            },
            "LowNode":
            "0",
            "PreviousTxnID":
            ("06FC7DE374089D50F81AAE13E7BBF3D0E694769331E14F55351B38D0148018EA"
             ).lower(),
            "PreviousTxnLgrSeq":
            32253063,
            "index":
            "000319BAE0A618A7D3BB492F17E98E5D92EA0C6458AFEBED44206B5B4798A840",
        }

        self.assertEqual(decode(lower), decode(s))
        self.assertEqual(encode(decode(lower)), s)
        self.assertEqual(encode(json_dict), binary)
        self.assertEqual(decode(encode(json_dict)), json_upper)
        self.assertEqual(encode(lowerCaseIntJson), lowerCaseIntBinary)