Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Extract mock rippled constructor, unify some request handlers to redu…
Browse files Browse the repository at this point in the history
…ce redundancy
  • Loading branch information
Chris Clark committed May 21, 2015
1 parent 690c104 commit b4e34bf
Show file tree
Hide file tree
Showing 25 changed files with 2,020 additions and 1,899 deletions.
26 changes: 5 additions & 21 deletions test/balances-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var fixtures = require('./fixtures').balances;
var errors = require('./fixtures').errors;
var addresses = require('./fixtures').addresses;
var requestPath = fixtures.requestPath;
var accountNotFoundResponse = require('./fixtures/mock')
.accountNotFoundResponse;

var MARKER = '29F992CC252056BF690107D1E8F2D9FBAFF29FF107B62B1D1F4E4E11ADF2CC73';
var NEXT_MARKER =
Expand All @@ -19,7 +21,6 @@ var DEFAULT_LIMIT = 200;

suite('get balances', function() {
var self = this;
self.accountInfoResponse = fixtures.accountInfoResponse;

// self.wss: rippled mock
// self.app: supertest-enabled REST handler
Expand Down Expand Up @@ -308,21 +309,14 @@ suite('get balances', function() {
});

test('/accounts/:account/balances -- non-existent account', function(done) {
self.wss.removeAllListeners('request_account_info');
self.wss.once('request_account_info', function(message, conn) {
assert.strictEqual(message.command, 'account_info');
assert.strictEqual(message.account, addresses.VALID);
conn.send(fixtures.accountNotFoundResponse(message));
});

self.wss.once('request_account_lines', function(message, conn) {
assert.strictEqual(message.command, 'account_lines');
assert.strictEqual(message.account, addresses.VALID);
conn.send(fixtures.accountNotFoundResponse(message));
assert.strictEqual(message.account, addresses.NOTFOUND);
conn.send(accountNotFoundResponse(message));
});

self.app
.get(requestPath(addresses.VALID))
.get(requestPath(addresses.NOTFOUND))
.expect(testutils.checkStatus(404))
.expect(testutils.checkHeaders)
.expect(testutils.checkBody(errors.RESTAccountNotFound))
Expand Down Expand Up @@ -350,16 +344,6 @@ suite('get balances', function() {
});

test('/accounts/:account/balances?currency -- native currency', function(done) {
self.wss.removeAllListeners('request_account_info');
self.wss.once('request_account_info', function(message, conn) {
assert.strictEqual(message.command, 'account_info');
assert.strictEqual(message.account, addresses.VALID);
assert.strictEqual(message.ledger_index, 'validated');
conn.send(fixtures.accountInfoResponse(message, {
ledger: LEDGER
}));
});

self.app
.get(requestPath(addresses.VALID, '?currency=XRP'))
.expect(testutils.checkStatus(200))
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module.exports = {
INVALID: 'rxxLy6UWsjzxsQrTATf1bwDYSaJMoTGvfY2Q',
COUNTERPARTY: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
VALID2: 'rHrGzm86u7fwsickgTghsS9D7sUuC3VKwE',
ISSUER2: 'rBXMZX16zyqthrECN4AY4wxbug7335tCKh'
ISSUER2: 'rBXMZX16zyqthrECN4AY4wxbug7335tCKh',
NOTFOUND: 'rajTAg3hon5Lcu1RxQQPxTgHvqfhc1EaUS'
};
Loading

0 comments on commit b4e34bf

Please sign in to comment.