ripple-binary-codec 0.2.7 → 1.0.0-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 (364) hide show
  1. package/README.md +104 -2
  2. package/dist/binary.d.ts +90 -0
  3. package/dist/binary.js +128 -0
  4. package/dist/binary.js.map +1 -0
  5. package/dist/coretypes.d.ts +9 -0
  6. package/dist/coretypes.js +48 -0
  7. package/dist/coretypes.js.map +1 -0
  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 +2956 -0
  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 -0
  19. package/dist/enums/index.js +31 -0
  20. package/dist/enums/index.js.map +1 -0
  21. package/{distrib/npm → dist/enums/src}/enums/definitions.json +1709 -438
  22. package/dist/enums/utils-renumber.d.ts +101 -0
  23. package/dist/enums/utils-renumber.js +127 -0
  24. package/dist/enums/utils-renumber.js.map +1 -0
  25. package/dist/enums/xrpl-definitions-base.d.ts +44 -0
  26. package/dist/enums/xrpl-definitions-base.js +59 -0
  27. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  28. package/dist/enums/xrpl-definitions.d.ts +21 -0
  29. package/dist/enums/xrpl-definitions.js +29 -0
  30. package/dist/enums/xrpl-definitions.js.map +1 -0
  31. package/dist/hash-prefixes.d.ts +5 -0
  32. package/dist/hash-prefixes.js +41 -0
  33. package/dist/hash-prefixes.js.map +1 -0
  34. package/dist/hashes.d.ts +50 -0
  35. package/dist/hashes.js +76 -0
  36. package/dist/hashes.js.map +1 -0
  37. package/dist/index.d.ts +64 -0
  38. package/dist/index.js +123 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/ledger-hashes.d.ts +48 -0
  41. package/dist/ledger-hashes.js +141 -0
  42. package/dist/ledger-hashes.js.map +1 -0
  43. package/dist/quality.d.ts +21 -0
  44. package/dist/quality.js +42 -0
  45. package/dist/quality.js.map +1 -0
  46. package/dist/serdes/binary-parser.d.ts +100 -0
  47. package/dist/serdes/binary-parser.js +194 -0
  48. package/dist/serdes/binary-parser.js.map +1 -0
  49. package/dist/serdes/binary-serializer.d.ts +81 -0
  50. package/dist/serdes/binary-serializer.js +149 -0
  51. package/dist/serdes/binary-serializer.js.map +1 -0
  52. package/dist/shamap.d.ts +102 -0
  53. package/dist/shamap.js +172 -0
  54. package/dist/shamap.js.map +1 -0
  55. package/dist/src/binary.d.ts +90 -0
  56. package/dist/src/binary.js +128 -0
  57. package/dist/src/binary.js.map +1 -0
  58. package/dist/src/coretypes.d.ts +9 -0
  59. package/dist/src/coretypes.js +48 -0
  60. package/dist/src/coretypes.js.map +1 -0
  61. package/dist/src/enums/bytes.d.ts +25 -0
  62. package/dist/src/enums/bytes.js +63 -0
  63. package/dist/src/enums/bytes.js.map +1 -0
  64. package/dist/src/enums/constants.d.ts +4 -0
  65. package/dist/src/enums/constants.js +8 -0
  66. package/dist/src/enums/constants.js.map +1 -0
  67. package/dist/src/enums/definitions.json +2956 -0
  68. package/dist/src/enums/field.d.ts +28 -0
  69. package/dist/src/enums/field.js +58 -0
  70. package/dist/src/enums/field.js.map +1 -0
  71. package/dist/src/enums/index.d.ts +12 -0
  72. package/dist/src/enums/index.js +31 -0
  73. package/dist/src/enums/index.js.map +1 -0
  74. package/dist/src/enums/utils-renumber.d.ts +101 -0
  75. package/dist/src/enums/utils-renumber.js +127 -0
  76. package/dist/src/enums/utils-renumber.js.map +1 -0
  77. package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
  78. package/dist/src/enums/xrpl-definitions-base.js +59 -0
  79. package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
  80. package/dist/src/enums/xrpl-definitions.d.ts +21 -0
  81. package/dist/src/enums/xrpl-definitions.js +29 -0
  82. package/dist/src/enums/xrpl-definitions.js.map +1 -0
  83. package/dist/src/hash-prefixes.d.ts +5 -0
  84. package/dist/src/hash-prefixes.js +41 -0
  85. package/dist/src/hash-prefixes.js.map +1 -0
  86. package/dist/src/hashes.d.ts +50 -0
  87. package/dist/src/hashes.js +76 -0
  88. package/dist/src/hashes.js.map +1 -0
  89. package/dist/src/index.d.ts +64 -0
  90. package/dist/src/index.js +123 -0
  91. package/dist/src/index.js.map +1 -0
  92. package/dist/src/ledger-hashes.d.ts +48 -0
  93. package/dist/src/ledger-hashes.js +141 -0
  94. package/dist/src/ledger-hashes.js.map +1 -0
  95. package/dist/src/quality.d.ts +21 -0
  96. package/dist/src/quality.js +42 -0
  97. package/dist/src/quality.js.map +1 -0
  98. package/dist/src/serdes/binary-parser.d.ts +100 -0
  99. package/dist/src/serdes/binary-parser.js +194 -0
  100. package/dist/src/serdes/binary-parser.js.map +1 -0
  101. package/dist/src/serdes/binary-serializer.d.ts +81 -0
  102. package/dist/src/serdes/binary-serializer.js +149 -0
  103. package/dist/src/serdes/binary-serializer.js.map +1 -0
  104. package/dist/src/shamap.d.ts +102 -0
  105. package/dist/src/shamap.js +172 -0
  106. package/dist/src/shamap.js.map +1 -0
  107. package/dist/src/types/account-id.d.ts +35 -0
  108. package/dist/src/types/account-id.js +69 -0
  109. package/dist/src/types/account-id.js.map +1 -0
  110. package/dist/src/types/amount.d.ts +91 -0
  111. package/dist/src/types/amount.js +289 -0
  112. package/dist/src/types/amount.js.map +1 -0
  113. package/dist/src/types/blob.d.ts +24 -0
  114. package/dist/src/types/blob.js +40 -0
  115. package/dist/src/types/blob.js.map +1 -0
  116. package/dist/src/types/currency.d.ts +28 -0
  117. package/dist/src/types/currency.js +127 -0
  118. package/dist/src/types/currency.js.map +1 -0
  119. package/dist/src/types/hash-128.d.ts +16 -0
  120. package/dist/src/types/hash-128.js +32 -0
  121. package/dist/src/types/hash-128.js.map +1 -0
  122. package/dist/src/types/hash-160.d.ts +10 -0
  123. package/dist/src/types/hash-160.js +19 -0
  124. package/dist/src/types/hash-160.js.map +1 -0
  125. package/dist/src/types/hash-192.d.ts +10 -0
  126. package/dist/src/types/hash-192.js +19 -0
  127. package/dist/src/types/hash-192.js.map +1 -0
  128. package/dist/src/types/hash-256.d.ts +10 -0
  129. package/dist/src/types/hash-256.js +16 -0
  130. package/dist/src/types/hash-256.js.map +1 -0
  131. package/dist/src/types/hash.d.ts +40 -0
  132. package/dist/src/types/hash.js +73 -0
  133. package/dist/src/types/hash.js.map +1 -0
  134. package/dist/src/types/index.d.ts +19 -0
  135. package/dist/src/types/index.js +64 -0
  136. package/dist/src/types/index.js.map +1 -0
  137. package/dist/src/types/issue.d.ts +38 -0
  138. package/dist/src/types/issue.js +81 -0
  139. package/dist/src/types/issue.js.map +1 -0
  140. package/dist/src/types/path-set.d.ts +36 -0
  141. package/dist/src/types/path-set.js +233 -0
  142. package/dist/src/types/path-set.js.map +1 -0
  143. package/dist/src/types/serialized-type.d.ts +70 -0
  144. package/dist/src/types/serialized-type.js +105 -0
  145. package/dist/src/types/serialized-type.js.map +1 -0
  146. package/dist/src/types/st-array.d.ts +31 -0
  147. package/dist/src/types/st-array.js +83 -0
  148. package/dist/src/types/st-array.js.map +1 -0
  149. package/dist/src/types/st-object.d.ts +32 -0
  150. package/dist/src/types/st-object.js +155 -0
  151. package/dist/src/types/st-object.js.map +1 -0
  152. package/dist/src/types/uint-16.d.ts +24 -0
  153. package/dist/src/types/uint-16.js +45 -0
  154. package/dist/src/types/uint-16.js.map +1 -0
  155. package/dist/src/types/uint-32.d.ts +24 -0
  156. package/dist/src/types/uint-32.js +50 -0
  157. package/dist/src/types/uint-32.js.map +1 -0
  158. package/dist/src/types/uint-64.d.ts +37 -0
  159. package/dist/src/types/uint-64.js +86 -0
  160. package/dist/src/types/uint-64.js.map +1 -0
  161. package/dist/src/types/uint-8.d.ts +24 -0
  162. package/dist/src/types/uint-8.js +46 -0
  163. package/dist/src/types/uint-8.js.map +1 -0
  164. package/dist/src/types/uint.d.ts +29 -0
  165. package/dist/src/types/uint.js +47 -0
  166. package/dist/src/types/uint.js.map +1 -0
  167. package/dist/src/types/vector-256.d.ts +30 -0
  168. package/dist/src/types/vector-256.js +73 -0
  169. package/dist/src/types/vector-256.js.map +1 -0
  170. package/dist/src/types/xchain-bridge.d.ts +44 -0
  171. package/dist/src/types/xchain-bridge.js +102 -0
  172. package/dist/src/types/xchain-bridge.js.map +1 -0
  173. package/dist/src/utils.d.ts +47 -0
  174. package/dist/src/utils.js +137 -0
  175. package/dist/src/utils.js.map +1 -0
  176. package/dist/tsconfig.tsbuildinfo +1 -0
  177. package/dist/types/account-id.d.ts +35 -0
  178. package/dist/types/account-id.js +69 -0
  179. package/dist/types/account-id.js.map +1 -0
  180. package/dist/types/amount.d.ts +91 -0
  181. package/dist/types/amount.js +289 -0
  182. package/dist/types/amount.js.map +1 -0
  183. package/dist/types/blob.d.ts +24 -0
  184. package/dist/types/blob.js +40 -0
  185. package/dist/types/blob.js.map +1 -0
  186. package/dist/types/currency.d.ts +28 -0
  187. package/dist/types/currency.js +127 -0
  188. package/dist/types/currency.js.map +1 -0
  189. package/dist/types/hash-128.d.ts +16 -0
  190. package/dist/types/hash-128.js +32 -0
  191. package/dist/types/hash-128.js.map +1 -0
  192. package/dist/types/hash-160.d.ts +10 -0
  193. package/dist/types/hash-160.js +19 -0
  194. package/dist/types/hash-160.js.map +1 -0
  195. package/dist/types/hash-192.d.ts +10 -0
  196. package/dist/types/hash-192.js +19 -0
  197. package/dist/types/hash-192.js.map +1 -0
  198. package/dist/types/hash-256.d.ts +10 -0
  199. package/dist/types/hash-256.js +16 -0
  200. package/dist/types/hash-256.js.map +1 -0
  201. package/dist/types/hash.d.ts +40 -0
  202. package/dist/types/hash.js +73 -0
  203. package/dist/types/hash.js.map +1 -0
  204. package/dist/types/index.d.ts +19 -0
  205. package/dist/types/index.js +64 -0
  206. package/dist/types/index.js.map +1 -0
  207. package/dist/types/issue.d.ts +38 -0
  208. package/dist/types/issue.js +81 -0
  209. package/dist/types/issue.js.map +1 -0
  210. package/dist/types/path-set.d.ts +36 -0
  211. package/dist/types/path-set.js +233 -0
  212. package/dist/types/path-set.js.map +1 -0
  213. package/dist/types/serialized-type.d.ts +70 -0
  214. package/dist/types/serialized-type.js +105 -0
  215. package/dist/types/serialized-type.js.map +1 -0
  216. package/dist/types/st-array.d.ts +31 -0
  217. package/dist/types/st-array.js +83 -0
  218. package/dist/types/st-array.js.map +1 -0
  219. package/dist/types/st-object.d.ts +32 -0
  220. package/dist/types/st-object.js +155 -0
  221. package/dist/types/st-object.js.map +1 -0
  222. package/dist/types/uint-16.d.ts +24 -0
  223. package/dist/types/uint-16.js +45 -0
  224. package/dist/types/uint-16.js.map +1 -0
  225. package/dist/types/uint-32.d.ts +24 -0
  226. package/dist/types/uint-32.js +50 -0
  227. package/dist/types/uint-32.js.map +1 -0
  228. package/dist/types/uint-64.d.ts +37 -0
  229. package/dist/types/uint-64.js +86 -0
  230. package/dist/types/uint-64.js.map +1 -0
  231. package/dist/types/uint-8.d.ts +24 -0
  232. package/dist/types/uint-8.js +46 -0
  233. package/dist/types/uint-8.js.map +1 -0
  234. package/dist/types/uint.d.ts +29 -0
  235. package/dist/types/uint.js +47 -0
  236. package/dist/types/uint.js.map +1 -0
  237. package/dist/types/vector-256.d.ts +30 -0
  238. package/dist/types/vector-256.js +73 -0
  239. package/dist/types/vector-256.js.map +1 -0
  240. package/dist/types/xchain-bridge.d.ts +44 -0
  241. package/dist/types/xchain-bridge.js +102 -0
  242. package/dist/types/xchain-bridge.js.map +1 -0
  243. package/dist/utils.d.ts +47 -0
  244. package/dist/utils.js +137 -0
  245. package/dist/utils.js.map +1 -0
  246. package/package.json +28 -33
  247. package/src/README.md +5 -0
  248. package/src/binary.ts +194 -0
  249. package/src/coretypes.ts +31 -0
  250. package/src/enums/README.md +144 -0
  251. package/src/enums/bytes.ts +74 -0
  252. package/src/enums/constants.ts +4 -0
  253. package/src/enums/definitions.json +2961 -0
  254. package/src/enums/field.ts +84 -0
  255. package/src/enums/index.ts +34 -0
  256. package/src/enums/utils-renumber.ts +134 -0
  257. package/src/enums/xrpl-definitions-base.ts +111 -0
  258. package/src/enums/xrpl-definitions.ts +32 -0
  259. package/src/hash-prefixes.ts +40 -0
  260. package/src/hashes.ts +75 -0
  261. package/src/index.ts +153 -0
  262. package/src/ledger-hashes.ts +191 -0
  263. package/src/quality.ts +38 -0
  264. package/src/serdes/binary-parser.ts +224 -0
  265. package/src/serdes/binary-serializer.ts +166 -0
  266. package/src/shamap.ts +186 -0
  267. package/src/types/account-id.ts +86 -0
  268. package/src/types/amount.ts +362 -0
  269. package/src/types/blob.ts +43 -0
  270. package/src/types/currency.ts +140 -0
  271. package/src/types/hash-128.ts +33 -0
  272. package/src/types/hash-160.ts +19 -0
  273. package/src/types/hash-192.ts +19 -0
  274. package/src/types/hash-256.ts +15 -0
  275. package/src/types/hash.ts +83 -0
  276. package/src/types/index.ts +66 -0
  277. package/src/types/issue.ts +96 -0
  278. package/src/types/path-set.ts +290 -0
  279. package/src/types/serialized-type.ts +122 -0
  280. package/src/types/st-array.ts +107 -0
  281. package/src/types/st-object.ts +192 -0
  282. package/src/types/uint-16.ts +53 -0
  283. package/src/types/uint-32.ts +59 -0
  284. package/src/types/uint-64.ts +104 -0
  285. package/src/types/uint-8.ts +52 -0
  286. package/src/types/uint.ts +60 -0
  287. package/src/types/vector-256.ts +79 -0
  288. package/src/types/xchain-bridge.ts +128 -0
  289. package/src/utils.ts +152 -0
  290. package/HISTORY.md +0 -66
  291. package/distrib/npm/binary.js +0 -68
  292. package/distrib/npm/coretypes.js +0 -22
  293. package/distrib/npm/enums/index.js +0 -125
  294. package/distrib/npm/enums/utils-renumber.js +0 -134
  295. package/distrib/npm/hash-prefixes.js +0 -30
  296. package/distrib/npm/hashes.js +0 -42
  297. package/distrib/npm/index.js +0 -72
  298. package/distrib/npm/ledger-hashes.js +0 -71
  299. package/distrib/npm/quality.js +0 -20
  300. package/distrib/npm/serdes/binary-parser.js +0 -98
  301. package/distrib/npm/serdes/binary-serializer.js +0 -106
  302. package/distrib/npm/shamap.js +0 -107
  303. package/distrib/npm/types/account-id.js +0 -41
  304. package/distrib/npm/types/amount.js +0 -215
  305. package/distrib/npm/types/blob.js +0 -28
  306. package/distrib/npm/types/currency.js +0 -91
  307. package/distrib/npm/types/hash-128.js +0 -10
  308. package/distrib/npm/types/hash-160.js +0 -10
  309. package/distrib/npm/types/hash-256.js +0 -15
  310. package/distrib/npm/types/hash.js +0 -45
  311. package/distrib/npm/types/index.js +0 -45
  312. package/distrib/npm/types/path-set.js +0 -112
  313. package/distrib/npm/types/serialized-type.js +0 -63
  314. package/distrib/npm/types/st-array.js +0 -37
  315. package/distrib/npm/types/st-object.js +0 -65
  316. package/distrib/npm/types/uint-16.js +0 -10
  317. package/distrib/npm/types/uint-32.js +0 -10
  318. package/distrib/npm/types/uint-64.js +0 -49
  319. package/distrib/npm/types/uint-8.js +0 -10
  320. package/distrib/npm/types/uint.js +0 -60
  321. package/distrib/npm/types/vector-256.js +0 -31
  322. package/distrib/npm/utils/bytes-utils.js +0 -112
  323. package/distrib/npm/utils/make-class.js +0 -83
  324. package/test/amount-test.js +0 -43
  325. package/test/binary-json-test.js +0 -43
  326. package/test/binary-parser-test.js +0 -341
  327. package/test/binary-serializer-test.js +0 -194
  328. package/test/bytes-utils-test.js +0 -72
  329. package/test/fixtures/account-tx-transactions.db +0 -0
  330. package/test/fixtures/codec-fixtures.json +0 -4466
  331. package/test/fixtures/data-driven-tests.json +0 -3721
  332. package/test/fixtures/delivermin-tx-binary.json +0 -1
  333. package/test/fixtures/delivermin-tx.json +0 -98
  334. package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
  335. package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
  336. package/test/fixtures/deposit-preauth-tx.json +0 -58
  337. package/test/fixtures/escrow-cancel-binary.json +0 -1
  338. package/test/fixtures/escrow-cancel-tx.json +0 -6
  339. package/test/fixtures/escrow-create-binary.json +0 -1
  340. package/test/fixtures/escrow-create-tx.json +0 -10
  341. package/test/fixtures/escrow-finish-binary.json +0 -1
  342. package/test/fixtures/escrow-finish-meta-binary.json +0 -1
  343. package/test/fixtures/escrow-finish-tx.json +0 -95
  344. package/test/fixtures/ledger-full-38129.json +0 -1
  345. package/test/fixtures/ledger-full-40000.json +0 -1
  346. package/test/fixtures/payment-channel-claim-binary.json +0 -1
  347. package/test/fixtures/payment-channel-claim-tx.json +0 -8
  348. package/test/fixtures/payment-channel-create-binary.json +0 -1
  349. package/test/fixtures/payment-channel-create-tx.json +0 -11
  350. package/test/fixtures/payment-channel-fund-binary.json +0 -1
  351. package/test/fixtures/payment-channel-fund-tx.json +0 -7
  352. package/test/fixtures/signerlistset-tx-binary.json +0 -1
  353. package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
  354. package/test/fixtures/signerlistset-tx.json +0 -94
  355. package/test/hash-test.js +0 -58
  356. package/test/ledger-test.js +0 -26
  357. package/test/mocha.opts +0 -1
  358. package/test/quality-test.js +0 -16
  359. package/test/shamap-test.js +0 -88
  360. package/test/signing-data-encoding-test.js +0 -120
  361. package/test/tx-encode-decode-test.js +0 -124
  362. package/test/types-test.js +0 -38
  363. package/test/uint-test.js +0 -38
  364. package/test/utils.js +0 -93
@@ -1,83 +0,0 @@
1
- 'use strict';var _ = require('lodash');
2
- var inherits = require('inherits');
3
-
4
- function forEach(obj, func) {
5
- Object.keys(obj || {}).forEach(function (k) {
6
- func(obj[k], k);
7
- });
8
- }
9
-
10
- function ensureArray(val) {
11
- return Array.isArray(val) ? val : [val];
12
- }
13
-
14
- module.exports = function makeClass(klass_, definition_) {
15
- var definition = definition_ || klass_;
16
- var klass = typeof klass_ === 'function' ? klass_ : null;
17
- if (klass === null) {
18
- for (var k in definition) {
19
- if (k[0].match(/[A-Z]/)) {
20
- klass = definition[k];
21
- break;
22
- }
23
- }
24
- }
25
- var parent = definition.inherits;
26
- if (parent) {
27
- if (klass === null) {
28
- klass = function klass() {
29
- parent.apply(this, arguments);
30
- };
31
- }
32
- inherits(klass, parent);
33
- _.defaults(klass, parent);
34
- }
35
- if (klass === null) {
36
- klass = function klass() {};
37
- }
38
- var proto = klass.prototype;
39
- function addFunc(original, name, wrapper) {
40
- proto[name] = wrapper || original;
41
- }
42
- (definition.getters || []).forEach(function (k) {
43
- var key = '_' + k;
44
- proto[k] = function () {
45
- return this[key];
46
- };
47
- });
48
- forEach(definition.virtuals, function (f, n) {
49
- addFunc(f, n, function () {
50
- throw new Error('unimplemented');
51
- });
52
- });
53
- forEach(definition.methods, addFunc);
54
- forEach(definition, function (f, n) {
55
- if (_.isFunction(f) && f !== klass) {
56
- addFunc(f, n);
57
- }
58
- });
59
- _.assign(klass, definition.statics);
60
- if (typeof klass.init === 'function') {
61
- klass.init();
62
- }
63
- forEach(definition.cached, function (f, n) {
64
- var key = '_' + n;
65
- addFunc(f, n, function () {
66
- var value = this[key];
67
- if (value === undefined) {
68
- value = this[key] = f.call(this);
69
- }
70
- return value;
71
- });
72
- });
73
- if (definition.mixins) {
74
- var mixins = {};
75
- // Right-most in the list win
76
- ensureArray(definition.mixins).reverse().forEach(function (o) {
77
- _.defaults(mixins, o);
78
- });
79
- _.defaults(proto, mixins);
80
- }
81
-
82
- return klass;
83
- };
@@ -1,43 +0,0 @@
1
- const _ = require('lodash');
2
- const assert = require('assert');
3
- const utils = require('./utils');
4
- const {Amount} = require('../src/coretypes');
5
- const {loadFixture} = utils;
6
- const fixtures = loadFixture('data-driven-tests.json');
7
-
8
- function amountErrorTests() {
9
- _.filter(fixtures.values_tests, {type: 'Amount'}).forEach(f => {
10
- // We only want these with errors
11
- if (!f.error) {
12
- return
13
- }
14
- const testName = `${JSON.stringify(f.test_json)}\n\tis invalid ` +
15
- `because: ${f.error}`
16
- it(testName, () => {
17
- assert.throws(() => {
18
- Amount.from(f.test_json);
19
- }, JSON.stringify(f.test_json));
20
- });
21
- });
22
- }
23
-
24
- describe('Amount', function() {
25
- it('can be parsed from', function() {
26
- assert(Amount.from('1000000') instanceof Amount);
27
- assert.equal(Amount.from('1000000').valueString(), '1000000');
28
- const fixture = {
29
- 'value': '1',
30
- 'issuer': '0000000000000000000000000000000000000000',
31
- 'currency': 'USD'
32
- };
33
- const amt = Amount.from(fixture);
34
- const rewritten = {
35
- 'value': '1',
36
- 'issuer': 'rrrrrrrrrrrrrrrrrrrrrhoLvTp',
37
- 'currency': 'USD'
38
- };
39
- assert.deepEqual(amt.toJSON(), rewritten);
40
- });
41
- amountErrorTests()
42
- });
43
-
@@ -1,43 +0,0 @@
1
- const assert = require('assert');
2
- const fixtures = require('./fixtures/codec-fixtures.json');
3
- const {decode, encode, decodeLedgerData} = require('../src');
4
-
5
- function json(object) {
6
- return JSON.stringify(object);
7
- }
8
-
9
- function truncateForDisplay(longStr) {
10
- return longStr.slice(0, 10) + '...' + longStr.slice(-10);
11
- }
12
-
13
- describe('ripple-binary-codec', function() {
14
- function makeSuite(name, entries) {
15
- describe(name, function() {
16
- entries.forEach((t, test_n) => {
17
- // eslint-disable-next-line max-len
18
- it(`${name}[${test_n}] can encode ${truncateForDisplay(json(t.json))} to ${truncateForDisplay(t.binary)}`,
19
- () => {
20
- assert.equal(t.binary, encode(t.json));
21
- });
22
- // eslint-disable-next-line max-len
23
- it(`${name}[${test_n}] can decode ${truncateForDisplay(t.binary)} to ${truncateForDisplay(json(t.json))}`,
24
- () => {
25
- const decoded = decode(t.binary);
26
- assert.deepEqual(t.json, decoded);
27
- });
28
- });
29
- });
30
- }
31
- makeSuite('transactions', fixtures.transactions);
32
- makeSuite('accountState', fixtures.accountState);
33
-
34
- describe('ledgerData', function() {
35
- fixtures.ledgerData.forEach((t, test_n) => {
36
- it(`ledgerData[${test_n}] can decode ${t.binary} to ${json(t.json)}`,
37
- () => {
38
- const decoded = decodeLedgerData(t.binary);
39
- assert.deepEqual(t.json, decoded);
40
- });
41
- });
42
- })
43
- });
@@ -1,341 +0,0 @@
1
- /* eslint-disable func-style */
2
-
3
- const coreTypes = require('../src/coretypes');
4
-
5
- const _ = require('lodash');
6
- const assert = require('assert');
7
- const {encodeAccountID} = require('ripple-address-codec');
8
- const {binary: {makeParser, readJSON}, Field, Amount, Hash160} = coreTypes;
9
- const {enums: {TransactionType}} = coreTypes;
10
- const utils = require('./utils');
11
- const {parseHexOnly, assertEqualAmountJSON, hexOnly, loadFixture} = utils;
12
- const {bytesToHex} = require('../src/utils/bytes-utils');
13
- const fixtures = loadFixture('data-driven-tests.json');
14
- const {BytesList} = require('../src/serdes/binary-serializer');
15
-
16
- const __ = hexOnly;
17
- function unused() {}
18
- function toJSON(v) {
19
- return v.toJSON ? v.toJSON() : v;
20
- }
21
-
22
- function basicApiTests() {
23
- const bytes = parseHexOnly('00,01020304,0506', Uint8Array);
24
- it('can read slices of bytes', () => {
25
- const parser = makeParser(bytes);
26
- assert.deepEqual(parser.pos(), 0);
27
- assert(parser._buf instanceof Uint8Array);
28
- const read1 = parser.read(1);
29
- assert(read1 instanceof Uint8Array);
30
- assert.deepEqual(read1, Uint8Array.from([0]));
31
- assert.deepEqual(parser.read(4), Uint8Array.from([1, 2, 3, 4]));
32
- assert.deepEqual(parser.read(2), Uint8Array.from([5, 6]));
33
- assert.throws(() => parser.read(1));
34
- });
35
- it('can read a Uint32 at full', () => {
36
- const parser = makeParser('FFFFFFFF');
37
- assert.equal(parser.readUInt32(), 0xFFFFFFFF);
38
- });
39
- }
40
-
41
- function transactionParsingTests() {
42
- const transaction = {
43
- json: {
44
- 'Account': 'raD5qJMAShLeHZXf9wjUmo6vRK4arj9cF3',
45
- 'Fee': '10',
46
- 'Flags': 0,
47
- 'Sequence': 103929,
48
- 'SigningPubKey':
49
- '028472865AF4CB32AA285834B57576B7290AA8C31B459047DB27E16F418D6A7166',
50
- 'TakerGets': {'currency': 'ILS',
51
- 'issuer': 'rNPRNzBB92BVpAhhZr4iXDTveCgV5Pofm9',
52
- 'value': '1694.768'},
53
- 'TakerPays': '98957503520',
54
- 'TransactionType': 'OfferCreate',
55
- 'TxnSignature': __(`
56
- 304502202ABE08D5E78D1E74A4C18F2714F64E87B8BD57444AF
57
- A5733109EB3C077077520022100DB335EE97386E4C0591CAC02
58
- 4D50E9230D8F171EEB901B5E5E4BD6D1E0AEF98C`)
59
- },
60
- binary: __(`
61
- 120007220000000024000195F964400000170A53AC2065D5460561E
62
- C9DE000000000000000000000000000494C53000000000092D70596
63
- 8936C419CE614BF264B5EEB1CEA47FF468400000000000000A73210
64
- 28472865AF4CB32AA285834B57576B7290AA8C31B459047DB27E16F
65
- 418D6A71667447304502202ABE08D5E78D1E74A4C18F2714F64E87B
66
- 8BD57444AFA5733109EB3C077077520022100DB335EE97386E4C059
67
- 1CAC024D50E9230D8F171EEB901B5E5E4BD6D1E0AEF98C811439408
68
- A69F0895E62149CFCC006FB89FA7D1E6E5D`)
69
- };
70
-
71
- const tx_json = transaction.json;
72
- // These tests are basically development logs
73
-
74
- it('can be done with low level apis', () => {
75
- const parser = makeParser(transaction.binary);
76
-
77
- assert.equal(parser.readField(), Field.TransactionType);
78
- assert.equal(parser.readUInt16(), 7);
79
- assert.equal(parser.readField(), Field.Flags);
80
- assert.equal(parser.readUInt32(), 0);
81
- assert.equal(parser.readField(), Field.Sequence);
82
- assert.equal(parser.readUInt32(), 103929);
83
- assert.equal(parser.readField(), Field.TakerPays);
84
- parser.read(8);
85
- assert.equal(parser.readField(), Field.TakerGets);
86
- // amount value
87
- assert(parser.read(8));
88
- // amount currency
89
- assert(Hash160.fromParser(parser));
90
- assert.equal(encodeAccountID(parser.read(20)),
91
- tx_json.TakerGets.issuer);
92
- assert.equal(parser.readField(), Field.Fee);
93
- assert(parser.read(8));
94
- assert.equal(parser.readField(), Field.SigningPubKey);
95
- assert.equal(parser.readVLLength(), 33);
96
- assert.equal(bytesToHex(parser.read(33)), tx_json.SigningPubKey);
97
- assert.equal(parser.readField(), Field.TxnSignature);
98
- assert.equal(bytesToHex(parser.readVL()), tx_json.TxnSignature);
99
- assert.equal(parser.readField(), Field.Account);
100
- assert.equal(encodeAccountID(parser.readVL()), tx_json.Account);
101
- assert(parser.end());
102
- });
103
-
104
- it('can be done with high level apis', () => {
105
- const parser = makeParser(transaction.binary);
106
- function readField() {
107
- return parser.readFieldAndValue();
108
- }
109
- {
110
- const [field, value] = readField();
111
- assert.equal(field, Field.TransactionType);
112
- assert.equal(value, TransactionType.OfferCreate);
113
- }
114
- {
115
- const [field, value] = readField();
116
- assert.equal(field, Field.Flags);
117
- assert.equal(value, 0);
118
- }
119
- {
120
- const [field, value] = readField();
121
- assert.equal(field, Field.Sequence);
122
- assert.equal(value, 103929);
123
- }
124
- {
125
- const [field, value] = readField();
126
- assert.equal(field, Field.TakerPays);
127
- assert.equal(value.currency.isNative(), true);
128
- assert.equal(value.currency.toJSON(), 'XRP');
129
- }
130
- {
131
- const [field, value] = readField();
132
- assert.equal(field, Field.TakerGets);
133
- assert.equal(value.currency.isNative(), false);
134
- assert.equal(value.issuer.toJSON(), tx_json.TakerGets.issuer);
135
- }
136
- {
137
- const [field, value] = readField();
138
- assert.equal(field, Field.Fee);
139
- assert.equal(value.currency.isNative(), true);
140
- }
141
- {
142
- const [field, value] = readField();
143
- assert.equal(field, Field.SigningPubKey);
144
- assert.equal(value.toJSON(), tx_json.SigningPubKey);
145
- }
146
- {
147
- const [field, value] = readField();
148
- assert.equal(field, Field.TxnSignature);
149
- assert.equal(value.toJSON(), tx_json.TxnSignature);
150
- }
151
- {
152
- const [field, value] = readField();
153
- assert.equal(field, Field.Account);
154
- assert.equal(value.toJSON(), tx_json.Account);
155
- }
156
- assert(parser.end());
157
- });
158
-
159
- it('can be done with higher level apis', () => {
160
- const parser = makeParser(transaction.binary);
161
- const jsonFromBinary = readJSON(parser);
162
- assert.deepEqual(jsonFromBinary, tx_json);
163
- });
164
-
165
- it('readJSON (binary.decode) does not return STObject ', () => {
166
- const parser = makeParser(transaction.binary);
167
- const jsonFromBinary = readJSON(parser);
168
- assert((jsonFromBinary instanceof coreTypes.STObject) === false);
169
- assert(_.isPlainObject(jsonFromBinary));
170
- });
171
- }
172
-
173
- function amountParsingTests() {
174
- _.filter(fixtures.values_tests, {type: 'Amount'}).forEach((f, i) => {
175
- if (f.error) {
176
- return;
177
- }
178
- const parser = makeParser(f.expected_hex);
179
- const testName =
180
- `values_tests[${i}] parses ${f.expected_hex.slice(0, 16)}...
181
- as ${JSON.stringify(f.test_json)}`;
182
- it(testName, () => {
183
- const value = parser.readType(Amount);
184
- // May not actually be in canonical form. The fixtures are to be used
185
- // also for json -> binary;
186
- assertEqualAmountJSON(toJSON(value), f.test_json);
187
- if (f.exponent) {
188
- assert.equal(value.exponent(), f.exponent);
189
- }
190
- });
191
- });
192
- }
193
-
194
- function fieldParsingTests() {
195
- fixtures.fields_tests.forEach((f, i) => {
196
- const parser = makeParser(f.expected_hex);
197
- it(`fields[${i}]: parses ${f.expected_hex} as ${f.name}`, () => {
198
- const field = parser.readField();
199
- assert.equal(field.name, f.name);
200
- assert.equal(field.type.name, f.type_name);
201
- });
202
- });
203
- }
204
-
205
- function assertRecyclable(json, forField) {
206
- const Type = forField.associatedType;
207
- const recycled = Type.from(json).toJSON();
208
- assert.deepEqual(recycled, json);
209
- const sink = new BytesList();
210
- Type.from(recycled).toBytesSink(sink);
211
- const recycledAgain = makeParser(sink.toHex())
212
- .readType(Type)
213
- .toJSON();
214
- assert.deepEqual(recycledAgain, json);
215
- }
216
-
217
- function nestedObjectTests() {
218
- function disabled(i) {
219
- unused(i);
220
- return false; // !_.includes([2], i);
221
- }
222
-
223
- fixtures.whole_objects.forEach((f, i) => {
224
- if (disabled(i)) {
225
- return;
226
- }
227
-
228
- it(`whole_objects[${i}]: can parse blob into
229
- ${JSON.stringify(f.tx_json)}`,
230
- /* */ () => {
231
-
232
- const parser = makeParser(f.blob_with_no_signing);
233
- let ix = 0;
234
- while (!parser.end()) {
235
- const [field, value] = parser.readFieldAndValue();
236
- const expected = f.fields[ix];
237
- const expectedJSON = expected[1].json;
238
- const expectedField = expected[0];
239
- const actual = toJSON(value);
240
-
241
- try {
242
- assert.deepEqual(actual, expectedJSON);
243
- } catch (e) {
244
- throw new Error(`${e} ${field} a: ${actual} e: ${expectedJSON}`);
245
- }
246
- assert.equal(field.name, expectedField);
247
- assertRecyclable(actual, field);
248
- ix++;
249
- }
250
- });
251
- });
252
- }
253
-
254
- function pathSetBinaryTests() {
255
- const bytes = __(
256
- `1200002200000000240000002E2E00004BF161D4C71AFD498D00000000000000
257
- 0000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA0
258
- 6594D168400000000000000A69D446F8038585E9400000000000000000000000
259
- 00425443000000000078CA21A6014541AB7B26C3929B9E0CD8C284D61C732103
260
- A4665B1F0B7AE2BCA12E2DB80A192125BBEA660F80E9CEE137BA444C1B0769EC
261
- 7447304502205A964536805E35785C659D1F9670D057749AE39668175D6AA75D
262
- 25B218FE682E0221009252C0E5DDD5F2712A48F211669DE17B54113918E0D2C2
263
- 66F818095E9339D7D3811478CA21A6014541AB7B26C3929B9E0CD8C284D61C83
264
- 140A20B3C85F482532A9578DBB3950B85CA06594D1011231585E1F3BD02A15D6
265
- 185F8BB9B57CC60DEDDB37C10000000000000000000000004254430000000000
266
- 585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C131E4FE687C90257D3D2D694C
267
- 8531CDEECBE84F33670000000000000000000000004254430000000000E4FE68
268
- 7C90257D3D2D694C8531CDEECBE84F3367310A20B3C85F482532A9578DBB3950
269
- B85CA06594D100000000000000000000000042544300000000000A20B3C85F48
270
- 2532A9578DBB3950B85CA06594D1300000000000000000000000005553440000
271
- 0000000A20B3C85F482532A9578DBB3950B85CA06594D1FF31585E1F3BD02A15
272
- D6185F8BB9B57CC60DEDDB37C100000000000000000000000042544300000000
273
- 00585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C131E4FE687C90257D3D2D69
274
- 4C8531CDEECBE84F33670000000000000000000000004254430000000000E4FE
275
- 687C90257D3D2D694C8531CDEECBE84F33673115036E2D3F5437A83E5AC3CAEE
276
- 34FF2C21DEB618000000000000000000000000425443000000000015036E2D3F
277
- 5437A83E5AC3CAEE34FF2C21DEB6183000000000000000000000000055534400
278
- 000000000A20B3C85F482532A9578DBB3950B85CA06594D1FF31585E1F3BD02A
279
- 15D6185F8BB9B57CC60DEDDB37C1000000000000000000000000425443000000
280
- 0000585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C13157180C769B66D942EE
281
- 69E6DCC940CA48D82337AD000000000000000000000000425443000000000057
282
- 180C769B66D942EE69E6DCC940CA48D82337AD10000000000000000000000000
283
- 58525000000000003000000000000000000000000055534400000000000A20B3
284
- C85F482532A9578DBB3950B85CA06594D100`);
285
-
286
- const expectedJSON =
287
- [[{account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
288
- currency: 'BTC',
289
- issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'},
290
- {account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
291
- currency: 'BTC',
292
- issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo'},
293
- {account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
294
- currency: 'BTC',
295
- issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'},
296
- {currency: 'USD',
297
- issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'}],
298
- [{account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
299
- currency: 'BTC',
300
- issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'},
301
- {account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
302
- currency: 'BTC',
303
- issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo'},
304
- {account: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi',
305
- currency: 'BTC',
306
- issuer: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi'},
307
- {currency: 'USD',
308
- issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'}],
309
- [{account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
310
- currency: 'BTC',
311
- issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'},
312
- {account: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn',
313
- currency: 'BTC',
314
- issuer: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn'},
315
- {currency: '0000000000000000000000005852500000000000'},
316
- {currency: 'USD',
317
- issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'}]];
318
-
319
- it('works with long paths', () => {
320
- const parser = makeParser(bytes);
321
- const txn = readJSON(parser);
322
- assert.deepEqual(txn.Paths, expectedJSON);
323
- // TODO: this should go elsewhere
324
- assert.deepEqual(
325
- coreTypes.PathSet.from(txn.Paths).toJSON(),
326
- expectedJSON
327
- );
328
- });
329
- }
330
-
331
- describe('BinaryParser', function() {
332
- function dataDrivenTests() {
333
- describe('Amount parsing tests', amountParsingTests);
334
- describe('Field Tests', fieldParsingTests);
335
- describe('Parsing nested objects', nestedObjectTests);
336
- }
337
- describe('pathSetBinaryTests', pathSetBinaryTests);
338
- describe('Basic API', basicApiTests);
339
- describe('Parsing a transaction', transactionParsingTests);
340
- describe('Data Driven Tests', dataDrivenTests);
341
- });
@@ -1,194 +0,0 @@
1
- /* eslint-disable func-style */
2
-
3
- const BN = require('bn.js');
4
- const assert = require('assert');
5
- const lib = require('../src/coretypes');
6
- const encode = require('../src').encode;
7
- const {binary: {makeParser, BytesList, BinarySerializer}} = lib;
8
- const {UInt8, UInt16, UInt32, UInt64, STObject} = lib;
9
- const {loadFixture} = require('./utils');
10
- const fixtures = loadFixture('data-driven-tests.json');
11
- const deliverMinTx = require('./fixtures/delivermin-tx.json');
12
- const deliverMinTxBinary = require('./fixtures/delivermin-tx-binary.json');
13
- const SignerListSet = {
14
- tx: require('./fixtures/signerlistset-tx.json'),
15
- binary: require('./fixtures/signerlistset-tx-binary.json'),
16
- meta: require('./fixtures/signerlistset-tx-meta-binary.json')
17
- };
18
- const DepositPreauth = {
19
- tx: require('./fixtures/deposit-preauth-tx.json'),
20
- binary: require('./fixtures/deposit-preauth-tx-binary.json'),
21
- meta: require('./fixtures/deposit-preauth-tx-meta-binary.json')
22
- };
23
- const Escrow = {
24
- create: {
25
- tx: require('./fixtures/escrow-create-tx.json'),
26
- binary: require('./fixtures/escrow-create-binary.json')
27
- },
28
- finish: {
29
- tx: require('./fixtures/escrow-finish-tx.json'),
30
- binary: require('./fixtures/escrow-finish-binary.json'),
31
- meta: require('./fixtures/escrow-finish-meta-binary.json')
32
- },
33
- cancel: {
34
- tx: require('./fixtures/escrow-cancel-tx.json'),
35
- binary: require('./fixtures/escrow-cancel-binary.json')
36
- }
37
- }
38
- const PaymentChannel = {
39
- create: {
40
- tx: require('./fixtures/payment-channel-create-tx.json'),
41
- binary: require('./fixtures/payment-channel-create-binary.json')
42
- },
43
- fund: {
44
- tx: require('./fixtures/payment-channel-fund-tx.json'),
45
- binary: require('./fixtures/payment-channel-fund-binary.json')
46
- },
47
- claim: {
48
- tx: require('./fixtures/payment-channel-claim-tx.json'),
49
- binary: require('./fixtures/payment-channel-claim-binary.json')
50
- }
51
- }
52
-
53
- function bytesListTest() {
54
- const list = new BytesList().put([0]).put([2, 3]).put([4, 5]);
55
- it('is an Array<Uint8Array>', function() {
56
- assert(Array.isArray(list.arrays));
57
- assert(list.arrays[0] instanceof Uint8Array);
58
- });
59
- it('keeps track of the length itself', function() {
60
- assert.equal(list.length, 5);
61
- });
62
- it('can join all arrays into one via toBytes', function() {
63
- const joined = list.toBytes();
64
- assert(joined.length, 5);
65
- assert.deepEqual(joined, Uint8Array.from([0, 2, 3, 4, 5]));
66
- });
67
- }
68
-
69
- function assertRecycles(blob) {
70
- const parser = makeParser(blob);
71
- const so = parser.readType(STObject);
72
- const out = new BytesList();
73
- so.toBytesSink(out);
74
- const hex = out.toHex();
75
- assert.equal(hex, blob);
76
- assert.notEqual(hex + ':', blob);
77
- }
78
-
79
- function nestedObjectTests() {
80
- fixtures.whole_objects.forEach((f, i) => {
81
- it(`whole_objects[${i}]: can parse blob and dump out same blob`,
82
- /* */ () => {
83
- assertRecycles(f.blob_with_no_signing);
84
- });
85
- });
86
- }
87
-
88
- function UIntTest() {
89
- function check(type, n, expected) {
90
- it(`Uint${type.width * 8} serializes ${n} as ${expected}`, function() {
91
- const bl = new BytesList();
92
- const serializer = new BinarySerializer(bl);
93
- if (expected === 'throws') {
94
- assert.throws(() => serializer.writeType(type, n));
95
- return;
96
- }
97
- serializer.writeType(type, n);
98
- assert.deepEqual(bl.toBytes(), Uint8Array.from(expected));
99
- });
100
- }
101
-
102
- check(UInt8, 5, [5]);
103
- check(UInt16, 5, [0, 5]);
104
- check(UInt32, 5, [0, 0, 0, 5]);
105
- check(UInt32, 0xFFFFFFFF, [255, 255, 255, 255]);
106
- check(UInt8, 0xFEFFFFFF, 'throws');
107
- check(UInt16, 0xFEFFFFFF, 'throws');
108
- check(UInt16, 0xFEFFFFFF, 'throws');
109
- check(UInt64, 0xFEFFFFFF, [0, 0, 0, 0, 254, 255, 255, 255]);
110
- check(UInt64, -1, 'throws');
111
- check(UInt64, 0, [0, 0, 0, 0, 0, 0, 0, 0]);
112
- check(UInt64, 1, [0, 0, 0, 0, 0, 0, 0, 1]);
113
- check(UInt64, new BN(1), [0, 0, 0, 0, 0, 0, 0, 1]);
114
- }
115
-
116
-
117
- function parseLedger4320278() {
118
- it('can parse object', done => {
119
- this.timeout(30e3);
120
- const json = loadFixture('as-ledger-4320278.json');
121
- json.forEach(e => {
122
- assertRecycles(e.binary);
123
- });
124
- done();
125
- });
126
- }
127
-
128
- function deliverMinTest() {
129
- it('can serialize DeliverMin', () => {
130
- assert.strictEqual(encode(deliverMinTx), deliverMinTxBinary);
131
- });
132
- }
133
-
134
- function SignerListSetTest() {
135
- it('can serialize SignerListSet', () => {
136
- assert.strictEqual(encode(SignerListSet.tx), SignerListSet.binary);
137
- });
138
- it('can serialize SignerListSet metadata', () => {
139
- assert.strictEqual(encode(SignerListSet.tx.meta), SignerListSet.meta);
140
- });
141
- }
142
-
143
- function DepositPreauthTest() {
144
- it('can serialize DepositPreauth', () => {
145
- assert.strictEqual(encode(DepositPreauth.tx), DepositPreauth.binary);
146
- });
147
- it('can serialize DepositPreauth metadata', () => {
148
- assert.strictEqual(encode(DepositPreauth.tx.meta), DepositPreauth.meta);
149
- });
150
- }
151
-
152
- function EscrowTest() {
153
- it('can serialize EscrowCreate', () => {
154
- assert.strictEqual(encode(Escrow.create.tx),
155
- Escrow.create.binary);
156
- });
157
- it('can serialize EscrowFinish', () => {
158
- assert.strictEqual(encode(Escrow.finish.tx),
159
- Escrow.finish.binary);
160
- assert.strictEqual(encode(Escrow.finish.tx.meta),
161
- Escrow.finish.meta);
162
- });
163
- it('can serialize EscrowCancel', () => {
164
- assert.strictEqual(encode(Escrow.cancel.tx),
165
- Escrow.cancel.binary);
166
- });
167
- }
168
-
169
- function PaymentChannelTest() {
170
- it('can serialize PaymentChannelCreate', () => {
171
- assert.strictEqual(encode(PaymentChannel.create.tx),
172
- PaymentChannel.create.binary);
173
- });
174
- it('can serialize PaymentChannelFund', () => {
175
- assert.strictEqual(encode(PaymentChannel.fund.tx),
176
- PaymentChannel.fund.binary);
177
- });
178
- it('can serialize PaymentChannelClaim', () => {
179
- assert.strictEqual(encode(PaymentChannel.claim.tx),
180
- PaymentChannel.claim.binary);
181
- });
182
- }
183
-
184
- describe('Binary Serialization', function() {
185
- describe.skip('parseLedger4320278', parseLedger4320278);
186
- describe('nestedObjectTests', nestedObjectTests);
187
- describe('UIntTest', UIntTest);
188
- describe('BytesList', bytesListTest);
189
- describe('DeliverMin', deliverMinTest);
190
- describe('DepositPreauth', DepositPreauthTest);
191
- describe('SignerListSet', SignerListSetTest);
192
- describe('Escrow', EscrowTest);
193
- describe('PaymentChannel', PaymentChannelTest);
194
- });