mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
Fix getPaths (#930)
* getPaths: * Filter paths correctly * Use correct value when XRP is the destination currency
This commit is contained in:
@@ -485,7 +485,57 @@ module.exports = function createMockRippled(port) {
|
||||
if (request.subcommand === 'close') { // for path_find command
|
||||
return;
|
||||
}
|
||||
if (request.source_account === addresses.NOTFOUND) {
|
||||
if (request.source_account === 'rB2NTuTTS3eNCsWxZYzJ4wqRqxNLZqA9Vx') {
|
||||
// getPaths - result path has source_amount in drops
|
||||
response = createResponse(request, {
|
||||
"id": 0,
|
||||
"type": "response",
|
||||
"status": "success",
|
||||
"result": {
|
||||
"alternatives": [
|
||||
{
|
||||
"destination_amount": {
|
||||
"currency": "EUR",
|
||||
"issuer": "rGpGaj4sxEZGenW1prqER25EUi7x4fqK9u",
|
||||
"value": "1"
|
||||
},
|
||||
"paths_canonical": [],
|
||||
"paths_computed": [
|
||||
[
|
||||
{
|
||||
"currency": "USD",
|
||||
"issuer": "rGpGaj4sxEZGenW1prqER25EUi7x4fqK9u",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
},
|
||||
{
|
||||
"currency": "EUR",
|
||||
"issuer": "rGpGaj4sxEZGenW1prqER25EUi7x4fqK9u",
|
||||
"type": 48,
|
||||
"type_hex": "0000000000000030"
|
||||
}
|
||||
]
|
||||
],
|
||||
"source_amount": "1000000"
|
||||
}
|
||||
],
|
||||
"destination_account": "rhpJkBfZGQyT1xeDbwtKEuSrSXw3QZSAy5",
|
||||
"destination_amount": {
|
||||
"currency": "EUR",
|
||||
"issuer": "rGpGaj4sxEZGenW1prqER25EUi7x4fqK9u",
|
||||
"value": "-1"
|
||||
},
|
||||
"destination_currencies": [
|
||||
"EUR",
|
||||
"XRP"
|
||||
],
|
||||
"full_reply": true,
|
||||
"id": 2,
|
||||
"source_account": "rB2NTuTTS3eNCsWxZYzJ4wqRqxNLZqA9Vx",
|
||||
"status": "success"
|
||||
}
|
||||
})
|
||||
} else if (request.source_account === addresses.NOTFOUND) {
|
||||
response = createResponse(request, fixtures.path_find.srcActNotFound);
|
||||
} else if (request.source_account === addresses.SOURCE_LOW_FUNDS) {
|
||||
response = createResponse(request, fixtures.path_find.sourceAmountLow);
|
||||
@@ -497,8 +547,9 @@ module.exports = function createMockRippled(port) {
|
||||
destination_address: request.destination_address
|
||||
});
|
||||
} else if (request.source_account === addresses.ACCOUNT) {
|
||||
if (request.destination_account ===
|
||||
'ra5nK24KXen9AHvsdFTKHSANinZseWnPcX') {
|
||||
if (request.destination_account === 'ra5nK24KXen9AHvsdFTKHSANinZseWnPcX' &&
|
||||
// Important: Ensure that destination_amount.value is correct
|
||||
request.destination_amount.value === "-1") {
|
||||
response = createResponse(request, fixtures.path_find.sendAll);
|
||||
} else {
|
||||
response = fixtures.path_find.generate.generateIOUPaymentPaths(
|
||||
|
||||
Reference in New Issue
Block a user