Skip to content

Commit ccf5435

Browse files
committed
make more channels and set accept-amp for AMP payments in integration tests
1 parent 6e75f7e commit ccf5435

File tree

8 files changed

+52
-27
lines changed

8 files changed

+52
-27
lines changed

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ services:
5959
entrypoint: ["node", "/lndsetup/index.js"]
6060
volumes:
6161
- ./lnd/alice/.lnd:/alice/.lnd
62+
- ./lnd/bob/.lnd:/bob/.lnd
63+
- ./lnd/carol/.lnd:/carol/.lnd
6264
- ./lnd/setup:/lndsetup
6365
- ./lnd/setup/nodes/nodes.js:/lndsetup/nodes.js
6466

lnd/setup/alice.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10009
55
restlisten=0.0.0.0:38881
66
tlsextradomain=alice-lnd.sphinx
77
accept-keysend=true
8+
accept-amp=true
9+
maxpendingchannels=69
810
alias=alice-lnd
911
bitcoin.node=bitcoind
1012
bitcoin.defaultchanconfs=2

lnd/setup/bob.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10010
55
restlisten=0.0.0.0:38882
66
tlsextradomain=bob-lnd.sphinx
77
accept-keysend=true
8+
accept-amp=true
9+
maxpendingchannels=69
810
alias=bob-lnd
911
bitcoin.node=bitcoind
1012
bitcoin.defaultchanconfs=2

lnd/setup/carol.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10011
55
restlisten=0.0.0.0:38883
66
tlsextradomain=carol-lnd.sphinx
77
accept-keysend=true
8+
accept-amp=false
9+
maxpendingchannels=69
810
alias=carol-lnd
911
bitcoin.node=bitcoind
1012
bitcoin.defaultchanconfs=2

lnd/setup/dave.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rpclisten=0.0.0.0:10012
55
restlisten=0.0.0.0:38884
66
tlsextradomain=dave-lnd.sphinx
77
accept-keysend=true
8+
accept-amp=true
9+
maxpendingchannels=69
810
alias=dave-lnd
911
bitcoin.node=bitcoind
1012
bitcoin.defaultchanconfs=2

lnd/setup/index.js

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,17 @@ async function createOrUnlockWallet(node) {
2424
}
2525
}
2626

27-
async function coinsAndChannels(node) {
28-
try {
29-
const coins_success = await coins(node);
30-
if (coins_success) {
31-
await channels(node);
32-
}
33-
} catch (e) {
34-
console.log("=> err", e);
35-
}
36-
}
37-
3827
async function coins(node) {
3928
try {
4029
const balres = await lightning.getBalance(node);
4130
const confirmed = parseInt(balres.confirmed_balance);
42-
console.log("=> ALICE confirmed balance:", confirmed);
31+
console.log(`=> ${node.alias} confirmed balance:`, confirmed);
4332
if (!confirmed) {
4433
const ares = await lightning.newAddress(node);
4534
const addy = ares.address;
46-
console.log("=> ALICE address", addy);
35+
console.log(`=> ${node.alias} address`, addy);
4736
await bitcoind.mine(101, addy);
48-
console.log("=> 101 blocks mined to alice!", addy);
37+
console.log(`=> 101 blocks mined to ${node.alias}!`);
4938
await sleep(5000);
5039
}
5140
return true;
@@ -73,8 +62,10 @@ async function channels(node) {
7362
await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr");
7463
console.log("=> 6 blocked mined to Alice!");
7564
await sleep(20000)
76-
if (!channels.length) {
77-
console.log("=> alice opening channels...");
65+
if (channels.length) {
66+
console.log(`=> ${node.alias} already has open channels`);
67+
} else {
68+
console.log(`=> ${node.alias} opening ${peersToMake.length} channels...`);
7869
// open channels here
7970
await asyncForEach(peersToMake, async (p) => {
8071
await lightning.openChannel(node, {
@@ -83,25 +74,39 @@ async function channels(node) {
8374
push_amount: 1000000,
8475
});
8576
});
86-
await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr");
87-
console.log("=> 6 blocked mined to Alice!");
8877
}
8978
await sleep(4000);
90-
const chans2 = await lightning.listChannels(node);
91-
console.log("FINAL CHANS", chans2.channels);
79+
} catch (e) {
80+
console.log("=> err:", e);
81+
}
82+
}
83+
84+
async function logChannels(node) {
85+
try {
86+
const chans = await lightning.listChannels(node);
87+
console.log(`${node.alias} channels:`, chans.channels);
9288
} catch (e) {
9389
console.log("=> err:", e);
9490
}
9591
}
9692

9793
async function unlockAll() {
9894
await sleep(3500);
99-
// createOrUnlockWallet(nodes.nodes.alice);
100-
await asyncForEach(Object.values(nodes.nodes), async (node) => {
101-
await createOrUnlockWallet(node);
102-
});
95+
96+
await forEachNode(createOrUnlockWallet);
97+
10398
await sleep(5000);
104-
await coinsAndChannels(nodes.nodes.alice);
99+
100+
await forEachNode(coins);
101+
102+
await forEachNode(channels);
103+
104+
await bitcoind.mine(6, "bcrt1qsrq4qj4zgwyj8hpsnpgeeh0p0aqfe5vqhv7yrr");
105+
console.log("=> mined 6 blocks to confirm channels");
106+
107+
await sleep(2500);
108+
109+
await forEachNode(logChannels);
105110
}
106111

107112
unlockAll();
@@ -110,6 +115,10 @@ async function sleep(ms) {
110115
return new Promise((resolve) => setTimeout(resolve, ms));
111116
}
112117

118+
async function forEachNode(callback) {
119+
await asyncForEach(Object.values(nodes.nodes), callback);
120+
}
121+
113122
async function asyncForEach(array, callback) {
114123
for (let index = 0; index < array.length; index++) {
115124
await callback(array[index], index, array);

lnd/setup/nodes/nodes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ const nodes = {
5050
hostname: "bob-lnd.sphinx:38882",
5151
password: "bob12345",
5252
macaroon: "/bob/" + macpath,
53+
channels: [
54+
{
55+
host: "carol-lnd.sphinx:9735",
56+
pubkey:
57+
"0364c05cbcbb9612036cc66297445a88bcfc21941fd816e17a56b54b0b52ff02b9",
58+
},
59+
],
5360
mnemonic: [
5461
"above",
5562
"street",

relay/dave-db.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"development": {
33
"dialect": "sqlite",
44
"storage": "./configs/db/dave.db"
5-
}
6-
,
5+
},
76
"gitactionenv": {
87
"dialect": "sqlite"
98
}

0 commit comments

Comments
 (0)