mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-28 08:05:51 +00:00
Use streaming pathfinding: rippled path_find instead of ripple_path_find
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"source": {
|
||||
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J"
|
||||
},
|
||||
"destination": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"amount": {
|
||||
"value": "1000002",
|
||||
"currency": "XRP"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"source": {
|
||||
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J"
|
||||
},
|
||||
"destination": {
|
||||
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"amount": {
|
||||
"value": "1000002",
|
||||
"currency": "XRP"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
"currency": "XRP"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
test/fixtures/api/rippled/index.js
vendored
8
test/fixtures/api/rippled/index.js
vendored
@@ -16,10 +16,10 @@ module.exports = {
|
||||
book_offers: require('./book-offers'),
|
||||
server_info: require('./server-info'),
|
||||
server_info_error: require('./server-info-error'),
|
||||
ripple_path_find: {
|
||||
generate: require('./ripple-path-find'),
|
||||
sendUSD: require('./ripple-path-find-send-usd'),
|
||||
XrpToXrp: require('./ripple-path-find-xrp-to-xrp')
|
||||
path_find: {
|
||||
generate: require('./path-find'),
|
||||
sendUSD: require('./path-find-send-usd'),
|
||||
XrpToXrp: require('./path-find-xrp-to-xrp')
|
||||
},
|
||||
tx: {
|
||||
Payment: require('./tx/payment.json'),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"id": 0,
|
||||
"result": {
|
||||
"full_reply": true,
|
||||
"alternatives": [
|
||||
{
|
||||
"paths_canonical": [],
|
||||
@@ -72,6 +73,12 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"source_account": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
||||
"destination_amount": {
|
||||
"currency": "USD",
|
||||
"value": "0.000001",
|
||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
||||
},
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_currencies": [
|
||||
"JOE",
|
||||
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"id": 1,
|
||||
"result": {
|
||||
"full_reply": true,
|
||||
"alternatives": [],
|
||||
"source_account": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
|
||||
"destination_amount": "2",
|
||||
"destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
||||
"destination_currencies": [
|
||||
"JOE",
|
||||
@@ -7,6 +7,9 @@ function(request_id, sendingAccount, destinationAccount, destinationAmount) {
|
||||
'status': 'success',
|
||||
'type': 'response',
|
||||
'result': {
|
||||
'full_reply': true,
|
||||
'source_account': sendingAccount,
|
||||
'destination_amount': destinationAmount,
|
||||
'alternatives': [
|
||||
{
|
||||
'paths_canonical': [],
|
||||
@@ -308,6 +311,7 @@ function(request_id, sendingAccount, destinationAccount) {
|
||||
'status': 'success',
|
||||
'type': 'response',
|
||||
'result': {
|
||||
'full_reply': true,
|
||||
'alternatives': [
|
||||
{
|
||||
'paths_canonical': [],
|
||||
@@ -17,8 +17,11 @@ function isBTC(json) {
|
||||
return json === 'BTC' || json === '0000000000000000000000004254430000000000';
|
||||
}
|
||||
|
||||
function createResponse(request, response) {
|
||||
return JSON.stringify(_.assign({}, response, {id: request.id}));
|
||||
function createResponse(request, response, overrides={}) {
|
||||
const result = _.assign({}, response.result, overrides);
|
||||
const change = response.result && !_.isEmpty(overrides) ?
|
||||
{id: request.id, result: result} : {id: request.id};
|
||||
return JSON.stringify(_.assign({}, response, change));
|
||||
}
|
||||
|
||||
module.exports = function(port) {
|
||||
@@ -216,14 +219,20 @@ module.exports = function(port) {
|
||||
}
|
||||
});
|
||||
|
||||
mock.on('request_ripple_path_find', function(request, conn) {
|
||||
mock.on('request_path_find', function(request, conn) {
|
||||
let response = null;
|
||||
if (request.subcommand === 'close') {
|
||||
return;
|
||||
}
|
||||
if (request.source_account === addresses.OTHER_ACCOUNT) {
|
||||
response = createResponse(request, fixtures.ripple_path_find.sendUSD);
|
||||
response = createResponse(request, fixtures.path_find.sendUSD);
|
||||
} else if (request.source_account === addresses.THIRD_ACCOUNT) {
|
||||
response = createResponse(request, fixtures.ripple_path_find.XrpToXrp);
|
||||
response = createResponse(request, fixtures.path_find.XrpToXrp, {
|
||||
destination_amount: request.destination_amount,
|
||||
destination_address: request.destination_address
|
||||
});
|
||||
} else {
|
||||
response = fixtures.ripple_path_find.generate.generateIOUPaymentPaths(
|
||||
response = fixtures.path_find.generate.generateIOUPaymentPaths(
|
||||
request.id, request.source_account, request.destination_account,
|
||||
request.destination_amount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user