diff --git a/packages/ripple-binary-codec/src/enums/definitions.json b/packages/ripple-binary-codec/src/enums/definitions.json index 886f081b..938355f8 100644 --- a/packages/ripple-binary-codec/src/enums/definitions.json +++ b/packages/ripple-binary-codec/src/enums/definitions.json @@ -861,6 +861,17 @@ "type": "Amount" } ], + [ + "DeliverMin", + { + "nth": 10, + "isVLEncoded": false, + "bytes": "6A", + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], [ "MinimumOffer", { @@ -1636,4 +1647,4 @@ "SuspendedPaymentCancel": 4, "Invalid": -1 } -} \ No newline at end of file +} diff --git a/packages/ripple-binary-codec/test/binary-serializer-test.js b/packages/ripple-binary-codec/test/binary-serializer-test.js index c885ba15..2ac824ca 100644 --- a/packages/ripple-binary-codec/test/binary-serializer-test.js +++ b/packages/ripple-binary-codec/test/binary-serializer-test.js @@ -5,10 +5,13 @@ const BN = require('bn.js'); const assert = require('assert-diff'); const lib = require('../src/coretypes'); +const encode = require('../src').encode; const {binary: {makeParser, BytesList, BinarySerializer}} = lib; const {UInt8, UInt16, UInt32, UInt64, STObject} = lib; const {loadFixture} = require('./utils'); const fixtures = loadFixture('data-driven-tests.json'); +const deliverMinTx = require('./fixtures/delivermin-tx.json'); +const deliverMinTxBinary = require('./fixtures/delivermin-tx-binary.json'); function bytesListTest() { const list = new BytesList().put([0]).put([2, 3]).put([4, 5]); @@ -85,9 +88,16 @@ function parseLedger4320278() { }); } +function deliverMinTest() { + it(`can serialize DeliverMin`, () => { + assert.strictEqual(encode(deliverMinTx), deliverMinTxBinary); + }); +} + describe('Binary Serialization', function() { describe.skip('parseLedger4320278', parseLedger4320278); describe('nestedObjectTests', nestedObjectTests); describe('UIntTest', UIntTest); describe('BytesList', bytesListTest); + describe('DeliverMin', deliverMinTest); }); diff --git a/packages/ripple-binary-codec/test/fixtures/delivermin-tx-binary.json b/packages/ripple-binary-codec/test/fixtures/delivermin-tx-binary.json new file mode 100644 index 00000000..b4703139 --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/delivermin-tx-binary.json @@ -0,0 +1 @@ +"1200002280020000240000689E201B010BF0E361D4950EA99C657EF800000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D1684000000000002AF8694000000000003A986AD40485B690F28E8000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D173210254D771E2A30552D1F347F5B88EC87513843F8BC1A408E70A4175B2E3C325FD3C7446304402202A4965FCF0571B7308971956864B1949C2BD924B5A41B5E8DAF00C91C64F964502207FD3BEB7C165BD1F10E6E7C443742BD686F8E102A89B502A4A495F4C29EC5C488114EAAA52373B59DCFBFD3476049AA6408AA22EAA898314EAAA52373B59DCFBFD3476049AA6408AA22EAA8901123000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D1FF01FDF050193BEDEAA9074764B961405D31E66AC0E9300000000000000000000000005553440000000000FDF050193BEDEAA9074764B961405D31E66AC0E901FDF050193BEDEAA9074764B961405D31E66AC0E9FF300000000000000000000000005553440000000000DD39C650A96EDA48334E70CC4A85B8B2E8502CD301DD39C650A96EDA48334E70CC4A85B8B2E8502CD3017C44F934D7A5FEEBD1530570CDB83D1D8EF1F37E00" diff --git a/packages/ripple-binary-codec/test/fixtures/delivermin-tx.json b/packages/ripple-binary-codec/test/fixtures/delivermin-tx.json new file mode 100644 index 00000000..910fa8c6 --- /dev/null +++ b/packages/ripple-binary-codec/test/fixtures/delivermin-tx.json @@ -0,0 +1,98 @@ +{ + "Account": "r4PowrZ7KZw83oWDYxzY82ht2kgDmFUpB7", + "Amount": { + "currency": "USD", + "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + "value": "5.927096147083" + }, + "DeliverMin": { + "currency": "USD", + "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + "value": "0.012729190692" + }, + "Destination": "r4PowrZ7KZw83oWDYxzY82ht2kgDmFUpB7", + "Fee": "11000", + "Flags": 2147614720, + "LastLedgerSequence": 17559779, + "Paths": [ + [ + { + "currency": "USD", + "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", + "type": 48, + "type_hex": "0000000000000030" + } + ], + [ + { + "account": "rQ96qm46YsRX2F7SSCQxToR2ybRuUYsZ4R", + "type": 1, + "type_hex": "0000000000000001" + }, + { + "currency": "USD", + "issuer": "rQ96qm46YsRX2F7SSCQxToR2ybRuUYsZ4R", + "type": 48, + "type_hex": "0000000000000030" + }, + { + "account": "rQ96qm46YsRX2F7SSCQxToR2ybRuUYsZ4R", + "type": 1, + "type_hex": "0000000000000001" + } + ], + [ + { + "currency": "USD", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", + "type": 48, + "type_hex": "0000000000000030" + }, + { + "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", + "type": 1, + "type_hex": "0000000000000001" + }, + { + "account": "rULnR9YhAkj9HrcxAcudzBhaXRSqT7zJkq", + "type": 1, + "type_hex": "0000000000000001" + } + ] + ], + "SendMax": "15000", + "Sequence": 26782, + "SigningPubKey": "0254D771E2A30552D1F347F5B88EC87513843F8BC1A408E70A4175B2E3C325FD3C", + "TransactionType": "Payment", + "TxnSignature": "304402202A4965FCF0571B7308971956864B1949C2BD924B5A41B5E8DAF00C91C64F964502207FD3BEB7C165BD1F10E6E7C443742BD686F8E102A89B502A4A495F4C29EC5C48", + "date": 502912010, + "hash": "0FB10DF664F33840ABC68A8BBE78178359C55AC1AFC83DB468CE69C4A86E3EAC", + "inLedger": 17559773, + "ledger_index": 17559773, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "r4PowrZ7KZw83oWDYxzY82ht2kgDmFUpB7", + "Balance": "1064773000", + "Flags": 65536, + "OwnerCount": 9, + "Sequence": 26783 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "0D7F8ADAA3269E9C8B2AA9CDE31BC57E2E52133F36516D3DF576DBCE6E405BDC", + "PreviousFields": { + "Balance": "1064784000", + "Sequence": 26782 + }, + "PreviousTxnID": "E028797D6C7AE9B84C6930452D427D5E40CE23E199E8DF0534DAAE5277A76CC1", + "PreviousTxnLgrSeq": 17537115 + } + } + ], + "TransactionIndex": 12, + "TransactionResult": "tecPATH_PARTIAL" + }, + "validated": true +}