From ff29247b9e415732e110fa63c5abd4cfdd27eaf9 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Thu, 16 Jul 2015 16:47:08 -0700 Subject: [PATCH] Organize rippled mock fixtures --- .../api/rippled/account-info-not-found.json | 15 + test/fixtures/api/rippled/account-info.json | 24 + test/fixtures/api/rippled/account-lines.js | 325 ++++++++ test/fixtures/api/rippled/account-tx.js | 7 +- test/fixtures/api/rippled/index.js | 13 +- test/fixtures/api/rippled/ledger-close.json | 12 + test/fixtures/api/rippled/ledger.json | 27 + test/fixtures/api/rippled/mock.js | 717 ------------------ test/fixtures/api/rippled/server-info.json | 29 + test/fixtures/api/rippled/submit.json | 13 + test/fixtures/api/rippled/subscribe.json | 21 + test/fixtures/api/rippled/tx/account-set.json | 81 +- test/fixtures/api/rippled/tx/not-found.json | 13 + .../fixtures/api/rippled/tx/offer-cancel.json | 173 +++-- .../fixtures/api/rippled/tx/offer-create.json | 171 +++-- test/fixtures/api/rippled/tx/payment.json | 186 +++++ test/fixtures/api/rippled/tx/trust-set.json | 95 +-- test/mock-rippled.js | 48 +- test/setup-api.js | 5 +- 19 files changed, 975 insertions(+), 1000 deletions(-) create mode 100644 test/fixtures/api/rippled/account-info-not-found.json create mode 100644 test/fixtures/api/rippled/account-info.json create mode 100644 test/fixtures/api/rippled/account-lines.js create mode 100644 test/fixtures/api/rippled/ledger-close.json create mode 100644 test/fixtures/api/rippled/ledger.json delete mode 100644 test/fixtures/api/rippled/mock.js create mode 100644 test/fixtures/api/rippled/server-info.json create mode 100644 test/fixtures/api/rippled/submit.json create mode 100644 test/fixtures/api/rippled/subscribe.json create mode 100644 test/fixtures/api/rippled/tx/not-found.json create mode 100644 test/fixtures/api/rippled/tx/payment.json diff --git a/test/fixtures/api/rippled/account-info-not-found.json b/test/fixtures/api/rippled/account-info-not-found.json new file mode 100644 index 00000000..e3e54df4 --- /dev/null +++ b/test/fixtures/api/rippled/account-info-not-found.json @@ -0,0 +1,15 @@ +{ + "id": 0, + "status": "error", + "type": "response", + "account": "rajTAg3hon5Lcu1RxQQPxTgHvqfhc1EaUS", + "error": "actNotFound", + "error_code": 15, + "error_message": "Account not found.", + "ledger_current_index": 8861245, + "request": { + "account": "rajTAg3hon5Lcu1RxQQPxTgHvqfhc1EaUS", + "command": "account_info", + "id": 0 + } +} diff --git a/test/fixtures/api/rippled/account-info.json b/test/fixtures/api/rippled/account-info.json new file mode 100644 index 00000000..c6c17ae8 --- /dev/null +++ b/test/fixtures/api/rippled/account-info.json @@ -0,0 +1,24 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "account_data": { + "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "Balance": "922913243", + "Domain": "6578616D706C652E636F6D", + "EmailHash": "23463B99B62A72F26ED677CC556C44E8", + "Flags": 655360, + "LedgerEntryType": "AccountRoot", + "OwnerCount": 1, + "PreviousTxnID": "19899273706A9E040FDB5885EE991A1DC2BAD878A0D6E7DBCFB714E63BF737F7", + "PreviousTxnLgrSeq": 6614625, + "Sequence": 23, + "TransferRate": 1002000000, + "WalletLocator": "00000000000000000000000000000000000000000000000000000000DEADBEEF", + "index": "396400950EA27EB5710C0D5BE1D2B4689139F168AC5D07C13B8140EC3F82AE71", + "urlgravatar": "http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8" + }, + "ledger_index": 9592219 + } +} diff --git a/test/fixtures/api/rippled/account-lines.js b/test/fixtures/api/rippled/account-lines.js new file mode 100644 index 00000000..f12b7b6e --- /dev/null +++ b/test/fixtures/api/rippled/account-lines.js @@ -0,0 +1,325 @@ +'use strict'; +const _ = require('lodash'); +const BASE_LEDGER_INDEX = 8819951; + +module.exports.normal = function(request, options={}) { + _.defaults(options, { + ledger: BASE_LEDGER_INDEX + }); + + return JSON.stringify({ + id: request.id, + status: 'success', + type: 'response', + result: { + account: request.account, + marker: options.marker, + limit: request.limit, + ledger_index: options.ledger, + lines: [ + { + account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', + balance: '0', + currency: 'ASP', + limit: '0', + limit_peer: '10', + quality_in: 0, + quality_out: 0 + }, + { + account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', + balance: '0', + currency: 'XAU', + limit: '0', + limit_peer: '0', + no_ripple: true, + no_ripple_peer: true, + quality_in: 0, + quality_out: 0, + freeze: true + }, + { + account: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q', + balance: '2.497605752725159', + currency: 'USD', + limit: '5', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0, + freeze: true + }, + { + account: 'rHpXfibHgSb64n8kK9QWDpdbfqSpYbM9a4', + balance: '481.992867407479', + currency: 'MXN', + limit: '1000', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun', + balance: '0.793598266778297', + currency: 'EUR', + limit: '1', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK', + balance: '0', + currency: 'CNY', + limit: '3', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E', + balance: '1.294889190631542', + currency: 'DYM', + limit: '3', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '0.3488146605801446', + currency: 'CHF', + limit: '0', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '2.114103174931847', + currency: 'BTC', + limit: '3', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '0', + currency: 'USD', + limit: '5000', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rpgKWEmNqSDAGFhy5WDnsyPqfQxbWxKeVd', + balance: '-0.00111', + currency: 'BTC', + limit: '0', + limit_peer: '10', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rBJ3YjwXi2MGbg7GVLuTXUWQ8DjL7tDXh4', + balance: '-0.1010780000080207', + currency: 'BTC', + limit: '0', + limit_peer: '10', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun', + balance: '1', + currency: 'USD', + limit: '1', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA', + balance: '8.07619790068559', + currency: 'CNY', + limit: '100', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '7.292695098901099', + currency: 'JPY', + limit: '0', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', + balance: '0', + currency: 'AUX', + limit: '0', + limit_peer: '0', + no_ripple: true, + no_ripple_peer: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X', + balance: '0', + currency: 'USD', + limit: '1', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '12.41688780720394', + currency: 'EUR', + limit: '100', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rfF3PNkwkq1DygW2wum2HK3RGfgkJjdPVD', + balance: '35', + currency: 'USD', + limit: '500', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rwUVoVMSURqNyvocPCcvLu3ygJzZyw8qwp', + balance: '-5', + currency: 'JOE', + limit: '0', + limit_peer: '50', + no_ripple_peer: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2', + balance: '0', + currency: 'USD', + limit: '0', + limit_peer: '100', + no_ripple_peer: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2', + balance: '0', + currency: 'JOE', + limit: '0', + limit_peer: '100', + no_ripple_peer: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rs9M85karFkCRjvc6KMWn8Coigm9cbcgcx', + balance: '0', + currency: '015841551A748AD2C1F76FF6ECB0CCCD00000000', + limit: '10.01037626125837', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rEhDDUUNxpXgEHVJtC2cjXAgyx5VCFxdMF', + balance: '0', + currency: 'USD', + limit: '0', + limit_peer: '1', + quality_in: 0, + quality_out: 0, + freeze: true + } + ] + } + }); +}; + +module.exports.counterparty = function(request, options={}) { + _.defaults(options, { + ledger: BASE_LEDGER_INDEX + }); + + return JSON.stringify({ + id: request.id, + status: 'success', + type: 'response', + result: { + account: request.account, + marker: options.marker, + limit: request.limit, + ledger_index: options.ledger, + lines: [ + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '0.3488146605801446', + currency: 'CHF', + limit: '0', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '2.114103174931847', + currency: 'BTC', + limit: '3', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '0', + currency: 'USD', + limit: '5000', + limit_peer: '0', + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '7.292695098901099', + currency: 'JPY', + limit: '0', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + }, + { + account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', + balance: '12.41688780720394', + currency: 'EUR', + limit: '100', + limit_peer: '0', + no_ripple: true, + quality_in: 0, + quality_out: 0 + } + ] + } + }); +}; diff --git a/test/fixtures/api/rippled/account-tx.js b/test/fixtures/api/rippled/account-tx.js index 42d32546..fc38aec1 100644 --- a/test/fixtures/api/rippled/account-tx.js +++ b/test/fixtures/api/rippled/account-tx.js @@ -7,7 +7,12 @@ const SerializedObject = require('../../../../src/core').SerializedObject; module.exports = function(request, options={}) { _.defaults(options, { - memos: [], + memos: [{ + Memo: { + MemoFormat: '7274312E352E32', + MemoType: '636C69656E74' + } + }], hash: hashes.VALID_TRANSACTION_HASH, validated: true }); diff --git a/test/fixtures/api/rippled/index.js b/test/fixtures/api/rippled/index.js index 0beefeb8..25f5bf67 100644 --- a/test/fixtures/api/rippled/index.js +++ b/test/fixtures/api/rippled/index.js @@ -1,15 +1,24 @@ 'use strict'; module.exports = { - misc: require('./mock'), + submit: require('./submit'), + ledger: require('./ledger'), + subscribe: require('./subscribe'), + account_info: { + normal: require('./account-info'), + notfound: require('./account-info-not-found') + }, account_offers: require('./account-offers'), account_tx: require('./account-tx'), book_offers: require('./book-offers'), + server_info: require('./server-info'), ripple_path_find: require('./ripple-path-find'), tx: { + Payment: require('./tx/payment.json'), AccountSet: require('./tx/account-set.json'), OfferCreate: require('./tx/offer-create.json'), OfferCancel: require('./tx/offer-cancel.json'), - TrustSet: require('./tx/trust-set.json') + TrustSet: require('./tx/trust-set.json'), + NotFound: require('./tx/not-found.json') } }; diff --git a/test/fixtures/api/rippled/ledger-close.json b/test/fixtures/api/rippled/ledger-close.json new file mode 100644 index 00000000..0ad914f5 --- /dev/null +++ b/test/fixtures/api/rippled/ledger-close.json @@ -0,0 +1,12 @@ +{ + "type": "ledgerClosed", + "fee_base": 10, + "fee_ref": 10, + "ledger_hash": "BEAE5AA56874B7F1DE3AA19ED2B8CA61EBDAEC518E421F314B3EAE9AC12BDD02", + "ledger_index": 8819951, + "ledger_time": 463782900, + "reserve_base": 20000000, + "reserve_inc": 5000000, + "txn_count": 5, + "validated_ledgers": "32570-8819951" +} diff --git a/test/fixtures/api/rippled/ledger.json b/test/fixtures/api/rippled/ledger.json new file mode 100644 index 00000000..3d25ed33 --- /dev/null +++ b/test/fixtures/api/rippled/ledger.json @@ -0,0 +1,27 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "ledger": { + "accepted": true, + "account_hash": "EC028EC32896D537ECCA18D18BEBE6AE99709FEFF9EF72DBD3A7819E918D8B96", + "close_time": 464908910, + "close_time_human": "2014-Sep-24 21:21:50", + "close_time_resolution": 10, + "closed": true, + "hash": "0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A0F", + "ledger_hash": "0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A0F", + "ledger_index": "9038214", + "parent_hash": "4BB9CBE44C39DC67A1BE849C7467FE1A6D1F73949EA163C38A0121A15E04FFDE", + "seqNum": "9038214", + "totalCoins": "99999973964317514", + "total_coins": "99999973964317514", + "transaction_hash": "ECB730839EB55B1B114D5D1AD2CD9A932C35BA9AB6D3A8C2F08935EAC2BAC239", + "transactions": [ + "1FC4D12C30CE206A6E23F46FAC62BD393BE9A79A1C452C6F3A04A13BC7A5E5A3", + "E25C38FDB8DD4A2429649588638EE05D055EE6D839CABAF8ABFB4BD17CFE1F3E" + ] + } + } +} diff --git a/test/fixtures/api/rippled/mock.js b/test/fixtures/api/rippled/mock.js deleted file mode 100644 index 0038b09d..00000000 --- a/test/fixtures/api/rippled/mock.js +++ /dev/null @@ -1,717 +0,0 @@ -/* eslint-disable max-len */ -'use strict'; -const _ = require('lodash'); -const addresses = require('../../addresses'); -const accountTransactionsResponse = require('./account-tx'); -const BASE_LEDGER_INDEX = 8819951; - -module.exports.accountTransactionsResponse = accountTransactionsResponse; - -module.exports.subscribeResponse = function(request) { - return JSON.stringify({ - id: request.id, - type: 'response', - status: 'success', - result: { - fee_base: 10, - fee_ref: 10, - hostid: 'NAP', - ledger_hash: '60EBABF55F6AB58864242CADA0B24FBEA027F2426917F39CA56576B335C0065A', - ledger_index: BASE_LEDGER_INDEX, - ledger_time: 463782770, - load_base: 256, - load_factor: 256, - pubkey_node: 'n9Lt7DgQmxjHF5mYJsV2U9anALHmPem8PWQHWGpw4XMz79HA5aJY', - random: 'EECFEE93BBB608914F190EC177B11DE52FC1D75D2C97DACBD26D2DFC6050E874', - reserve_base: 20000000, - reserve_inc: 5000000, - server_status: 'full', - validated_ledgers: '32570-' + BASE_LEDGER_INDEX.toString() - } - }); -}; - -module.exports.ledgerClose = function(offset) { - const ledgerIndex = BASE_LEDGER_INDEX + (offset || 0); - return JSON.stringify({ - type: 'ledgerClosed', - fee_base: 10, - fee_ref: 10, - ledger_hash: 'BEAE5AA56874B7F1DE3AA19ED2B8CA61EBDAEC518E421F314B3EAE9AC12BDD02', - ledger_index: ledgerIndex, - ledger_time: 463782900, - reserve_base: 20000000, - reserve_inc: 5000000, - txn_count: 5, - validated_ledgers: '32570-' + ledgerIndex.toString() - }); -}; - -module.exports.accountInfoResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - account_data: { - Account: request.account, - Balance: '922913243', - Domain: '6578616D706C652E636F6D', - EmailHash: '23463B99B62A72F26ED677CC556C44E8', - Flags: 655360, - LedgerEntryType: 'AccountRoot', - OwnerCount: 1, - PreviousTxnID: '19899273706A9E040FDB5885EE991A1DC2BAD878A0D6E7DBCFB714E63BF737F7', - PreviousTxnLgrSeq: 6614625, - Sequence: 23, - TransferRate: 1002000000, - WalletLocator: '00000000000000000000000000000000000000000000000000000000DEADBEEF', - index: '396400950EA27EB5710C0D5BE1D2B4689139F168AC5D07C13B8140EC3F82AE71', - urlgravatar: 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8' - }, - ledger_index: 9592219 - } - }); -}; - -module.exports.accountNotFoundResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'error', - type: 'response', - account: request.account, - error: 'actNotFound', - error_code: 15, - error_message: 'Account not found.', - ledger_current_index: 8861245, - request: { - account: request.account, - command: 'account_info', - id: request.id - } - }); -}; - -module.exports.accountLinesResponse = function(request, options={}) { - _.defaults(options, { - ledger: BASE_LEDGER_INDEX - }); - - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - account: request.account, - marker: options.marker, - limit: request.limit, - ledger_index: options.ledger, - lines: [ - { - account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', - balance: '0', - currency: 'ASP', - limit: '0', - limit_peer: '10', - quality_in: 0, - quality_out: 0 - }, - { - account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', - balance: '0', - currency: 'XAU', - limit: '0', - limit_peer: '0', - no_ripple: true, - no_ripple_peer: true, - quality_in: 0, - quality_out: 0, - freeze: true - }, - { - account: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q', - balance: '2.497605752725159', - currency: 'USD', - limit: '5', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0, - freeze: true - }, - { - account: 'rHpXfibHgSb64n8kK9QWDpdbfqSpYbM9a4', - balance: '481.992867407479', - currency: 'MXN', - limit: '1000', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun', - balance: '0.793598266778297', - currency: 'EUR', - limit: '1', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK', - balance: '0', - currency: 'CNY', - limit: '3', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E', - balance: '1.294889190631542', - currency: 'DYM', - limit: '3', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '0.3488146605801446', - currency: 'CHF', - limit: '0', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '2.114103174931847', - currency: 'BTC', - limit: '3', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '0', - currency: 'USD', - limit: '5000', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rpgKWEmNqSDAGFhy5WDnsyPqfQxbWxKeVd', - balance: '-0.00111', - currency: 'BTC', - limit: '0', - limit_peer: '10', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rBJ3YjwXi2MGbg7GVLuTXUWQ8DjL7tDXh4', - balance: '-0.1010780000080207', - currency: 'BTC', - limit: '0', - limit_peer: '10', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun', - balance: '1', - currency: 'USD', - limit: '1', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA', - balance: '8.07619790068559', - currency: 'CNY', - limit: '100', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '7.292695098901099', - currency: 'JPY', - limit: '0', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z', - balance: '0', - currency: 'AUX', - limit: '0', - limit_peer: '0', - no_ripple: true, - no_ripple_peer: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X', - balance: '0', - currency: 'USD', - limit: '1', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '12.41688780720394', - currency: 'EUR', - limit: '100', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rfF3PNkwkq1DygW2wum2HK3RGfgkJjdPVD', - balance: '35', - currency: 'USD', - limit: '500', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rwUVoVMSURqNyvocPCcvLu3ygJzZyw8qwp', - balance: '-5', - currency: 'JOE', - limit: '0', - limit_peer: '50', - no_ripple_peer: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2', - balance: '0', - currency: 'USD', - limit: '0', - limit_peer: '100', - no_ripple_peer: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rE6R3DWF9fBD7CyiQciePF9SqK58Ubp8o2', - balance: '0', - currency: 'JOE', - limit: '0', - limit_peer: '100', - no_ripple_peer: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rs9M85karFkCRjvc6KMWn8Coigm9cbcgcx', - balance: '0', - currency: '015841551A748AD2C1F76FF6ECB0CCCD00000000', - limit: '10.01037626125837', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rEhDDUUNxpXgEHVJtC2cjXAgyx5VCFxdMF', - balance: '0', - currency: 'USD', - limit: '0', - limit_peer: '1', - quality_in: 0, - quality_out: 0, - freeze: true - } - ] - } - }); -}; - -module.exports.accountLinesCounterpartyResponse = function(request, options={}) { - _.defaults(options, { - ledger: BASE_LEDGER_INDEX - }); - - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - account: request.account, - marker: options.marker, - limit: request.limit, - ledger_index: options.ledger, - lines: [ - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '0.3488146605801446', - currency: 'CHF', - limit: '0', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '2.114103174931847', - currency: 'BTC', - limit: '3', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '0', - currency: 'USD', - limit: '5000', - limit_peer: '0', - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '7.292695098901099', - currency: 'JPY', - limit: '0', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - }, - { - account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B', - balance: '12.41688780720394', - currency: 'EUR', - limit: '100', - limit_peer: '0', - no_ripple: true, - quality_in: 0, - quality_out: 0 - } - ] - } - }); -}; - -module.exports.accountLinesNoCounterpartyResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - account: request.account, - lines: [] - } - }); -}; - -module.exports.ledgerResponse = function(request) { - return JSON.stringify( - { - id: request.id, - status: 'success', - type: 'response', - result: { - ledger: { - accepted: true, - account_hash: 'EC028EC32896D537ECCA18D18BEBE6AE99709FEFF9EF72DBD3A7819E918D8B96', - close_time: 464908910, - close_time_human: '2014-Sep-24 21:21:50', - close_time_resolution: 10, - closed: true, - hash: '0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A0F', - ledger_hash: '0F7ED9F40742D8A513AE86029462B7A6768325583DF8EE21B7EC663019DD6A0F', - ledger_index: '9038214', - parent_hash: '4BB9CBE44C39DC67A1BE849C7467FE1A6D1F73949EA163C38A0121A15E04FFDE', - seqNum: '9038214', - totalCoins: '99999973964317514', - total_coins: '99999973964317514', - transaction_hash: 'ECB730839EB55B1B114D5D1AD2CD9A932C35BA9AB6D3A8C2F08935EAC2BAC239', - transactions: [ - '1FC4D12C30CE206A6E23F46FAC62BD393BE9A79A1C452C6F3A04A13BC7A5E5A3', - 'E25C38FDB8DD4A2429649588638EE05D055EE6D839CABAF8ABFB4BD17CFE1F3E' - ] - } - } - } - ); -}; - -const METADATA = module.exports.METADATA = { - AffectedNodes: [ - { - ModifiedNode: { - FinalFields: { - Account: 'r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr', - BookDirectory: '4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5E03E788E09BB000', - BookNode: '0000000000000000', - Flags: 0, - OwnerNode: '0000000000000000', - Sequence: 58, - TakerGets: { - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - value: '5.648998' - }, - TakerPays: '6208248802' - }, - LedgerEntryType: 'Offer', - LedgerIndex: '3CFB3C79D4F1BDB1EE5245259372576D926D9A875713422F7169A6CC60AFA68B', - PreviousFields: { - TakerGets: { - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - value: '5.65' - }, - TakerPays: '6209350000' - }, - PreviousTxnID: '8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4', - PreviousTxnLgrSeq: 348433 - } - }, - { - ModifiedNode: { - FinalFields: { - Balance: { - currency: 'USD', - issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji', - value: '-0.001' - }, - Flags: 131072, - HighLimit: { - currency: 'USD', - issuer: addresses.ISSUER, - value: '1' - }, - HighNode: '0000000000000000', - LowLimit: { - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - value: '0' - }, - LowNode: '0000000000000002' - }, - LedgerEntryType: 'RippleState', - LedgerIndex: '4BD1874F8F3A60EDB0C23F5BD43E07953C2B8741B226648310D113DE2B486F01', - PreviousFields: { - Balance: { - currency: 'USD', - issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji', - value: '0' - } - }, - PreviousTxnID: '5B2006DAD0B3130F57ACF7CC5CCAC2EEBCD4B57AAA091A6FD0A24B073D08ABB8', - PreviousTxnLgrSeq: 343703 - } - }, - { - ModifiedNode: { - FinalFields: { - Account: addresses.ACCOUNT, - Balance: '9998898762', - Flags: 0, - OwnerCount: 3, - Sequence: 5 - }, - LedgerEntryType: 'AccountRoot', - LedgerIndex: '4F83A2CF7E70F77F79A307E6A472BFC2585B806A70833CCD1C26105BAE0D6E05', - PreviousFields: { - Balance: '9999999970', - Sequence: 4 - }, - PreviousTxnID: '53354D84BAE8FDFC3F4DA879D984D24B929E7FEB9100D2AD9EFCD2E126BCCDC8', - PreviousTxnLgrSeq: 343570 - } - }, - { - ModifiedNode: { - FinalFields: { - Account: 'r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr', - Balance: '912695302618', - Flags: 0, - OwnerCount: 10, - Sequence: 59 - }, - LedgerEntryType: 'AccountRoot', - LedgerIndex: 'F3E119AAA87AF3607CF87F5523BB8278A83BCB4142833288305D767DD30C392A', - PreviousFields: { - Balance: '912694201420' - }, - PreviousTxnID: '8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4', - PreviousTxnLgrSeq: 348433 - } - }, - { - ModifiedNode: { - FinalFields: { - Balance: { - currency: 'USD', - issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji', - value: '-5.5541638883365' - }, - Flags: 131072, - HighLimit: { - currency: 'USD', - issuer: 'r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr', - value: '1000' - }, - HighNode: '0000000000000000', - LowLimit: { - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - value: '0' - }, - LowNode: '000000000000000C' - }, - LedgerEntryType: 'RippleState', - LedgerIndex: 'FA1255C2E0407F1945BCF9351257C7C5C28B0F5F09BB81C08D35A03E9F0136BC', - PreviousFields: { - Balance: { - currency: 'USD', - issuer: 'rrrrrrrrrrrrrrrrrrrrBZbvji', - value: '-5.5551658883365' - } - }, - PreviousTxnID: '8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4', - PreviousTxnLgrSeq: 348433 - } - } - ], - TransactionIndex: 0, - TransactionResult: 'tesSUCCESS' -}; - -const BINARY_TRANSACTION = module.exports.BINARY_TRANSACTION = { - Account: addresses.ACCOUNT, - Amount: { - currency: 'USD', - issuer: addresses.ISSUER, - value: '0.001' - }, - Destination: addresses.ISSUER, - Fee: '10', - Flags: 0, - Paths: [ - [ - { - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - type: 48, - type_hex: '0000000000000030' - }, - { - account: addresses.OTHER_ACCOUNT, - currency: 'USD', - issuer: addresses.OTHER_ACCOUNT, - type: 49, - type_hex: '0000000000000031' - } - ] - ], - SendMax: '1112209', - Sequence: 4, - SigningPubKey: '02BC8C02199949B15C005B997E7C8594574E9B02BA2D0628902E0532989976CF9D', - TransactionType: 'Payment', - TxnSignature: '304502204EE3E9D1B01D8959B08450FCA9E22025AF503DEF310E34A93863A85CAB3C0BC5022100B61F5B567F77026E8DEED89EED0B7CAF0E6C96C228A2A65216F0DC2D04D52083' -}; - -const BINARY_TRANSACTION_SYNTH = module.exports.BINARY_TRANSACTION_SYNTH = { - date: 416447810, - hash: 'F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF', - inLedger: 348860, - ledger_index: 348860, - validated: true -}; - -const EXAMPLE_TX = _.merge(BINARY_TRANSACTION_SYNTH, BINARY_TRANSACTION, {meta: METADATA}); - -module.exports.transactionResponse = function(request, transaction) { - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: transaction || EXAMPLE_TX - }); -}; - -module.exports.transactionNotFoundResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'error', - type: 'response', - error: 'txnNotFound', - error_code: 24, - error_message: 'Transaction not found.', - request: { - command: 'tx', - id: request.id, - transaction: 'E08D6E9754025CA2534A78707605E0601F03ACE063687A0CA1BDDACFCD1698C7' - } - }); -}; - -module.exports.serverInfoResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - info: { - build_version: '0.24.0-rc1', - complete_ledgers: '32570-6595042', - hostid: 'ARTS', - last_close: {converge_time_s: 2.007, proposers: 4}, - load_factor: 1, - peers: 53, - pubkey_node: 'n94wWvFUmaKGYrKUGgpv1DyYgDeXRGdACkNQaSe7zJiy5Znio7UC', - server_state: 'full', - validated_ledger: { - age: 5, - base_fee_xrp: 0.00001, - hash: '4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46', - reserve_base_xrp: 20, - reserve_inc_xrp: 5, - seq: 6595042 - }, - validation_quorum: 3 - } - } - }); -}; - -module.exports.submitResponse = function(request) { - return JSON.stringify({ - id: request.id, - status: 'success', - type: 'response', - result: { - success: true, - engine_result: 'tesSUCCESS', - engine_result_code: 0, - engine_result_message: 'The transaction was applied. Only final in a validated ledger.', - tx_blob: request.tx_blob, - tx_json: {} // stubbed out for simplicity, not needed for testing - } - }); -}; diff --git a/test/fixtures/api/rippled/server-info.json b/test/fixtures/api/rippled/server-info.json new file mode 100644 index 00000000..913c43be --- /dev/null +++ b/test/fixtures/api/rippled/server-info.json @@ -0,0 +1,29 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "info": { + "build_version": "0.24.0-rc1", + "complete_ledgers": "32570-6595042", + "hostid": "ARTS", + "last_close": { + "converge_time_s": 2.007, + "proposers": 4 + }, + "load_factor": 1, + "peers": 53, + "pubkey_node": "n94wWvFUmaKGYrKUGgpv1DyYgDeXRGdACkNQaSe7zJiy5Znio7UC", + "server_state": "full", + "validated_ledger": { + "age": 5, + "base_fee_xrp": 0.00001, + "hash": "4482DEE5362332F54A4036ED57EE1767C9F33CF7CE5A6670355C16CECE381D46", + "reserve_base_xrp": 20, + "reserve_inc_xrp": 5, + "seq": 6595042 + }, + "validation_quorum": 3 + } + } +} diff --git a/test/fixtures/api/rippled/submit.json b/test/fixtures/api/rippled/submit.json new file mode 100644 index 00000000..a02e05c7 --- /dev/null +++ b/test/fixtures/api/rippled/submit.json @@ -0,0 +1,13 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "success": true, + "engine_result": "tesSUCCESS", + "engine_result_code": 0, + "engine_result_message": "The transaction was applied. Only final in a validated ledger.", + "tx_blob": "12000322000000002400000017201B0086955468400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF02207F5517BC8AEF2ADC1325897ECDBA8C673838048BCA62F4E98B252F19BE88796D770A726970706C652E636F6D81144FBFF73DA4ECF9B701940F27341FA8020C313443", + "tx_json": {} + } +} diff --git a/test/fixtures/api/rippled/subscribe.json b/test/fixtures/api/rippled/subscribe.json new file mode 100644 index 00000000..c3238df7 --- /dev/null +++ b/test/fixtures/api/rippled/subscribe.json @@ -0,0 +1,21 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "fee_base": 10, + "fee_ref": 10, + "hostid": "NAP", + "ledger_hash": "60EBABF55F6AB58864242CADA0B24FBEA027F2426917F39CA56576B335C0065A", + "ledger_index": 8819951, + "ledger_time": 463782770, + "load_base": 256, + "load_factor": 256, + "pubkey_node": "n9Lt7DgQmxjHF5mYJsV2U9anALHmPem8PWQHWGpw4XMz79HA5aJY", + "random": "EECFEE93BBB608914F190EC177B11DE52FC1D75D2C97DACBD26D2DFC6050E874", + "reserve_base": 20000000, + "reserve_inc": 5000000, + "server_status": "full", + "validated_ledgers": "32570-8819951" + } +} diff --git a/test/fixtures/api/rippled/tx/account-set.json b/test/fixtures/api/rippled/tx/account-set.json index 15540da9..292d99e3 100644 --- a/test/fixtures/api/rippled/tx/account-set.json +++ b/test/fixtures/api/rippled/tx/account-set.json @@ -1,41 +1,46 @@ { - "Account": "rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe", - "Fee": "10", - "Flags": 2147483648, - "Sequence": 1, - "SetFlag": 2, - "SigningPubKey": "03EA3ADCA632F125EC2CC4F7F6A82DE0DCE2B65290CAC1F22242C5163F0DA9652D", - "TransactionType": "AccountSet", - "TxnSignature": "3045022100DE8B666B1A31EA65011B0F32130AB91A5747E32FA49B3054CEE8E8362DBAB98A022040CF0CF254677A8E5CD04C59CA2ED7F6F15F7E184641BAE169C561650967B226", - "date": 460832270, - "hash": "4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B", - "inLedger": 8206418, - "ledger_index": 8206418, - "meta": { - "AffectedNodes": [ - { - "ModifiedNode": { - "FinalFields": { - "Account": "rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe", - "Balance": "29999990", - "Flags": 786432, - "OwnerCount": 0, - "Sequence": 2 - }, - "LedgerEntryType": "AccountRoot", - "LedgerIndex": "3F5072C4875F32ED770DAF3610A716600ED7C7BB0348FADC7A98E011BB2CD36F", - "PreviousFields": { - "Balance": "30000000", - "Flags": 4194304, - "Sequence": 1 - }, - "PreviousTxnID": "3FB0350A3742BBCC0D8AA3C5247D1AEC01177D0A24D9C34762BAA2FEA8AD88B3", - "PreviousTxnLgrSeq": 8206397 + "id": 0, + "status": "success", + "type": "response", + "result": { + "Account": "rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe", + "Fee": "10", + "Flags": 2147483648, + "Sequence": 1, + "SetFlag": 2, + "SigningPubKey": "03EA3ADCA632F125EC2CC4F7F6A82DE0DCE2B65290CAC1F22242C5163F0DA9652D", + "TransactionType": "AccountSet", + "TxnSignature": "3045022100DE8B666B1A31EA65011B0F32130AB91A5747E32FA49B3054CEE8E8362DBAB98A022040CF0CF254677A8E5CD04C59CA2ED7F6F15F7E184641BAE169C561650967B226", + "date": 460832270, + "hash": "4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B", + "inLedger": 8206418, + "ledger_index": 8206418, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "rLVKsA4F9iJBbA6rX2x4wCmkj6drgtqpQe", + "Balance": "29999990", + "Flags": 786432, + "OwnerCount": 0, + "Sequence": 2 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "3F5072C4875F32ED770DAF3610A716600ED7C7BB0348FADC7A98E011BB2CD36F", + "PreviousFields": { + "Balance": "30000000", + "Flags": 4194304, + "Sequence": 1 + }, + "PreviousTxnID": "3FB0350A3742BBCC0D8AA3C5247D1AEC01177D0A24D9C34762BAA2FEA8AD88B3", + "PreviousTxnLgrSeq": 8206397 + } } - } - ], - "TransactionIndex": 5, - "TransactionResult": "tesSUCCESS" - }, - "validated": true + ], + "TransactionIndex": 5, + "TransactionResult": "tesSUCCESS" + }, + "validated": true + } } diff --git a/test/fixtures/api/rippled/tx/not-found.json b/test/fixtures/api/rippled/tx/not-found.json new file mode 100644 index 00000000..8503cb0d --- /dev/null +++ b/test/fixtures/api/rippled/tx/not-found.json @@ -0,0 +1,13 @@ +{ + "id": 0, + "status": "error", + "type": "response", + "error": "txnNotFound", + "error_code": 24, + "error_message": "Transaction not found.", + "request": { + "command": "tx", + "id": 0, + "transaction": "E08D6E9754025CA2534A78707605E0601F03ACE063687A0CA1BDDACFCD1698C7" + } +} diff --git a/test/fixtures/api/rippled/tx/offer-cancel.json b/test/fixtures/api/rippled/tx/offer-cancel.json index aef91028..7ecab3ea 100644 --- a/test/fixtures/api/rippled/tx/offer-cancel.json +++ b/test/fixtures/api/rippled/tx/offer-cancel.json @@ -1,90 +1,95 @@ { - "TransactionType": "OfferCancel", - "Flags": 0, - "Sequence": 466, - "OfferSequence": 465, - "LastLedgerSequence": 14661888, - "Fee": "12000", - "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", - "TxnSignature": "3045022100E4148E9809C5CE13BC5583E8CA665614D9FF02D6589D13BA7FBB67CF45EAC0BF02201B84DC18A921260BCEE685908260888BC20D4375DB4A8702F25B346CAD7F3387", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", - "hash": "809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E", - "ledger_index": 14661789, - "inLedger": 14661789, - "meta": { - "TransactionIndex": 4, - "AffectedNodes": [ - { - "ModifiedNode": { - "LedgerEntryType": "AccountRoot", - "PreviousTxnLgrSeq": 14661788, - "PreviousTxnID": "5D9B0B246255815B63983C188B4C23325B3544F605CDBE3004769EE9E990D2F2", - "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", - "PreviousFields": { - "Sequence": 466, - "OwnerCount": 4, - "Balance": "71827095" - }, - "FinalFields": { - "Flags": 0, - "Sequence": 467, - "OwnerCount": 3, - "Balance": "71815095", - "Domain": "726970706C652E636F6D", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" - } - } - }, - { - "ModifiedNode": { - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", - "FinalFields": { - "Flags": 0, - "RootIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", - "Owner": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" - } - } - }, - { - "DeletedNode": { - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "FinalFields": { - "Flags": 0, - "ExchangeRate": "550435C0500F1000", - "RootIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "TakerPaysCurrency": "0000000000000000000000005553440000000000", - "TakerPaysIssuer": "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3", - "TakerGetsCurrency": "0000000000000000000000000000000000000000", - "TakerGetsIssuer": "0000000000000000000000000000000000000000" - } - } - }, - { - "DeletedNode": { - "LedgerEntryType": "Offer", - "LedgerIndex": "D0BEA7E310CDCEED282911314B0D6D00BB7E3B985EAA275AE2AC2DE3763AAF0C", - "FinalFields": { - "Flags": 0, - "Sequence": 465, + "id": 0, + "status": "success", + "type": "response", + "result": { + "TransactionType": "OfferCancel", + "Flags": 0, + "Sequence": 466, + "OfferSequence": 465, + "LastLedgerSequence": 14661888, + "Fee": "12000", + "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", + "TxnSignature": "3045022100E4148E9809C5CE13BC5583E8CA665614D9FF02D6589D13BA7FBB67CF45EAC0BF02201B84DC18A921260BCEE685908260888BC20D4375DB4A8702F25B346CAD7F3387", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", + "hash": "809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E", + "ledger_index": 14661789, + "inLedger": 14661789, + "meta": { + "TransactionIndex": 4, + "AffectedNodes": [ + { + "ModifiedNode": { + "LedgerEntryType": "AccountRoot", "PreviousTxnLgrSeq": 14661788, - "BookNode": "0000000000000000", - "OwnerNode": "0000000000000000", "PreviousTxnID": "5D9B0B246255815B63983C188B4C23325B3544F605CDBE3004769EE9E990D2F2", - "BookDirectory": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "TakerPays": { - "value": "237", - "currency": "USD", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", + "PreviousFields": { + "Sequence": 466, + "OwnerCount": 4, + "Balance": "71827095" }, - "TakerGets": "200", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + "FinalFields": { + "Flags": 0, + "Sequence": 467, + "OwnerCount": 3, + "Balance": "71815095", + "Domain": "726970706C652E636F6D", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } + } + }, + { + "ModifiedNode": { + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", + "FinalFields": { + "Flags": 0, + "RootIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", + "Owner": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } + } + }, + { + "DeletedNode": { + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "FinalFields": { + "Flags": 0, + "ExchangeRate": "550435C0500F1000", + "RootIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "TakerPaysCurrency": "0000000000000000000000005553440000000000", + "TakerPaysIssuer": "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3", + "TakerGetsCurrency": "0000000000000000000000000000000000000000", + "TakerGetsIssuer": "0000000000000000000000000000000000000000" + } + } + }, + { + "DeletedNode": { + "LedgerEntryType": "Offer", + "LedgerIndex": "D0BEA7E310CDCEED282911314B0D6D00BB7E3B985EAA275AE2AC2DE3763AAF0C", + "FinalFields": { + "Flags": 0, + "Sequence": 465, + "PreviousTxnLgrSeq": 14661788, + "BookNode": "0000000000000000", + "OwnerNode": "0000000000000000", + "PreviousTxnID": "5D9B0B246255815B63983C188B4C23325B3544F605CDBE3004769EE9E990D2F2", + "BookDirectory": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "TakerPays": { + "value": "237", + "currency": "USD", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + }, + "TakerGets": "200", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } } } - } - ], - "TransactionResult": "tesSUCCESS" - }, - "validated": true -} \ No newline at end of file + ], + "TransactionResult": "tesSUCCESS" + }, + "validated": true + } +} diff --git a/test/fixtures/api/rippled/tx/offer-create.json b/test/fixtures/api/rippled/tx/offer-create.json index d748b08c..97cf87d1 100644 --- a/test/fixtures/api/rippled/tx/offer-create.json +++ b/test/fixtures/api/rippled/tx/offer-create.json @@ -1,87 +1,92 @@ { - "TransactionType": "OfferCreate", - "Flags": 0, - "Sequence": 465, - "LastLedgerSequence": 14661886, - "TakerPays": { - "value": "237", - "currency": "USD", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" - }, - "TakerGets": "200", - "Fee": "12000", - "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", - "TxnSignature": "3045022100FA4CBD0A54A38906F8D4C18FBA4DBCE45B98F9C5A33BC9102CB5911E9E20E88F022032C47AC74E60042FF1517C866680A41B396D61146FBA9E60B4CF74E373CA7AD2", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", - "hash": "5D9B0B246255815B63983C188B4C23325B3544F605CDBE3004769EE9E990D2F2", - "ledger_index": 14661788, - "inLedger": 14661788, - "meta": { - "TransactionIndex": 2, - "AffectedNodes": [ - { - "ModifiedNode": { - "LedgerEntryType": "AccountRoot", - "PreviousTxnLgrSeq": 14660978, - "PreviousTxnID": "566D4DE22972C5BAD2506CFFA928B21D2BD33FA52FE16712D17D727681FAA4B1", - "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", - "PreviousFields": { - "Sequence": 465, - "OwnerCount": 3, - "Balance": "71839095" - }, - "FinalFields": { - "Flags": 0, - "Sequence": 466, - "OwnerCount": 4, - "Balance": "71827095", - "Domain": "726970706C652E636F6D", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" - } - } - }, - { - "ModifiedNode": { - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", - "FinalFields": { - "Flags": 0, - "RootIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", - "Owner": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" - } - } - }, - { - "CreatedNode": { - "LedgerEntryType": "DirectoryNode", - "LedgerIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "NewFields": { - "ExchangeRate": "550435C0500F1000", - "RootIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "TakerPaysCurrency": "0000000000000000000000005553440000000000", - "TakerPaysIssuer": "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3" - } - } - }, - { - "CreatedNode": { - "LedgerEntryType": "Offer", - "LedgerIndex": "D0BEA7E310CDCEED282911314B0D6D00BB7E3B985EAA275AE2AC2DE3763AAF0C", - "NewFields": { - "Sequence": 465, - "BookDirectory": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", - "TakerPays": { - "value": "237", - "currency": "USD", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + "id": 0, + "status": "success", + "type": "response", + "result": { + "TransactionType": "OfferCreate", + "Flags": 0, + "Sequence": 465, + "LastLedgerSequence": 14661886, + "TakerPays": { + "value": "237", + "currency": "USD", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + }, + "TakerGets": "200", + "Fee": "12000", + "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", + "TxnSignature": "3045022100FA4CBD0A54A38906F8D4C18FBA4DBCE45B98F9C5A33BC9102CB5911E9E20E88F022032C47AC74E60042FF1517C866680A41B396D61146FBA9E60B4CF74E373CA7AD2", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", + "hash": "5D9B0B246255815B63983C188B4C23325B3544F605CDBE3004769EE9E990D2F2", + "ledger_index": 14661788, + "inLedger": 14661788, + "meta": { + "TransactionIndex": 2, + "AffectedNodes": [ + { + "ModifiedNode": { + "LedgerEntryType": "AccountRoot", + "PreviousTxnLgrSeq": 14660978, + "PreviousTxnID": "566D4DE22972C5BAD2506CFFA928B21D2BD33FA52FE16712D17D727681FAA4B1", + "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", + "PreviousFields": { + "Sequence": 465, + "OwnerCount": 3, + "Balance": "71839095" }, - "TakerGets": "200", - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + "FinalFields": { + "Flags": 0, + "Sequence": 466, + "OwnerCount": 4, + "Balance": "71827095", + "Domain": "726970706C652E636F6D", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } + } + }, + { + "ModifiedNode": { + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", + "FinalFields": { + "Flags": 0, + "RootIndex": "6FCB8B0AF9F22ACF762B7712BF44C6CF172FD2BECD849509604EB7DB3AD2C250", + "Owner": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } + } + }, + { + "CreatedNode": { + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "NewFields": { + "ExchangeRate": "550435C0500F1000", + "RootIndex": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "TakerPaysCurrency": "0000000000000000000000005553440000000000", + "TakerPaysIssuer": "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3" + } + } + }, + { + "CreatedNode": { + "LedgerEntryType": "Offer", + "LedgerIndex": "D0BEA7E310CDCEED282911314B0D6D00BB7E3B985EAA275AE2AC2DE3763AAF0C", + "NewFields": { + "Sequence": 465, + "BookDirectory": "CF8D13399C6ED20BA82740CFA78E928DC8D498255249BA63550435C0500F1000", + "TakerPays": { + "value": "237", + "currency": "USD", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + }, + "TakerGets": "200", + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b" + } } } - } - ], - "TransactionResult": "tesSUCCESS" - }, - "validated": true -} \ No newline at end of file + ], + "TransactionResult": "tesSUCCESS" + }, + "validated": true + } +} diff --git a/test/fixtures/api/rippled/tx/payment.json b/test/fixtures/api/rippled/tx/payment.json new file mode 100644 index 00000000..efa39cb6 --- /dev/null +++ b/test/fixtures/api/rippled/tx/payment.json @@ -0,0 +1,186 @@ +{ + "id": 0, + "status": "success", + "type": "response", + "result": { + "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "Amount": { + "currency": "USD", + "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", + "value": "0.001" + }, + "Destination": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", + "Fee": "10", + "Flags": 0, + "Paths": [ + [ + { + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "type": 48, + "type_hex": "0000000000000030" + }, + { + "account": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "type": 49, + "type_hex": "0000000000000031" + } + ] + ], + "SendMax": "1112209", + "Sequence": 4, + "SigningPubKey": "02BC8C02199949B15C005B997E7C8594574E9B02BA2D0628902E0532989976CF9D", + "TransactionType": "Payment", + "TxnSignature": "304502204EE3E9D1B01D8959B08450FCA9E22025AF503DEF310E34A93863A85CAB3C0BC5022100B61F5B567F77026E8DEED89EED0B7CAF0E6C96C228A2A65216F0DC2D04D52083", + "date": 416447810, + "hash": "F4AB442A6D4CBB935D66E1DA7309A5FC71C7143ED4049053EC14E3875B0CF9BF", + "inLedger": 348860, + "ledger_index": 348860, + "validated": true, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr", + "BookDirectory": "4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5E03E788E09BB000", + "BookNode": "0000000000000000", + "Flags": 0, + "OwnerNode": "0000000000000000", + "Sequence": 58, + "TakerGets": { + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "value": "5.648998" + }, + "TakerPays": "6208248802" + }, + "LedgerEntryType": "Offer", + "LedgerIndex": "3CFB3C79D4F1BDB1EE5245259372576D926D9A875713422F7169A6CC60AFA68B", + "PreviousFields": { + "TakerGets": { + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "value": "5.65" + }, + "TakerPays": "6209350000" + }, + "PreviousTxnID": "8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4", + "PreviousTxnLgrSeq": 348433 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "-0.001" + }, + "Flags": 131072, + "HighLimit": { + "currency": "USD", + "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", + "value": "1" + }, + "HighNode": "0000000000000000", + "LowLimit": { + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "value": "0" + }, + "LowNode": "0000000000000002" + }, + "LedgerEntryType": "RippleState", + "LedgerIndex": "4BD1874F8F3A60EDB0C23F5BD43E07953C2B8741B226648310D113DE2B486F01", + "PreviousFields": { + "Balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "0" + } + }, + "PreviousTxnID": "5B2006DAD0B3130F57ACF7CC5CCAC2EEBCD4B57AAA091A6FD0A24B073D08ABB8", + "PreviousTxnLgrSeq": 343703 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", + "Balance": "9998898762", + "Flags": 0, + "OwnerCount": 3, + "Sequence": 5 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "4F83A2CF7E70F77F79A307E6A472BFC2585B806A70833CCD1C26105BAE0D6E05", + "PreviousFields": { + "Balance": "9999999970", + "Sequence": 4 + }, + "PreviousTxnID": "53354D84BAE8FDFC3F4DA879D984D24B929E7FEB9100D2AD9EFCD2E126BCCDC8", + "PreviousTxnLgrSeq": 343570 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Account": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr", + "Balance": "912695302618", + "Flags": 0, + "OwnerCount": 10, + "Sequence": 59 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "F3E119AAA87AF3607CF87F5523BB8278A83BCB4142833288305D767DD30C392A", + "PreviousFields": { + "Balance": "912694201420" + }, + "PreviousTxnID": "8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4", + "PreviousTxnLgrSeq": 348433 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "-5.5541638883365" + }, + "Flags": 131072, + "HighLimit": { + "currency": "USD", + "issuer": "r9tGqzZgKxVFvzKFdUqXAqTzazWBUia8Qr", + "value": "1000" + }, + "HighNode": "0000000000000000", + "LowLimit": { + "currency": "USD", + "issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo", + "value": "0" + }, + "LowNode": "000000000000000C" + }, + "LedgerEntryType": "RippleState", + "LedgerIndex": "FA1255C2E0407F1945BCF9351257C7C5C28B0F5F09BB81C08D35A03E9F0136BC", + "PreviousFields": { + "Balance": { + "currency": "USD", + "issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji", + "value": "-5.5551658883365" + } + }, + "PreviousTxnID": "8F571C346688D89AC1F737AE3B6BB5D976702B171CC7B4DE5CA3D444D5B8D6B4", + "PreviousTxnLgrSeq": 348433 + } + } + ], + "TransactionIndex": 0, + "TransactionResult": "tesSUCCESS" + } + } +} diff --git a/test/fixtures/api/rippled/tx/trust-set.json b/test/fixtures/api/rippled/tx/trust-set.json index 7a2fc9de..5ee19a44 100644 --- a/test/fixtures/api/rippled/tx/trust-set.json +++ b/test/fixtures/api/rippled/tx/trust-set.json @@ -1,48 +1,53 @@ { - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", - "Fee": "12000", - "Flags": 131072, - "LastLedgerSequence": 14640622, - "LimitAmount": { - "currency": "USD", - "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", - "value": "10000" - }, - "QualityIn": 500000000, - "QualityOut": 500000000, - "Sequence": 449, - "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", - "TransactionType": "TrustSet", - "TxnSignature": "3045022100D91DB5E6E8B6650E67A61C04D110EB61FA1F83E25815F7EE1A24A1A0DD40C3DD0220578726715E597B6FB8EBDAD88CA9E6A5A64F17BE1AC9EEA89584663BC55021BE", - "date": 490233540, - "hash": "635A0769BD94710A1F6A76CDE65A3BC661B20B798807D1BBBDADCEA26420538D", - "inLedger": 14640523, - "ledger_index": 14640523, - "meta": { - "AffectedNodes": [ - { - "ModifiedNode": { - "FinalFields": { - "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", - "Balance": "72019096", - "Domain": "726970706C652E636F6D", - "Flags": 0, - "OwnerCount": 3, - "Sequence": 450 - }, - "LedgerEntryType": "AccountRoot", - "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", - "PreviousFields": { - "Balance": "72031096", - "Sequence": 449 - }, - "PreviousTxnID": "B1E5D76EA71644EF349843D9AB03D76651A42649A95E2FC07C1D8284F10D76A2", - "PreviousTxnLgrSeq": 14640521 + "id": 0, + "status": "success", + "type": "response", + "result": { + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", + "Fee": "12000", + "Flags": 131072, + "LastLedgerSequence": 14640622, + "LimitAmount": { + "currency": "USD", + "issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM", + "value": "10000" + }, + "QualityIn": 500000000, + "QualityOut": 500000000, + "Sequence": 449, + "SigningPubKey": "036A749E3B7187E43E8936E3D83A7030989325249E03803F12B7F64BAACABA6025", + "TransactionType": "TrustSet", + "TxnSignature": "3045022100D91DB5E6E8B6650E67A61C04D110EB61FA1F83E25815F7EE1A24A1A0DD40C3DD0220578726715E597B6FB8EBDAD88CA9E6A5A64F17BE1AC9EEA89584663BC55021BE", + "date": 490233540, + "hash": "635A0769BD94710A1F6A76CDE65A3BC661B20B798807D1BBBDADCEA26420538D", + "inLedger": 14640523, + "ledger_index": 14640523, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "r9UHu5CWni1qRY7Q4CfFZLGvXo2pGQy96b", + "Balance": "72019096", + "Domain": "726970706C652E636F6D", + "Flags": 0, + "OwnerCount": 3, + "Sequence": 450 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "4AD70690C6FF8A069F8AE00B09F70E9B732360026E8085050D314432091A59C9", + "PreviousFields": { + "Balance": "72031096", + "Sequence": 449 + }, + "PreviousTxnID": "B1E5D76EA71644EF349843D9AB03D76651A42649A95E2FC07C1D8284F10D76A2", + "PreviousTxnLgrSeq": 14640521 + } } - } - ], - "TransactionIndex": 1, - "TransactionResult": "tesSUCCESS" - }, - "validated": true + ], + "TransactionIndex": 1, + "TransactionResult": "tesSUCCESS" + }, + "validated": true + } } diff --git a/test/mock-rippled.js b/test/mock-rippled.js index c426fb62..09ea30f2 100644 --- a/test/mock-rippled.js +++ b/test/mock-rippled.js @@ -6,6 +6,8 @@ const EventEmitter2 = require('eventemitter2').EventEmitter2; const fixtures = require('./fixtures/api/rippled'); const addresses = require('./fixtures/addresses'); const hashes = require('./fixtures/hashes'); +const transactionsResponse = require('./fixtures/api/rippled/account-tx'); +const accountLinesResponse = require('./fixtures/api/rippled/account-lines'); function isUSD(json) { return json === 'USD' || json === '0000000000000000000000005553440000000000'; @@ -15,6 +17,10 @@ function isBTC(json) { return json === 'BTC' || json === '0000000000000000000000004254430000000000'; } +function createResponse(request, response) { + return JSON.stringify(_.assign({}, response, {id: request.id})); +} + module.exports = function(port) { const mock = new WebSocketServer({port: port}); _.assign(mock, EventEmitter2.prototype); @@ -65,7 +71,7 @@ module.exports = function(port) { mock.on('request_server_info', function(request, conn) { assert.strictEqual(request.command, 'server_info'); - conn.send(fixtures.misc.serverInfoResponse(request)); + conn.send(createResponse(request, fixtures.server_info)); }); mock.on('request_subscribe', function(request, conn) { @@ -75,15 +81,15 @@ module.exports = function(port) { } else { assert.deepEqual(request.streams, ['ledger', 'server']); } - conn.send(fixtures.misc.subscribeResponse(request)); + conn.send(createResponse(request, fixtures.subscribe)); }); mock.on('request_account_info', function(request, conn) { assert.strictEqual(request.command, 'account_info'); if (request.account === addresses.ACCOUNT) { - conn.send(fixtures.misc.accountInfoResponse(request)); + conn.send(createResponse(request, fixtures.account_info.normal)); } else if (request.account === addresses.NOTFOUND) { - conn.send(fixtures.misc.accountNotFoundResponse(request)); + conn.send(createResponse(request, fixtures.account_info.notfound)); } else { assert(false, 'Unrecognized account address: ' + request.account); } @@ -91,31 +97,27 @@ module.exports = function(port) { mock.on('request_ledger', function(request, conn) { assert.strictEqual(request.command, 'ledger'); - conn.send(fixtures.misc.ledgerResponse(request)); + conn.send(createResponse(request, fixtures.ledger)); }); mock.on('request_tx', function(request, conn) { assert.strictEqual(request.command, 'tx'); if (request.transaction === hashes.VALID_TRANSACTION_HASH) { - conn.send(fixtures.misc.transactionResponse(request)); + conn.send(createResponse(request, fixtures.tx.Payment)); } else if (request.transaction === '4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA1B') { - const transaction = fixtures.tx.AccountSet; - conn.send(fixtures.misc.transactionResponse(request, transaction)); + conn.send(createResponse(request, fixtures.tx.AccountSet)); } else if (request.transaction === '10A6FB4A66EE80BED46AAE4815D7DC43B97E944984CCD5B93BCF3F8538CABC51') { - const transaction = fixtures.tx.OfferCreate; - conn.send(fixtures.misc.transactionResponse(request, transaction)); + conn.send(createResponse(request, fixtures.tx.OfferCreate)); } else if (request.transaction === '809335DD3B0B333865096217AA2F55A4DF168E0198080B3A090D12D88880FF0E') { - const transaction = fixtures.tx.OfferCancel; - conn.send(fixtures.misc.transactionResponse(request, transaction)); + conn.send(createResponse(request, fixtures.tx.OfferCancel)); } else if (request.transaction === '635A0769BD94710A1F6A76CDE65A3BC661B20B798807D1BBBDADCEA26420538D') { - const transaction = fixtures.tx.TrustSet; - conn.send(fixtures.misc.transactionResponse(request, transaction)); + conn.send(createResponse(request, fixtures.tx.TrustSet)); } else if (request.transaction === hashes.NOTFOUND_TRANSACTION_HASH) { - conn.send(fixtures.misc.transactionNotFoundResponse(request)); + conn.send(createResponse(request, fixtures.tx.NotFound)); } else { assert(false, 'Unrecognized transaction hash: ' + request.transaction); } @@ -123,14 +125,14 @@ module.exports = function(port) { mock.on('request_submit', function(request, conn) { assert.strictEqual(request.command, 'submit'); - conn.send(fixtures.misc.submitResponse(request)); + conn.send(createResponse(request, fixtures.submit)); }); mock.on('request_account_lines', function(request, conn) { if (request.account === addresses.ACCOUNT) { - conn.send(fixtures.misc.accountLinesResponse(request)); + conn.send(accountLinesResponse.normal(request)); } else if (request.account === addresses.OTHER_ACCOUNT) { - conn.send(fixtures.misc.accountLinesCounterpartyResponse(request)); + conn.send(accountLinesResponse.counterparty(request)); } else { assert(false, 'Unrecognized account address: ' + request.account); } @@ -138,15 +140,7 @@ module.exports = function(port) { mock.on('request_account_tx', function(request, conn) { if (request.account === addresses.ACCOUNT) { - const options = { - memos: [{ - Memo: { - MemoFormat: '7274312E352E32', - MemoType: '636C69656E74' - } - }] - }; - conn.send(fixtures.misc.accountTransactionsResponse(request, options)); + conn.send(transactionsResponse(request)); } else { assert(false, 'Unrecognized account address: ' + request.account); } diff --git a/test/setup-api.js b/test/setup-api.js index 3c9ca732..dc7d661e 100644 --- a/test/setup-api.js +++ b/test/setup-api.js @@ -1,7 +1,7 @@ 'use strict'; const net = require('net'); const RippleAPI = require('../src').RippleAPI; -const fixtures = require('./fixtures/api/rippled').misc; +const ledgerClosed = require('./fixtures/api/rippled/ledger-close'); const createMockRippled = require('./mock-rippled'); // using a free port instead of a constant port enables parallelization @@ -26,8 +26,7 @@ function setupMockRippledConnection(testcase, port, done) { testcase.api = new RippleAPI({servers: ['ws://localhost:' + port]}); testcase.api.connect(() => { testcase.api.remote.getServer().once('ledger_closed', () => done()); - testcase.api.remote.getServer().emit('message', - JSON.parse(fixtures.ledgerClose(0))); + testcase.api.remote.getServer().emit('message', ledgerClosed); }); }