Skip to content

Commit

Permalink
testing - add memo field into payment transaction so parsePaymentMemo…
Browse files Browse the repository at this point in the history
…s from parsePayment is tested
  • Loading branch information
darkdarkdragon committed Jul 17, 2015
1 parent 8d57528 commit eb7bbe5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/api/ledger/parse/payment.js
Expand Up @@ -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 {
Expand Down
16 changes: 14 additions & 2 deletions test/fixtures/api/responses/get-transactions.json
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
10 changes: 9 additions & 1 deletion test/mock-rippled.js
Expand Up @@ -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);
}
Expand Down

0 comments on commit eb7bbe5

Please sign in to comment.