mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
Merge pull request #596 from darkdarkdragon/develop-RLJS-520
getBalances fixes:
This commit is contained in:
@@ -196,9 +196,45 @@ describe('RippleAPI', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('getBalances', function() {
|
||||
return this.api.getBalances(address).then(
|
||||
_.partial(checkResult, responses.getBalances, 'getBalances'));
|
||||
describe('RippleAPI', function() {
|
||||
|
||||
it('getBalances', function() {
|
||||
return this.api.getBalances(address).then(
|
||||
_.partial(checkResult, responses.getBalances, 'getBalances'));
|
||||
});
|
||||
|
||||
it('getBalances - limit', function() {
|
||||
const options = {
|
||||
limit: 3
|
||||
};
|
||||
const expectedResponse = responses.getBalances.slice(0, 3);
|
||||
return this.api.getBalances(address, options).then(
|
||||
_.partial(checkResult, expectedResponse, 'getBalances'));
|
||||
});
|
||||
|
||||
it('getBalances - limit & currency', function() {
|
||||
const options = {
|
||||
currency: 'USD',
|
||||
limit: 3
|
||||
};
|
||||
const expectedResponse = _.filter(responses.getBalances,
|
||||
item => item.currency === 'USD').slice(0, 3);
|
||||
return this.api.getBalances(address, options).then(
|
||||
_.partial(checkResult, expectedResponse, 'getBalances'));
|
||||
});
|
||||
|
||||
it('getBalances - limit & currency & issuer', function() {
|
||||
const options = {
|
||||
currency: 'USD',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
limit: 3
|
||||
};
|
||||
const expectedResponse = _.filter(responses.getBalances,
|
||||
item => item.currency === 'USD' &&
|
||||
item.counterparty === 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B').slice(0, 3);
|
||||
return this.api.getBalances(address, options).then(
|
||||
_.partial(checkResult, expectedResponse, 'getBalances'));
|
||||
});
|
||||
});
|
||||
|
||||
it('getBalanceSheet', function() {
|
||||
|
||||
12
test/fixtures/api/rippled/account-lines.js
vendored
12
test/fixtures/api/rippled/account-lines.js
vendored
@@ -2,7 +2,7 @@
|
||||
const _ = require('lodash');
|
||||
const BASE_LEDGER_INDEX = 8819951;
|
||||
|
||||
module.exports.normal = function(request, options={}) {
|
||||
module.exports.normal = function(request, options = {}) {
|
||||
_.defaults(options, {
|
||||
ledger: BASE_LEDGER_INDEX
|
||||
});
|
||||
@@ -16,8 +16,7 @@ module.exports.normal = function(request, options={}) {
|
||||
marker: options.marker,
|
||||
limit: request.limit,
|
||||
ledger_index: options.ledger,
|
||||
lines: [
|
||||
{
|
||||
lines: _.filter([{
|
||||
account: 'r3vi7mWxru9rJCxETCyA1CHvzL96eZWx5z',
|
||||
balance: '0',
|
||||
currency: 'ASP',
|
||||
@@ -252,12 +251,12 @@ module.exports.normal = function(request, options={}) {
|
||||
quality_out: 0,
|
||||
freeze: true
|
||||
}
|
||||
]
|
||||
], item => !request.peer || item.account === request.peer)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.counterparty = function(request, options={}) {
|
||||
module.exports.counterparty = function(request, options = {}) {
|
||||
_.defaults(options, {
|
||||
ledger: BASE_LEDGER_INDEX
|
||||
});
|
||||
@@ -271,8 +270,7 @@ module.exports.counterparty = function(request, options={}) {
|
||||
marker: options.marker,
|
||||
limit: request.limit,
|
||||
ledger_index: options.ledger,
|
||||
lines: [
|
||||
{
|
||||
lines: [{
|
||||
account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
balance: '0.3488146605801446',
|
||||
currency: 'CHF',
|
||||
|
||||
Reference in New Issue
Block a user