ripple-binary-codec 1.0.2 → 1.0.3-mpt-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +3 -3
  2. package/dist/binary.d.ts +34 -20
  3. package/dist/binary.js +51 -34
  4. package/dist/binary.js.map +1 -1
  5. package/dist/coretypes.d.ts +9 -9
  6. package/dist/coretypes.js +33 -9
  7. package/dist/coretypes.js.map +1 -1
  8. package/dist/enums/bytes.d.ts +25 -0
  9. package/dist/enums/bytes.js +63 -0
  10. package/dist/enums/bytes.js.map +1 -0
  11. package/dist/enums/constants.d.ts +4 -0
  12. package/dist/enums/constants.js +8 -0
  13. package/dist/enums/constants.js.map +1 -0
  14. package/dist/enums/definitions.json +3066 -1760
  15. package/dist/enums/field.d.ts +28 -0
  16. package/dist/enums/field.js +58 -0
  17. package/dist/enums/field.js.map +1 -0
  18. package/dist/enums/index.d.ts +12 -46
  19. package/dist/enums/index.js +22 -110
  20. package/dist/enums/index.js.map +1 -1
  21. package/dist/enums/src/enums/definitions.json +3073 -0
  22. package/dist/enums/utils-renumber.js +20 -20
  23. package/dist/enums/utils-renumber.js.map +1 -1
  24. package/dist/enums/xrpl-definitions-base.d.ts +44 -0
  25. package/dist/enums/xrpl-definitions-base.js +59 -0
  26. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  27. package/dist/enums/xrpl-definitions.d.ts +21 -0
  28. package/dist/enums/xrpl-definitions.js +29 -0
  29. package/dist/enums/xrpl-definitions.js.map +1 -0
  30. package/dist/hash-prefixes.d.ts +1 -2
  31. package/dist/hash-prefixes.js +7 -6
  32. package/dist/hash-prefixes.js.map +1 -1
  33. package/dist/hashes.d.ts +7 -8
  34. package/dist/hashes.js +23 -44
  35. package/dist/hashes.js.map +1 -1
  36. package/dist/index.d.ts +16 -17
  37. package/dist/index.js +65 -40
  38. package/dist/index.js.map +1 -1
  39. package/dist/ledger-hashes.d.ts +6 -3
  40. package/dist/ledger-hashes.js +40 -33
  41. package/dist/ledger-hashes.js.map +1 -1
  42. package/dist/quality.d.ts +3 -4
  43. package/dist/quality.js +20 -19
  44. package/dist/quality.js.map +1 -1
  45. package/dist/serdes/binary-parser.d.ts +8 -6
  46. package/dist/serdes/binary-parser.js +74 -64
  47. package/dist/serdes/binary-parser.js.map +1 -1
  48. package/dist/serdes/binary-serializer.d.ts +10 -11
  49. package/dist/serdes/binary-serializer.js +50 -48
  50. package/dist/serdes/binary-serializer.js.map +1 -1
  51. package/dist/shamap.d.ts +6 -7
  52. package/dist/shamap.js +74 -97
  53. package/dist/shamap.js.map +1 -1
  54. package/dist/src/binary.d.ts +90 -0
  55. package/dist/src/binary.js +128 -0
  56. package/dist/src/binary.js.map +1 -0
  57. package/dist/src/coretypes.d.ts +9 -0
  58. package/dist/src/coretypes.js +48 -0
  59. package/dist/src/coretypes.js.map +1 -0
  60. package/dist/src/enums/bytes.d.ts +25 -0
  61. package/dist/src/enums/bytes.js +63 -0
  62. package/dist/src/enums/bytes.js.map +1 -0
  63. package/dist/src/enums/constants.d.ts +4 -0
  64. package/dist/src/enums/constants.js +8 -0
  65. package/dist/src/enums/constants.js.map +1 -0
  66. package/dist/src/enums/definitions.json +3068 -0
  67. package/dist/src/enums/field.d.ts +28 -0
  68. package/dist/src/enums/field.js +58 -0
  69. package/dist/src/enums/field.js.map +1 -0
  70. package/dist/src/enums/index.d.ts +12 -0
  71. package/dist/src/enums/index.js +31 -0
  72. package/dist/src/enums/index.js.map +1 -0
  73. package/dist/src/enums/utils-renumber.d.ts +101 -0
  74. package/dist/src/enums/utils-renumber.js +127 -0
  75. package/dist/src/enums/utils-renumber.js.map +1 -0
  76. package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
  77. package/dist/src/enums/xrpl-definitions-base.js +59 -0
  78. package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
  79. package/dist/src/enums/xrpl-definitions.d.ts +21 -0
  80. package/dist/src/enums/xrpl-definitions.js +29 -0
  81. package/dist/src/enums/xrpl-definitions.js.map +1 -0
  82. package/dist/src/hash-prefixes.d.ts +5 -0
  83. package/dist/src/hash-prefixes.js +41 -0
  84. package/dist/src/hash-prefixes.js.map +1 -0
  85. package/dist/src/hashes.d.ts +50 -0
  86. package/dist/src/hashes.js +76 -0
  87. package/dist/src/hashes.js.map +1 -0
  88. package/dist/src/index.d.ts +64 -0
  89. package/dist/src/index.js +123 -0
  90. package/dist/src/index.js.map +1 -0
  91. package/dist/src/ledger-hashes.d.ts +48 -0
  92. package/dist/src/ledger-hashes.js +141 -0
  93. package/dist/src/ledger-hashes.js.map +1 -0
  94. package/dist/src/quality.d.ts +21 -0
  95. package/dist/src/quality.js +42 -0
  96. package/dist/src/quality.js.map +1 -0
  97. package/dist/src/serdes/binary-parser.d.ts +100 -0
  98. package/dist/src/serdes/binary-parser.js +194 -0
  99. package/dist/src/serdes/binary-parser.js.map +1 -0
  100. package/dist/src/serdes/binary-serializer.d.ts +81 -0
  101. package/dist/src/serdes/binary-serializer.js +149 -0
  102. package/dist/src/serdes/binary-serializer.js.map +1 -0
  103. package/dist/src/shamap.d.ts +102 -0
  104. package/dist/src/shamap.js +172 -0
  105. package/dist/src/shamap.js.map +1 -0
  106. package/dist/src/types/account-id.d.ts +35 -0
  107. package/dist/src/types/account-id.js +69 -0
  108. package/dist/src/types/account-id.js.map +1 -0
  109. package/dist/src/types/amount.d.ts +91 -0
  110. package/dist/src/types/amount.js +289 -0
  111. package/dist/src/types/amount.js.map +1 -0
  112. package/dist/src/types/blob.d.ts +24 -0
  113. package/dist/src/types/blob.js +43 -0
  114. package/dist/src/types/blob.js.map +1 -0
  115. package/dist/src/types/currency.d.ts +28 -0
  116. package/dist/src/types/currency.js +127 -0
  117. package/dist/src/types/currency.js.map +1 -0
  118. package/dist/src/types/hash-128.d.ts +16 -0
  119. package/dist/src/types/hash-128.js +32 -0
  120. package/dist/src/types/hash-128.js.map +1 -0
  121. package/dist/src/types/hash-160.d.ts +10 -0
  122. package/dist/src/types/hash-160.js +19 -0
  123. package/dist/src/types/hash-160.js.map +1 -0
  124. package/dist/src/types/hash-192.d.ts +10 -0
  125. package/dist/src/types/hash-192.js +19 -0
  126. package/dist/src/types/hash-192.js.map +1 -0
  127. package/dist/src/types/hash-256.d.ts +10 -0
  128. package/dist/src/types/hash-256.js +16 -0
  129. package/dist/src/types/hash-256.js.map +1 -0
  130. package/dist/src/types/hash.d.ts +40 -0
  131. package/dist/src/types/hash.js +73 -0
  132. package/dist/src/types/hash.js.map +1 -0
  133. package/dist/src/types/index.d.ts +19 -0
  134. package/dist/src/types/index.js +64 -0
  135. package/dist/src/types/index.js.map +1 -0
  136. package/dist/src/types/issue.d.ts +38 -0
  137. package/dist/src/types/issue.js +81 -0
  138. package/dist/src/types/issue.js.map +1 -0
  139. package/dist/src/types/path-set.d.ts +36 -0
  140. package/dist/src/types/path-set.js +233 -0
  141. package/dist/src/types/path-set.js.map +1 -0
  142. package/dist/src/types/serialized-type.d.ts +70 -0
  143. package/dist/src/types/serialized-type.js +105 -0
  144. package/dist/src/types/serialized-type.js.map +1 -0
  145. package/dist/src/types/st-array.d.ts +31 -0
  146. package/dist/src/types/st-array.js +86 -0
  147. package/dist/src/types/st-array.js.map +1 -0
  148. package/dist/src/types/st-object.d.ts +32 -0
  149. package/dist/src/types/st-object.js +155 -0
  150. package/dist/src/types/st-object.js.map +1 -0
  151. package/dist/src/types/uint-16.d.ts +24 -0
  152. package/dist/src/types/uint-16.js +45 -0
  153. package/dist/src/types/uint-16.js.map +1 -0
  154. package/dist/src/types/uint-32.d.ts +24 -0
  155. package/dist/src/types/uint-32.js +50 -0
  156. package/dist/src/types/uint-32.js.map +1 -0
  157. package/dist/src/types/uint-64.d.ts +37 -0
  158. package/dist/src/types/uint-64.js +86 -0
  159. package/dist/src/types/uint-64.js.map +1 -0
  160. package/dist/src/types/uint-8.d.ts +24 -0
  161. package/dist/src/types/uint-8.js +46 -0
  162. package/dist/src/types/uint-8.js.map +1 -0
  163. package/dist/src/types/uint.d.ts +29 -0
  164. package/dist/src/types/uint.js +47 -0
  165. package/dist/src/types/uint.js.map +1 -0
  166. package/dist/src/types/vector-256.d.ts +30 -0
  167. package/dist/src/types/vector-256.js +73 -0
  168. package/dist/src/types/vector-256.js.map +1 -0
  169. package/dist/src/types/xchain-bridge.d.ts +44 -0
  170. package/dist/src/types/xchain-bridge.js +102 -0
  171. package/dist/src/types/xchain-bridge.js.map +1 -0
  172. package/dist/src/utils.d.ts +47 -0
  173. package/dist/src/utils.js +137 -0
  174. package/dist/src/utils.js.map +1 -0
  175. package/dist/tsconfig.tsbuildinfo +1 -0
  176. package/dist/types/account-id.d.ts +2 -3
  177. package/dist/types/account-id.js +29 -37
  178. package/dist/types/account-id.js.map +1 -1
  179. package/dist/types/amount.d.ts +33 -10
  180. package/dist/types/amount.js +181 -101
  181. package/dist/types/amount.js.map +1 -1
  182. package/dist/types/blob.d.ts +3 -4
  183. package/dist/types/blob.js +16 -27
  184. package/dist/types/blob.js.map +1 -1
  185. package/dist/types/currency.d.ts +5 -13
  186. package/dist/types/currency.js +53 -66
  187. package/dist/types/currency.js.map +1 -1
  188. package/dist/types/hash-128.d.ts +8 -3
  189. package/dist/types/hash-128.js +23 -22
  190. package/dist/types/hash-128.js.map +1 -1
  191. package/dist/types/hash-160.d.ts +2 -3
  192. package/dist/types/hash-160.js +7 -24
  193. package/dist/types/hash-160.js.map +1 -1
  194. package/dist/types/hash-192.d.ts +10 -0
  195. package/dist/types/hash-192.js +19 -0
  196. package/dist/types/hash-192.js.map +1 -0
  197. package/dist/types/hash-256.d.ts +2 -3
  198. package/dist/types/hash-256.js +7 -22
  199. package/dist/types/hash-256.js.map +1 -1
  200. package/dist/types/hash.d.ts +4 -5
  201. package/dist/types/hash.js +25 -39
  202. package/dist/types/hash.js.map +1 -1
  203. package/dist/types/index.d.ts +19 -33
  204. package/dist/types/index.js +44 -24
  205. package/dist/types/index.js.map +1 -1
  206. package/dist/types/issue.d.ts +38 -0
  207. package/dist/types/issue.js +81 -0
  208. package/dist/types/issue.js.map +1 -0
  209. package/dist/types/path-set.d.ts +2 -2
  210. package/dist/types/path-set.js +73 -94
  211. package/dist/types/path-set.js.map +1 -1
  212. package/dist/types/serialized-type.d.ts +26 -18
  213. package/dist/types/serialized-type.js +50 -60
  214. package/dist/types/serialized-type.js.map +1 -1
  215. package/dist/types/st-array.d.ts +7 -4
  216. package/dist/types/st-array.js +36 -47
  217. package/dist/types/st-array.js.map +1 -1
  218. package/dist/types/st-object.d.ts +8 -5
  219. package/dist/types/st-object.js +73 -74
  220. package/dist/types/st-object.js.map +1 -1
  221. package/dist/types/uint-16.d.ts +3 -4
  222. package/dist/types/uint-16.js +20 -33
  223. package/dist/types/uint-16.js.map +1 -1
  224. package/dist/types/uint-32.d.ts +3 -4
  225. package/dist/types/uint-32.js +23 -36
  226. package/dist/types/uint-32.js.map +1 -1
  227. package/dist/types/uint-64.d.ts +5 -6
  228. package/dist/types/uint-64.js +44 -48
  229. package/dist/types/uint-64.js.map +1 -1
  230. package/dist/types/uint-8.d.ts +3 -4
  231. package/dist/types/uint-8.js +21 -33
  232. package/dist/types/uint-8.js.map +1 -1
  233. package/dist/types/uint.d.ts +5 -5
  234. package/dist/types/uint.js +17 -27
  235. package/dist/types/uint.js.map +1 -1
  236. package/dist/types/vector-256.d.ts +3 -4
  237. package/dist/types/vector-256.js +28 -45
  238. package/dist/types/vector-256.js.map +1 -1
  239. package/dist/types/xchain-bridge.d.ts +44 -0
  240. package/dist/types/xchain-bridge.js +102 -0
  241. package/dist/types/xchain-bridge.js.map +1 -0
  242. package/dist/utils.d.ts +47 -0
  243. package/dist/utils.js +137 -0
  244. package/dist/utils.js.map +1 -0
  245. package/package.json +23 -33
  246. package/src/README.md +5 -0
  247. package/src/binary.ts +194 -0
  248. package/src/coretypes.ts +31 -0
  249. package/src/enums/README.md +144 -0
  250. package/src/enums/bytes.ts +74 -0
  251. package/src/enums/constants.ts +4 -0
  252. package/src/enums/definitions.json +3073 -0
  253. package/src/enums/field.ts +84 -0
  254. package/src/enums/index.ts +34 -0
  255. package/src/enums/utils-renumber.ts +134 -0
  256. package/src/enums/xrpl-definitions-base.ts +111 -0
  257. package/src/enums/xrpl-definitions.ts +32 -0
  258. package/src/hash-prefixes.ts +40 -0
  259. package/src/hashes.ts +75 -0
  260. package/src/index.ts +153 -0
  261. package/src/ledger-hashes.ts +191 -0
  262. package/src/quality.ts +38 -0
  263. package/src/serdes/binary-parser.ts +228 -0
  264. package/src/serdes/binary-serializer.ts +166 -0
  265. package/src/shamap.ts +186 -0
  266. package/src/types/account-id.ts +86 -0
  267. package/src/types/amount.ts +362 -0
  268. package/src/types/blob.ts +46 -0
  269. package/src/types/currency.ts +140 -0
  270. package/src/types/hash-128.ts +33 -0
  271. package/src/types/hash-160.ts +19 -0
  272. package/src/types/hash-192.ts +19 -0
  273. package/src/types/hash-256.ts +15 -0
  274. package/src/types/hash.ts +83 -0
  275. package/src/types/index.ts +66 -0
  276. package/src/types/issue.ts +96 -0
  277. package/src/types/path-set.ts +290 -0
  278. package/src/types/serialized-type.ts +122 -0
  279. package/src/types/st-array.ts +113 -0
  280. package/src/types/st-object.ts +192 -0
  281. package/src/types/uint-16.ts +53 -0
  282. package/src/types/uint-32.ts +59 -0
  283. package/src/types/uint-64.ts +104 -0
  284. package/src/types/uint-8.ts +52 -0
  285. package/src/types/uint.ts +60 -0
  286. package/src/types/vector-256.ts +79 -0
  287. package/src/types/xchain-bridge.ts +128 -0
  288. package/src/utils.ts +152 -0
  289. package/HISTORY.md +0 -74
  290. package/test/amount.test.js +0 -43
  291. package/test/binary-json.test.js +0 -47
  292. package/test/binary-parser.test.js +0 -397
  293. package/test/binary-serializer.test.js +0 -248
  294. package/test/fixtures/account-tx-transactions.db +0 -0
  295. package/test/fixtures/codec-fixtures.json +0 -4466
  296. package/test/fixtures/data-driven-tests.json +0 -3721
  297. package/test/fixtures/delivermin-tx-binary.json +0 -1
  298. package/test/fixtures/delivermin-tx.json +0 -98
  299. package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
  300. package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
  301. package/test/fixtures/deposit-preauth-tx.json +0 -58
  302. package/test/fixtures/escrow-cancel-binary.json +0 -1
  303. package/test/fixtures/escrow-cancel-tx.json +0 -6
  304. package/test/fixtures/escrow-create-binary.json +0 -1
  305. package/test/fixtures/escrow-create-tx.json +0 -10
  306. package/test/fixtures/escrow-finish-binary.json +0 -1
  307. package/test/fixtures/escrow-finish-meta-binary.json +0 -1
  308. package/test/fixtures/escrow-finish-tx.json +0 -95
  309. package/test/fixtures/ledger-full-38129.json +0 -1
  310. package/test/fixtures/ledger-full-40000.json +0 -1
  311. package/test/fixtures/negative-unl.json +0 -12
  312. package/test/fixtures/payment-channel-claim-binary.json +0 -1
  313. package/test/fixtures/payment-channel-claim-tx.json +0 -8
  314. package/test/fixtures/payment-channel-create-binary.json +0 -1
  315. package/test/fixtures/payment-channel-create-tx.json +0 -11
  316. package/test/fixtures/payment-channel-fund-binary.json +0 -1
  317. package/test/fixtures/payment-channel-fund-tx.json +0 -7
  318. package/test/fixtures/signerlistset-tx-binary.json +0 -1
  319. package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
  320. package/test/fixtures/signerlistset-tx.json +0 -94
  321. package/test/fixtures/x-codec-fixtures.json +0 -188
  322. package/test/hash.test.js +0 -82
  323. package/test/ledger.test.js +0 -29
  324. package/test/lower-case-hex.test.js +0 -45
  325. package/test/pseudo-transaction.test.js +0 -38
  326. package/test/quality.test.js +0 -15
  327. package/test/shamap.test.js +0 -88
  328. package/test/signing-data-encoding.test.js +0 -129
  329. package/test/tx-encode-decode.test.js +0 -80
  330. package/test/types.test.js +0 -34
  331. package/test/uint.test.js +0 -40
  332. package/test/utils.js +0 -29
  333. package/test/x-address.test.js +0 -147
@@ -1,80 +0,0 @@
1
- const { encode, decode } = require("../dist");
2
-
3
- // Notice: no Amount or Fee
4
- const tx_json = {
5
- Account: "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ",
6
- // Amount: '1000',
7
- Destination: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
8
- // Fee: '10',
9
-
10
- // JavaScript converts operands to 32-bit signed ints after doing bitwise
11
- // operations. We need to convert it back to an unsigned int with >>> 0.
12
- Flags: (1 << 31) >>> 0, // tfFullyCanonicalSig
13
-
14
- Sequence: 1,
15
- TransactionType: "Payment",
16
- // TxnSignature,
17
- // Signature,
18
- // SigningPubKey
19
- };
20
-
21
- describe("encoding and decoding tx_json", function () {
22
- test("can encode tx_json without Amount or Fee", function () {
23
- const encoded = encode(tx_json);
24
- const decoded = decode(encoded);
25
- expect(tx_json).toEqual(decoded);
26
- });
27
- test("can encode tx_json with Amount and Fee", function () {
28
- const my_tx = Object.assign({}, tx_json, {
29
- Amount: "1000",
30
- Fee: "10",
31
- });
32
- const encoded = encode(my_tx);
33
- const decoded = decode(encoded);
34
- expect(my_tx).toEqual(decoded);
35
- });
36
- test("throws when Amount is invalid", function () {
37
- const my_tx = Object.assign({}, tx_json, {
38
- Amount: "1000.001",
39
- Fee: "10",
40
- });
41
- expect(() => {
42
- encode(my_tx);
43
- }).toThrow();
44
- });
45
- test("throws when Fee is invalid", function () {
46
- const my_tx = Object.assign({}, tx_json, {
47
- Amount: "1000",
48
- Fee: "10.123",
49
- });
50
- expect(() => {
51
- encode(my_tx);
52
- }).toThrow();
53
- });
54
- test("throws when Amount and Fee are invalid", function () {
55
- const my_tx = Object.assign({}, tx_json, {
56
- Amount: "1000.789",
57
- Fee: "10.123",
58
- });
59
- expect(() => {
60
- encode(my_tx);
61
- }).toThrow();
62
- });
63
- test("throws when Amount is a number instead of a string-encoded integer", function () {
64
- const my_tx = Object.assign({}, tx_json, {
65
- Amount: 1000.789,
66
- });
67
- expect(() => {
68
- encode(my_tx);
69
- }).toThrow();
70
- });
71
-
72
- test("throws when Fee is a number instead of a string-encoded integer", function () {
73
- const my_tx = Object.assign({}, tx_json, {
74
- Amount: 1234.56,
75
- });
76
- expect(() => {
77
- encode(my_tx);
78
- }).toThrow();
79
- });
80
- });
@@ -1,34 +0,0 @@
1
- const { coreTypes } = require("../dist/types");
2
- const { SerializedType } = require("../dist/types/serialized-type");
3
-
4
- describe("SerializedType interfaces", () => {
5
- Object.entries(coreTypes).forEach(([name, Value]) => {
6
- test(`${name} has a \`from\` static constructor`, () => {
7
- expect(Value.from && Value.from !== Array.from).toBe(true);
8
- });
9
- test(`${name} has a default constructor`, () => {
10
- expect(new Value()).not.toBe(undefined);
11
- });
12
- test(`${name}.from will return the same object`, () => {
13
- const instance = new Value();
14
- expect(Value.from(instance) === instance).toBe(true);
15
- });
16
- test(`${name} instances have toBytesSink`, () => {
17
- expect(new Value().toBytesSink).not.toBe(undefined);
18
- });
19
- test(`${name} instances have toJSON`, () => {
20
- expect(new Value().toJSON).not.toBe(undefined);
21
- });
22
- test(`${name}.from(json).toJSON() == json`, () => {
23
- const newJSON = new Value().toJSON();
24
- expect(Value.from(newJSON).toJSON()).toEqual(newJSON);
25
- });
26
- describe(`${name} supports all methods of the SerializedType mixin`, () => {
27
- Object.keys(SerializedType.prototype).forEach((k) => {
28
- test(`new ${name}.prototype.${k} !== undefined`, () => {
29
- expect(Value.prototype[k]).not.toBe(undefined);
30
- });
31
- });
32
- });
33
- });
34
- });
package/test/uint.test.js DELETED
@@ -1,40 +0,0 @@
1
- const { coreTypes } = require("../dist/types");
2
- const { UInt8, UInt64 } = coreTypes;
3
-
4
- test("compareToTests[0]", () => {
5
- expect(UInt8.from(124).compareTo(UInt64.from(124))).toBe(0);
6
- });
7
-
8
- test("compareToTest[1]", () => {
9
- expect(UInt64.from(124).compareTo(UInt8.from(124))).toBe(0);
10
- });
11
-
12
- test("compareToTest[2]", () => {
13
- expect(UInt64.from(124).compareTo(UInt8.from(123))).toBe(1);
14
- });
15
-
16
- test("compareToTest[3]", () => {
17
- expect(UInt8.from(124).compareTo(UInt8.from(13))).toBe(1);
18
- });
19
-
20
- test("compareToTest[4]", () => {
21
- expect(UInt8.from(124).compareTo(124)).toBe(0);
22
- });
23
-
24
- test("compareToTest[5]", () => {
25
- expect(UInt64.from(124).compareTo(124)).toBe(0);
26
- });
27
-
28
- test("compareToTest[6]", () => {
29
- expect(UInt64.from(124).compareTo(123)).toBe(1);
30
- });
31
-
32
- test("compareToTest[7]", () => {
33
- expect(UInt8.from(124).compareTo(13)).toBe(1);
34
- });
35
-
36
- test("valueOfTests", () => {
37
- let val = UInt8.from(1);
38
- val |= 0x2;
39
- expect(val).toBe(3);
40
- });
package/test/utils.js DELETED
@@ -1,29 +0,0 @@
1
- const fs = require("fs");
2
-
3
- function hexOnly(hex) {
4
- return hex.replace(/[^a-fA-F0-9]/g, "");
5
- }
6
-
7
- function unused() {}
8
-
9
- function parseHexOnly(hex) {
10
- return Buffer.from(hexOnly(hex), "hex");
11
- }
12
-
13
- function loadFixture(relativePath) {
14
- const fn = __dirname + "/fixtures/" + relativePath;
15
- return require(fn);
16
- }
17
-
18
- function loadFixtureText(relativePath) {
19
- const fn = __dirname + "/fixtures/" + relativePath;
20
- return fs.readFileSync(fn).toString("utf8");
21
- }
22
-
23
- module.exports = {
24
- hexOnly,
25
- parseHexOnly,
26
- loadFixture,
27
- loadFixtureText,
28
- unused,
29
- };
@@ -1,147 +0,0 @@
1
- const { encode, decode } = require("./../dist/index");
2
- const fixtures = require("./fixtures/x-codec-fixtures.json");
3
-
4
- let json_x1 = {
5
- OwnerCount: 0,
6
- Account: "XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT",
7
- PreviousTxnLgrSeq: 7,
8
- LedgerEntryType: "AccountRoot",
9
- PreviousTxnID:
10
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
11
- Flags: 0,
12
- Sequence: 1,
13
- Balance: "10000000000",
14
- };
15
-
16
- let json_r1 = {
17
- OwnerCount: 0,
18
- Account: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
19
- PreviousTxnLgrSeq: 7,
20
- LedgerEntryType: "AccountRoot",
21
- PreviousTxnID:
22
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
23
- Flags: 0,
24
- Sequence: 1,
25
- Balance: "10000000000",
26
- SourceTag: 12345,
27
- };
28
-
29
- let json_null_x = {
30
- OwnerCount: 0,
31
- Account: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
32
- Destination: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
33
- Issuer: "XVXdn5wEVm5G4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71",
34
- PreviousTxnLgrSeq: 7,
35
- LedgerEntryType: "AccountRoot",
36
- PreviousTxnID:
37
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
38
- Flags: 0,
39
- Sequence: 1,
40
- Balance: "10000000000",
41
- };
42
-
43
- let json_invalid_x = {
44
- OwnerCount: 0,
45
- Account: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
46
- Destination: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
47
- Issuer: "XVXdn5wEVm5g4UhEHWDPqjvdeH361P4GETfNyyXGaoqBj71",
48
- PreviousTxnLgrSeq: 7,
49
- LedgerEntryType: "AccountRoot",
50
- PreviousTxnID:
51
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
52
- Flags: 0,
53
- Sequence: 1,
54
- Balance: "10000000000",
55
- };
56
-
57
- let json_null_r = {
58
- OwnerCount: 0,
59
- Account: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
60
- Destination: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
61
- Issuer: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
62
- PreviousTxnLgrSeq: 7,
63
- LedgerEntryType: "AccountRoot",
64
- PreviousTxnID:
65
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
66
- Flags: 0,
67
- Sequence: 1,
68
- Balance: "10000000000",
69
- };
70
-
71
- let invalid_json_issuer_tagged = {
72
- OwnerCount: 0,
73
- Account: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
74
- Destination: "rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv",
75
- Issuer: "XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT",
76
- PreviousTxnLgrSeq: 7,
77
- LedgerEntryType: "AccountRoot",
78
- PreviousTxnID:
79
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
80
- Flags: 0,
81
- Sequence: 1,
82
- Balance: "10000000000",
83
- };
84
-
85
- let invalid_json_x_and_tagged = {
86
- OwnerCount: 0,
87
- Account: "XVXdn5wEVm5G4UhEHWDPqjvdeH361P7BsapL4m2D2XnPSwT",
88
- PreviousTxnLgrSeq: 7,
89
- LedgerEntryType: "AccountRoot",
90
- PreviousTxnID:
91
- "DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF",
92
- Flags: 0,
93
- Sequence: 1,
94
- Balance: "10000000000",
95
- SourceTag: 12345,
96
- };
97
-
98
- describe("X-Address Account is equivalent to a classic address w/ SourceTag", () => {
99
- let encoded_x = encode(json_x1);
100
- let encoded_r = encode(json_r1);
101
- test("Can encode with x-Address", () => {
102
- expect(encoded_x).toEqual(encoded_r);
103
- });
104
-
105
- test("decoded X-address is object w/ source and tag", () => {
106
- let decoded_x = decode(encoded_x);
107
- expect(decoded_x).toEqual(json_r1);
108
- });
109
-
110
- test("Encoding issuer X-Address w/ undefined destination tag", () => {
111
- expect(encode(json_null_x)).toEqual(encode(json_null_r));
112
- });
113
-
114
- test("Throws when X-Address is invalid", () => {
115
- expect(() => encode(json_invalid_x)).toThrow("checksum_invalid");
116
- });
117
- });
118
-
119
- describe("Invalid X-Address behavior", () => {
120
- test("X-Address with tag throws value for invalid field", () => {
121
- expect(() => encode(invalid_json_issuer_tagged)).toThrow(
122
- new Error("Issuer cannot have an associated tag")
123
- );
124
- });
125
-
126
- test("Throws when Account has both X-Addr and Destination Tag", () => {
127
- expect(() => encode(invalid_json_x_and_tagged)).toThrow(
128
- new Error("Cannot have Account X-Address and SourceTag")
129
- );
130
- });
131
- });
132
-
133
- describe("ripple-binary-codec x-address test", function () {
134
- function makeSuite(name, entries) {
135
- describe(name, function () {
136
- entries.forEach((t, testN) => {
137
- test(`${name}[${testN}] encodes X-address json equivalent to classic address json`, () => {
138
- expect(encode(t.rjson)).toEqual(encode(t.xjson));
139
- });
140
- test(`${name}[${testN}] decodes X-address json equivalent to classic address json`, () => {
141
- expect(decode(encode(t.xjson))).toEqual(t.rjson);
142
- });
143
- });
144
- });
145
- }
146
- makeSuite("transactions", fixtures.transactions);
147
- });