From eb7bbe571513a8385c75e0443066dab1b931aecb Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Fri, 17 Jul 2015 05:58:28 +0300 Subject: [PATCH] testing - add memo field into payment transaction so parsePaymentMemos from parsePayment is tested --- src/api/ledger/parse/payment.js | 8 +++++++- .../fixtures/api/responses/get-transactions.json | 16 ++++++++++++++-- test/mock-rippled.js | 10 +++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/api/ledger/parse/payment.js b/src/api/ledger/parse/payment.js index 236e50d4..bf8bba99 100644 --- a/src/api/ledger/parse/payment.js +++ b/src/api/ledger/parse/payment.js @@ -17,7 +17,13 @@ function parsePaymentMemos(tx) { if (!Array.isArray(tx.Memos) || tx.Memos.length === 0) { return undefined; } - return tx.Memos.map((m) => m.Memo); + return tx.Memos.map((m) => { + return utils.removeUndefined({ + type: m.Memo.parsed_memo_type, + format: m.Memo.parsed_memo_format, + data: m.Memo.parsed_memo_data + }); + }); } function parsePayment(tx: Object): Object { diff --git a/test/fixtures/api/responses/get-transactions.json b/test/fixtures/api/responses/get-transactions.json index f6a7d423..e7b50041 100644 --- a/test/fixtures/api/responses/get-transactions.json +++ b/test/fixtures/api/responses/get-transactions.json @@ -3,8 +3,14 @@ "type": "payment", "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "sequence": 4, - "id": "4C37C92576DEB000D13B07F4D3F99F968BD86B6B83A840BEFFB2BFC8A042A81B", + "id": "99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865", "specification": { + "memos": [ + { + "type": "client", + "format": "rt1.5.2" + } + ], "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "amount": { @@ -87,9 +93,15 @@ { "type": "payment", "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", - "id": "4C37C92576DEB000D13B07F4D3F99F968BD86B6B83A840BEFFB2BFC8A042A81B", + "id": "99404A34E8170319521223A6C604AF48B9F1E3000C377E6141F9A1BF60B0B865", "sequence": 4, "specification": { + "memos": [ + { + "type": "client", + "format": "rt1.5.2" + } + ], "source": { "address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "amount": { diff --git a/test/mock-rippled.js b/test/mock-rippled.js index db3df42b..62333340 100644 --- a/test/mock-rippled.js +++ b/test/mock-rippled.js @@ -134,7 +134,15 @@ module.exports = function(port) { mock.on('request_account_tx', function(request, conn) { if (request.account === addresses.ACCOUNT) { - conn.send(fixtures.misc.accountTransactionsResponse(request)); + const options = { + memos: [{ + Memo: { + MemoFormat: '7274312E352E32', + MemoType: '636C69656E74' + } + }] + }; + conn.send(fixtures.misc.accountTransactionsResponse(request, options)); } else { assert(false, 'Unrecognized account address: ' + request.account); }