From d71ddc08e0a9c8be54a7dfa679e5a8cc9f9bb95a Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Fri, 16 Sep 2022 22:31:37 +0200 Subject: [PATCH] make more channels and set `accept-amp` for AMP payments in integration tests --- docker-compose.yml | 2 ++ lnd/setup/alice.conf | 2 ++ lnd/setup/bob.conf | 2 ++ lnd/setup/carol.conf | 2 ++ lnd/setup/dave.conf | 2 ++ lnd/setup/index.js | 59 ++++++++++++++++++++--------------- lnd/setup/nodes/nodes.js | 7 +++++ lnd/setup/nodes/proxynodes.js | 7 +++++ relay/dave-db.json | 3 +- 9 files changed, 59 insertions(+), 27 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 59f1c79c..9ff1c980 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,8 @@ services: entrypoint: ["node", "/lndsetup/index.js"] volumes: - ./lnd/alice/.lnd:/alice/.lnd + - ./lnd/bob/.lnd:/bob/.lnd + - ./lnd/carol/.lnd:/carol/.lnd - ./lnd/setup:/lndsetup - ./lnd/setup/nodes/nodes.js:/lndsetup/nodes.js diff --git a/lnd/setup/alice.conf b/lnd/setup/alice.conf index 0cbb887b..4bfb1dc5 100644 --- a/lnd/setup/alice.conf +++ b/lnd/setup/alice.conf @@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10009 restlisten=0.0.0.0:38881 tlsextradomain=alice-lnd.sphinx accept-keysend=true +accept-amp=true +maxpendingchannels=69 alias=alice-lnd bitcoin.node=bitcoind bitcoin.defaultchanconfs=2 diff --git a/lnd/setup/bob.conf b/lnd/setup/bob.conf index 04a6fd89..ebbb60b2 100644 --- a/lnd/setup/bob.conf +++ b/lnd/setup/bob.conf @@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10010 restlisten=0.0.0.0:38882 tlsextradomain=bob-lnd.sphinx accept-keysend=true +accept-amp=true +maxpendingchannels=69 alias=bob-lnd bitcoin.node=bitcoind bitcoin.defaultchanconfs=2 diff --git a/lnd/setup/carol.conf b/lnd/setup/carol.conf index 1dd62ad0..9f6c5667 100644 --- a/lnd/setup/carol.conf +++ b/lnd/setup/carol.conf @@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10011 restlisten=0.0.0.0:38883 tlsextradomain=carol-lnd.sphinx accept-keysend=true +accept-amp=false +maxpendingchannels=69 alias=carol-lnd bitcoin.node=bitcoind bitcoin.defaultchanconfs=2 diff --git a/lnd/setup/dave.conf b/lnd/setup/dave.conf index 47b557a3..02601160 100644 --- a/lnd/setup/dave.conf +++ b/lnd/setup/dave.conf @@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10012 restlisten=0.0.0.0:38884 tlsextradomain=dave-lnd.sphinx accept-keysend=true +accept-amp=true +maxpendingchannels=69 alias=dave-lnd bitcoin.node=bitcoind bitcoin.defaultchanconfs=2 diff --git a/lnd/setup/index.js b/lnd/setup/index.js index 76210553..3ae9681c 100644 --- a/lnd/setup/index.js +++ b/lnd/setup/index.js @@ -24,28 +24,17 @@ async function createOrUnlockWallet(node) { } } -async function coinsAndChannels(node) { - try { - const coins_success = await coins(node); - if (coins_success) { - await channels(node); - } - } catch (e) { - console.log("=> err", e); - } -} - async function coins(node) { try { const balres = await lightning.getBalance(node); const confirmed = parseInt(balres.confirmed_balance); - console.log("=> ALICE confirmed balance:", confirmed); + console.log(`=> ${node.alias} confirmed balance:`, confirmed); if (!confirmed) { const ares = await lightning.newAddress(node); const addy = ares.address; - console.log("=> ALICE address", addy); + console.log(`=> ${node.alias} address`, addy); await bitcoind.mine(101, addy); - console.log("=> 101 blocks mined to alice!", addy); + console.log(`=> 101 blocks mined to ${node.alias}!`); await sleep(5000); } return true; @@ -73,8 +62,10 @@ async function channels(node) { await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr"); console.log("=> 6 blocked mined to Alice!"); await sleep(20000) - if (!channels.length) { - console.log("=> alice opening channels..."); + if (channels.length) { + console.log(`=> ${node.alias} already has open channels`); + } else { + console.log(`=> ${node.alias} opening ${peersToMake.length} channels...`); // open channels here await asyncForEach(peersToMake, async (p) => { await lightning.openChannel(node, { @@ -83,12 +74,17 @@ async function channels(node) { push_amount: 1000000, }); }); - await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr"); - console.log("=> 6 blocked mined to Alice!"); } await sleep(4000); - const chans2 = await lightning.listChannels(node); - console.log("FINAL CHANS", chans2.channels); + } catch (e) { + console.log("=> err:", e); + } +} + +async function logChannels(node) { + try { + const chans = await lightning.listChannels(node); + console.log(`${node.alias} channels:`, chans.channels); } catch (e) { console.log("=> err:", e); } @@ -96,12 +92,21 @@ async function channels(node) { async function unlockAll() { await sleep(3500); - // createOrUnlockWallet(nodes.nodes.alice); - await asyncForEach(Object.values(nodes.nodes), async (node) => { - await createOrUnlockWallet(node); - }); + + await forEachNode(createOrUnlockWallet); + await sleep(5000); - await coinsAndChannels(nodes.nodes.alice); + + await forEachNode(coins); + + await forEachNode(channels); + + await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr"); + console.log("=> mined 6 blocks to confirm channels"); + + await sleep(2500); + + await forEachNode(logChannels); } unlockAll(); @@ -110,6 +115,10 @@ async function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } +async function forEachNode(callback) { + await asyncForEach(Object.values(nodes.nodes), callback); +} + async function asyncForEach(array, callback) { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); diff --git a/lnd/setup/nodes/nodes.js b/lnd/setup/nodes/nodes.js index 5827db26..36422a6b 100644 --- a/lnd/setup/nodes/nodes.js +++ b/lnd/setup/nodes/nodes.js @@ -50,6 +50,13 @@ const nodes = { hostname: "bob-lnd.sphinx:38882", password: "bob12345", macaroon: "/bob/" + macpath, + channels: [ + { + host: "carol-lnd.sphinx:9735", + pubkey: + "0364c05cbcbb9612036cc66297445a88bcfc21941fd816e17a56b54b0b52ff02b9", + }, + ], mnemonic: [ "above", "street", diff --git a/lnd/setup/nodes/proxynodes.js b/lnd/setup/nodes/proxynodes.js index 6730b863..5ac79cfc 100644 --- a/lnd/setup/nodes/proxynodes.js +++ b/lnd/setup/nodes/proxynodes.js @@ -55,6 +55,13 @@ const nodes = { hostname: "bob-lnd.sphinx:38882", password: "bob12345", macaroon: "/bob/" + macpath, + channels: [ + { + host: "carol-lnd.sphinx:9735", + pubkey: + "0364c05cbcbb9612036cc66297445a88bcfc21941fd816e17a56b54b0b52ff02b9", + }, + ], mnemonic: [ "above", "street", diff --git a/relay/dave-db.json b/relay/dave-db.json index d1344f77..884cb094 100644 --- a/relay/dave-db.json +++ b/relay/dave-db.json @@ -2,8 +2,7 @@ "development": { "dialect": "sqlite", "storage": "./configs/db/dave.db" - } - , + }, "gitactionenv": { "dialect": "sqlite" }