diff --git a/src/ledger/pathfind-types.js b/src/ledger/pathfind-types.js index 236f0ee3c8..9cb23fd679 100644 --- a/src/ledger/pathfind-types.js +++ b/src/ledger/pathfind-types.js @@ -1,55 +1,55 @@ -/* @flow */ -'use strict'; - -import type {Amount, LaxLaxAmount, RippledAmount, Adjustment, MaxAdjustment, - MinAdjustment} from '../common/types.js'; - - -type Path = { - source: Adjustment | MaxAdjustment, - destination: Adjustment | MinAdjustment, - paths: string -} - -export type GetPaths = Array - -export type PathFind = { - source: { - address: string, - amount?: Amount, - currencies?: Array<{currency: string, counterparty?:string}> - }, - destination: { - address: string, - amount: LaxLaxAmount - } -} - -export type PathFindRequest = { - command: string, - source_account: string, - destination_amount: RippledAmount, - destination_account: string, - source_amount?: RippledAmount, - source_currencies?: Array -} - -export type RippledPathsResponse = { - alternatives: Array<{ - paths_computed: Array>, - source_amount: RippledAmount - }>, - type: string, - destination_account: string, - destination_amount: RippledAmount, - destination_currencies?: Array, - source_account?: string, - source_currencies?: Array<{currency: string}>, - full_reply?: boolean -} +/* @flow */ +'use strict'; + +import type {Amount, LaxLaxAmount, RippledAmount, Adjustment, MaxAdjustment, + MinAdjustment} from '../common/types.js'; + + +type Path = { + source: Adjustment | MaxAdjustment, + destination: Adjustment | MinAdjustment, + paths: string +} + +export type GetPaths = Array + +export type PathFind = { + source: { + address: string, + amount?: Amount, + currencies?: Array<{currency: string, counterparty?:string}> + }, + destination: { + address: string, + amount: LaxLaxAmount + } +} + +export type PathFindRequest = { + command: string, + source_account: string, + destination_amount: RippledAmount, + destination_account: string, + source_currencies?: Array, + send_max?: RippledAmount +} + +export type RippledPathsResponse = { + alternatives: Array<{ + paths_computed: Array>, + source_amount: RippledAmount + }>, + type: string, + destination_account: string, + destination_amount: RippledAmount, + destination_currencies?: Array, + source_account?: string, + source_currencies?: Array<{currency: string}>, + full_reply?: boolean +} diff --git a/src/ledger/pathfind.js b/src/ledger/pathfind.js index 1d1f93ede4..e633ab6828 100644 --- a/src/ledger/pathfind.js +++ b/src/ledger/pathfind.js @@ -46,9 +46,9 @@ function requestPathFind(connection: Connection, pathfind: PathFind): Promise { throw new ValidationError('Cannot specify both source.amount' + ' and destination.amount.value in getPaths'); } - request.source_amount = toRippledAmount(pathfind.source.amount); - if (request.source_amount.currency && !request.source_amount.issuer) { - request.source_amount.issuer = pathfind.source.address; + request.send_max = toRippledAmount(pathfind.source.amount); + if (request.send_max.currency && !request.send_max.issuer) { + request.send_max.issuer = pathfind.source.address; } } diff --git a/test/integration/integration-test.js b/test/integration/integration-test.js index 605cc534b3..35cf45a7e0 100644 --- a/test/integration/integration-test.js +++ b/test/integration/integration-test.js @@ -289,6 +289,21 @@ describe('integration tests', function() { }); }); + it('getPaths - send all', function() { + const pathfind = requests.getPaths.sendAll; + return this.api.getPaths(pathfind).then(data => { + assert(data && data.length > 0); + assert(_.every(data, path => { + return parseFloat(path.source.amount.value) + <= parseFloat(pathfind.source.amount.value); + })); + const path = data[0]; + assert(path && path.source); + assert.strictEqual(path.source.address, pathfind.source.address); + assert(path.paths && path.paths.length > 0); + }); + }); + it('generateWallet', function() { const newWallet = this.api.generateAddress();