Last active
November 30, 2018 18:59
-
-
Save karzak/351882b5cf265893ff46e0cc83bcc825 to your computer and use it in GitHub Desktop.
Multiple Connector Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Connector = require('ilp-connector') | |
const getPort = require('get-port') | |
const fetch = require('node-fetch') | |
const faucetUrl = 'https://faucet.altnet.rippletest.net/accounts' | |
const xrpServer = 'wss://s.altnet.rippletest.net:51233' | |
async function run () { | |
async function getXrpAccount () { | |
const res = await fetch(faucetUrl, { | |
method: 'POST' | |
}) | |
const json = await res.json() | |
return json.account | |
} | |
console.log('retreiving port for connectorB') | |
const portB = await getPort() | |
console.log('retreiving xrp account for connectorB') | |
const accountB = await getXrpAccount() | |
console.log('constructing connectorB') | |
const connectorB = Connector.createApp({ | |
spread: 0, | |
backend: 'one-to-one', | |
store: 'ilp-store-memory', | |
initialConnectTimeout: 60000, | |
ilpAddress: 'test.asym', | |
accounts: { | |
children: { | |
relation: 'child', | |
plugin: 'ilp-plugin-xrp-asym-server', | |
assetCode: 'XRP', | |
assetScale: 6, | |
maxPacketAmount: '1000', | |
options: { | |
port: portB, | |
prefix: 'private.asym.children', | |
xrpServer, | |
maxPacketAmount: '1000', | |
...accountB | |
} | |
} | |
} | |
}) | |
console.log('retreiving port for connectorA') | |
const portA = await getPort() | |
console.log('retreiving xrp account for connectorA') | |
const accountA = await getXrpAccount() | |
console.log('constructing connectorA') | |
const connectorA = Connector.createApp({ | |
spread: 0, | |
backend: 'one-to-one', | |
store: 'ilp-store-memory', | |
initialConnectTimeout: 60000, | |
accounts: { | |
parent: { | |
relation: 'parent', | |
plugin: 'ilp-plugin-xrp-asym-client', | |
assetCode: 'XRP', | |
assetScale: 6, | |
maxPacketAmount: '1000', | |
balance: { | |
minimum: '-Infinity', | |
maximum: '20000', | |
settleThreshold: '5000', | |
settleTo: '10000' | |
}, | |
sendRoutes: false, | |
receiveRoutes: false, | |
options: { | |
server: `btp+ws://userA:secretA@localhost:${portB}`, | |
xrpServer, | |
...accountA | |
} | |
}, | |
local: { | |
relation: 'child', | |
plugin: 'ilp-plugin-mini-accounts', | |
assetCode: 'XRP', | |
assetScale: 6, | |
options: { | |
wsOpts: { port: portA } | |
} | |
} | |
} | |
}) | |
} | |
run() | |
.catch(e => { | |
console.error(e) | |
process.exit(1) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"get-port": "^4.0.0", | |
"ilp-connector": "^22.1.3", | |
"node-fetch": "^2.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment