ln-service 57.1.0 → 57.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/package.json +5 -4
- package/test/chainrpc-integration/test_subscribe_to_blocks.js +12 -0
- package/test/integration/test_add_peer.js +3 -1
- package/test/integration/test_decode_payment_request.js +16 -1
- package/test/integration/test_delete_pending_channel.js +23 -4
- package/test/integration/test_get_chain_transactions.js +20 -22
- package/test/integration/test_get_invoices.js +17 -2
- package/test/integration/test_get_node.js +19 -7
- package/test/integration/test_get_peers.js +3 -1
- package/test/integration/test_pay_private_invoice.js +15 -0
- package/test/integration/test_propose_channel.js +2 -0
- package/test/integration/test_remove_peer.js +3 -1
- package/test/integration/test_send_message_to_peer.js +3 -1
- package/test/integration/test_subscribe_to_peer_messages.js +11 -5
- package/test/integration/test_subscribe_to_peers.js +2 -0
- package/test/integration/test_subscribe_to_rpc_requests.js +12 -1
- package/test/integration/test_trusted_funding.js +32 -12
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +10 -0
- package/test/routerrpc-integration/test_get_payment.js +14 -0
- package/test/routerrpc-integration/test_get_route_confidence.js +14 -0
- package/test/routerrpc-integration/test_pay_via_payment_request.js +13 -0
- package/test/routerrpc-integration/test_probe_for_route.js +12 -0
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +14 -1
- package/test/routerrpc-integration/test_subscribe_to_past_payments.js +19 -6
- package/test/routerrpc-integration/test_subscribe_to_payments.js +15 -1
- package/test/tower_clientrpc-integration/test_connect_watchtower.js +15 -1
- package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +15 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"bolt07": "1.8.4",
|
|
11
11
|
"invoices": "3.0.0",
|
|
12
|
-
"lightning": "10.1.
|
|
12
|
+
"lightning": "10.1.3",
|
|
13
13
|
"macaroon": "3.0.4"
|
|
14
14
|
},
|
|
15
15
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@alexbosworth/blockchain": "1.7.0",
|
|
18
18
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
19
|
-
"async": "3.2.
|
|
19
|
+
"async": "3.2.5",
|
|
20
20
|
"asyncjs-util": "1.2.12",
|
|
21
21
|
"bip32": "4.0.0",
|
|
22
22
|
"bip66": "1.1.5",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bn.js": "5.2.1",
|
|
25
25
|
"bs58check": "3.0.1",
|
|
26
26
|
"ecpair": "2.1.0",
|
|
27
|
-
"ln-docker-daemons": "6.0.
|
|
27
|
+
"ln-docker-daemons": "6.0.5",
|
|
28
28
|
"p2tr": "2.0.0",
|
|
29
29
|
"portfinder": "1.0.32",
|
|
30
30
|
"psbt": "3.0.0",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"url": "https://github.com/alexbosworth/ln-service.git"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
+
"integration-test-0.17.1": "DOCKER_LND_VERSION=v0.17.1-beta npm run test",
|
|
55
56
|
"integration-test-0.17.0": "DOCKER_LND_VERSION=v0.17.0-beta npm run test",
|
|
56
57
|
"integration-test-0.16.4": "DOCKER_LND_VERSION=v0.16.4-beta npm run test",
|
|
57
58
|
"integration-test-0.16.3": "DOCKER_LND_VERSION=v0.16.3-beta npm run test",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
67
68
|
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
68
69
|
},
|
|
69
|
-
"version": "57.1.
|
|
70
|
+
"version": "57.1.2"
|
|
70
71
|
}
|
|
@@ -11,6 +11,7 @@ const {delay} = require('./../macros');
|
|
|
11
11
|
const {generateBlocks} = require('./../macros');
|
|
12
12
|
const {getHeight} = require('./../../');
|
|
13
13
|
const {getChainBalance} = require('./../../');
|
|
14
|
+
const {getWalletInfo} = require('./../../');
|
|
14
15
|
const {subscribeToBlocks} = require('./../../');
|
|
15
16
|
const {waitForTermination} = require('./../macros');
|
|
16
17
|
|
|
@@ -26,6 +27,17 @@ test(`Subscribe to blocks`, async () => {
|
|
|
26
27
|
|
|
27
28
|
const [{generate, lnd}] = nodes;
|
|
28
29
|
|
|
30
|
+
// Try to make sure that the chain notifier RPC is ready
|
|
31
|
+
await asyncRetry({interval, times}, async () => {
|
|
32
|
+
const wallet = await getWalletInfo({lnd});
|
|
33
|
+
|
|
34
|
+
await generate({});
|
|
35
|
+
|
|
36
|
+
if (!wallet.is_synced_to_chain) {
|
|
37
|
+
throw new Error('NotSyncedToChain');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
29
41
|
const gotHeight = await asyncRetry({interval, times}, async () => {
|
|
30
42
|
const subBlocks = subscribeToBlocks({lnd});
|
|
31
43
|
|
|
@@ -17,7 +17,7 @@ const timeout = 100;
|
|
|
17
17
|
test(`Add a peer`, async () => {
|
|
18
18
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
19
19
|
|
|
20
|
-
const [{lnd}, target] = nodes;
|
|
20
|
+
const [{generate, lnd}, target] = nodes;
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
23
|
const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
|
|
@@ -29,6 +29,8 @@ test(`Add a peer`, async () => {
|
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
await asyncRetry({interval, times}, async () => {
|
|
32
|
+
await generate({});
|
|
33
|
+
|
|
32
34
|
await addPeer({
|
|
33
35
|
lnd,
|
|
34
36
|
timeout,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
const {strictEqual} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
4
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
5
6
|
|
|
6
7
|
const {createInvoice} = require('./../../');
|
|
7
8
|
const {decodePaymentRequest} = require('./../../');
|
|
8
9
|
const {getIdentity} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
11
|
+
|
|
12
|
+
const interval = 50;
|
|
13
|
+
const times = 4000;
|
|
9
14
|
|
|
10
15
|
const tests = [
|
|
11
16
|
{
|
|
@@ -24,7 +29,17 @@ const tests = [
|
|
|
24
29
|
|
|
25
30
|
tests.forEach(({description, expected}) => {
|
|
26
31
|
return test(description, async () => {
|
|
27
|
-
const [{kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
32
|
+
const [{generate, kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
33
|
+
|
|
34
|
+
await asyncRetry({interval, times}, async () => {
|
|
35
|
+
const wallet = await getWalletInfo({lnd});
|
|
36
|
+
|
|
37
|
+
await generate({});
|
|
38
|
+
|
|
39
|
+
if (!wallet.is_synced_to_chain) {
|
|
40
|
+
throw new Error('NotSyncedToChain');
|
|
41
|
+
}
|
|
42
|
+
});
|
|
28
43
|
|
|
29
44
|
try {
|
|
30
45
|
const {request} = await createInvoice({
|
|
@@ -19,6 +19,7 @@ const {getChannels} = require('./../../');
|
|
|
19
19
|
const {getLockedUtxos} = require('./../../');
|
|
20
20
|
const {getMasterPublicKeys} = require('./../../');
|
|
21
21
|
const {getPendingChannels} = require('./../../');
|
|
22
|
+
const {getWalletInfo} = require('./../../');
|
|
22
23
|
const {openChannels} = require('./../../');
|
|
23
24
|
const {signPsbt} = require('./../../');
|
|
24
25
|
const {unlockUtxo} = require('./../../');
|
|
@@ -39,10 +40,18 @@ test(`Forfeit pending channel`, async t => {
|
|
|
39
40
|
|
|
40
41
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
41
42
|
|
|
42
|
-
t.after(async () => await kill({}));
|
|
43
|
-
|
|
44
43
|
const [{generate, lnd}, target, remote] = nodes;
|
|
45
44
|
|
|
45
|
+
await asyncRetry({interval, times}, async () => {
|
|
46
|
+
const wallet = await getWalletInfo({lnd});
|
|
47
|
+
|
|
48
|
+
await generate({});
|
|
49
|
+
|
|
50
|
+
if (!wallet.is_synced_to_chain) {
|
|
51
|
+
throw new Error('NotSyncedToChain');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
46
55
|
await generate({count});
|
|
47
56
|
|
|
48
57
|
await asyncEach([target, remote], async node => {
|
|
@@ -63,7 +72,15 @@ test(`Forfeit pending channel`, async t => {
|
|
|
63
72
|
lnd,
|
|
64
73
|
is_avoiding_broadcast: true,
|
|
65
74
|
},
|
|
66
|
-
|
|
75
|
+
async (err, res) => {
|
|
76
|
+
await generate({});
|
|
77
|
+
|
|
78
|
+
await asyncEach([target, remote], async node => {
|
|
79
|
+
return await addPeer({lnd, public_key: node.id, socket: node.socket});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return cbk(err, res)
|
|
83
|
+
});
|
|
67
84
|
});
|
|
68
85
|
|
|
69
86
|
// Setup funding for the target
|
|
@@ -120,7 +137,7 @@ test(`Forfeit pending channel`, async t => {
|
|
|
120
137
|
funding: signRemote.psbt,
|
|
121
138
|
});
|
|
122
139
|
|
|
123
|
-
await delay(
|
|
140
|
+
await delay(2000);
|
|
124
141
|
|
|
125
142
|
const {transaction} = extractTransaction({ecp, psbt: signRemote.psbt});
|
|
126
143
|
|
|
@@ -179,5 +196,7 @@ test(`Forfeit pending channel`, async t => {
|
|
|
179
196
|
deepEqual(err, [501, 'DeletePendingChannelMethodNotSupported']);
|
|
180
197
|
}
|
|
181
198
|
|
|
199
|
+
await kill({});
|
|
200
|
+
|
|
182
201
|
return;
|
|
183
202
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {equal} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
4
|
const asyncRetry = require('async/retry');
|
|
@@ -28,6 +28,8 @@ test(`Get chain transactions`, async () => {
|
|
|
28
28
|
throw new Error('ExpectedWalletSyncedToChain');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
await generate({});
|
|
32
|
+
|
|
31
33
|
if (wallet.current_block_height < count + 1) {
|
|
32
34
|
throw new Error('ExpectedFullySyncedToChain');
|
|
33
35
|
}
|
|
@@ -48,37 +50,33 @@ test(`Get chain transactions`, async () => {
|
|
|
48
50
|
|
|
49
51
|
const {transactions} = await getChainTransactions({lnd});
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
equal(transactions.length > 1, true, 'Transaction found');
|
|
52
54
|
|
|
53
55
|
const [tx] = transactions;
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
equal(!!tx.block_id, true, 'Transaction has block id');
|
|
58
|
+
equal(!!tx.confirmation_count, true, 'Transaction confirm count');
|
|
59
|
+
equal(!!tx.confirmation_height, true, 'Transaction confirm height');
|
|
60
|
+
equal(!!tx.created_at, true, 'Transaction record create time');
|
|
61
|
+
equal(tx.description, undefined, 'No tx description');
|
|
62
|
+
equal(tx.fee, undefined, 'No transaction fee');
|
|
63
|
+
equal(!!tx.id, true, 'Transaction id');
|
|
64
|
+
equal(tx.is_confirmed, true, 'Transaction is confirmed');
|
|
65
|
+
equal(tx.is_outgoing, false, 'Transaction is incoming');
|
|
66
|
+
equal(tx.output_addresses.length, 1, 'Tx output address');
|
|
67
|
+
equal(tx.tokens, 5000000000, 'Got coinbase reward tokens');
|
|
68
|
+
equal(!!tx.transaction, true, 'Got transaction hex');
|
|
67
69
|
|
|
68
70
|
const onlyAfter = await getChainTransactions({
|
|
69
71
|
lnd,
|
|
70
72
|
after: tx.confirmation_height,
|
|
71
73
|
});
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const [height] = transactions
|
|
76
|
-
.map(n => n.confirmation_height)
|
|
77
|
-
.sort((a, b) => a - b);
|
|
75
|
+
equal(onlyAfter.transactions.length, [].length, 'No txs after');
|
|
78
76
|
|
|
79
|
-
const onlyBefore = await getChainTransactions({lnd, before:
|
|
77
|
+
const onlyBefore = await getChainTransactions({lnd, before: 2});
|
|
80
78
|
|
|
81
|
-
|
|
79
|
+
equal(onlyBefore.transactions.length < 100, true, 'Got before txs');
|
|
82
80
|
|
|
83
81
|
const between = await getChainTransactions({
|
|
84
82
|
lnd,
|
|
@@ -86,7 +84,7 @@ test(`Get chain transactions`, async () => {
|
|
|
86
84
|
before: tx.confirmation_height + 1,
|
|
87
85
|
});
|
|
88
86
|
|
|
89
|
-
|
|
87
|
+
equal(between.transactions.length, [tx].length, 'One transaction');
|
|
90
88
|
|
|
91
89
|
await kill({});
|
|
92
90
|
|
|
@@ -3,21 +3,36 @@ const {strictEqual} = require('node:assert').strict;
|
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
5
5
|
const asyncEach = require('async/each');
|
|
6
|
+
const asyncRetry = require('async/retry');
|
|
7
|
+
const {getWalletInfo} = require('./../../');
|
|
6
8
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
9
|
|
|
8
10
|
const {cancelHodlInvoice} = require('./../../');
|
|
9
11
|
const {createInvoice} = require('./../../');
|
|
10
12
|
const {getInvoices} = require('./../../');
|
|
11
13
|
|
|
14
|
+
const interval = 1000;
|
|
12
15
|
const limit = 1;
|
|
16
|
+
const times = 1000;
|
|
13
17
|
|
|
14
|
-
//
|
|
15
|
-
test(`
|
|
18
|
+
// Get invoices should result in a list of created invoices
|
|
19
|
+
test(`Get invoices`, async () => {
|
|
16
20
|
const {kill, nodes} = await spawnLightningCluster({});
|
|
17
21
|
|
|
18
22
|
try {
|
|
19
23
|
const [{generate, lnd}] = nodes;
|
|
20
24
|
|
|
25
|
+
// Make sure that target is synced to the chain otherwise invoice can halt
|
|
26
|
+
await asyncRetry({interval, times}, async () => {
|
|
27
|
+
const wallet = await getWalletInfo({lnd});
|
|
28
|
+
|
|
29
|
+
await generate({});
|
|
30
|
+
|
|
31
|
+
if (!wallet.is_synced_to_chain) {
|
|
32
|
+
throw new Error('WaitingForSyncToChain');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
21
36
|
const invoices = [
|
|
22
37
|
await createInvoice({lnd, description: '3'}),
|
|
23
38
|
await createInvoice({lnd, description: '2'}),
|
|
@@ -30,12 +30,20 @@ test(`Get node`, async () => {
|
|
|
30
30
|
const [{generate, id, lnd}, target, remote] = nodes;
|
|
31
31
|
|
|
32
32
|
try {
|
|
33
|
-
const controlToTarget = await
|
|
33
|
+
const controlToTarget = await asyncRetry({interval, times}, async () => {
|
|
34
|
+
await generate({});
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
return await setupChannel({generate, lnd, to: target});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const targetToRemote = await asyncRetry({interval, times}, async () => {
|
|
40
|
+
await target.generate({});
|
|
41
|
+
|
|
42
|
+
return await setupChannel({
|
|
43
|
+
generate: target.generate,
|
|
44
|
+
lnd: target.lnd,
|
|
45
|
+
to: remote,
|
|
46
|
+
});
|
|
39
47
|
});
|
|
40
48
|
|
|
41
49
|
await updateRoutingFees({
|
|
@@ -48,6 +56,8 @@ test(`Get node`, async () => {
|
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
await asyncRetry({interval, times}, async () => {
|
|
59
|
+
await generate({});
|
|
60
|
+
|
|
51
61
|
await addPeer({
|
|
52
62
|
lnd,
|
|
53
63
|
public_key: remote.id,
|
|
@@ -95,11 +105,13 @@ test(`Get node`, async () => {
|
|
|
95
105
|
strictEqual(!!socket.socket, true, 'Ip, port');
|
|
96
106
|
strictEqual(socket.type, 'tcp', 'Socket type');
|
|
97
107
|
strictEqual(node.updated_at.length, 24, 'Update date');
|
|
108
|
+
|
|
109
|
+
await kill({});
|
|
98
110
|
} catch (err) {
|
|
111
|
+
await kill({});
|
|
112
|
+
|
|
99
113
|
strictEqual(err, null, 'Expected no error');
|
|
100
114
|
}
|
|
101
115
|
|
|
102
|
-
await kill({});
|
|
103
|
-
|
|
104
116
|
return;
|
|
105
117
|
});
|
|
@@ -15,10 +15,12 @@ const times = 2000;
|
|
|
15
15
|
test('Get peers', async () => {
|
|
16
16
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
17
17
|
|
|
18
|
-
const [{lnd}, target] = nodes;
|
|
18
|
+
const [{generate, lnd}, target] = nodes;
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
21
|
await asyncRetry({interval, times}, async () => {
|
|
22
|
+
await generate({});
|
|
23
|
+
|
|
22
24
|
await addPeer({
|
|
23
25
|
lnd,
|
|
24
26
|
public_key: target.id,
|
|
@@ -11,6 +11,7 @@ const {decodePaymentRequest} = require('./../../');
|
|
|
11
11
|
const {getChannel} = require('./../../');
|
|
12
12
|
const {getInvoice} = require('./../../');
|
|
13
13
|
const {getRouteToDestination} = require('./../../');
|
|
14
|
+
const {getWalletInfo} = require('./../../');
|
|
14
15
|
const {openChannel} = require('./../../');
|
|
15
16
|
const {parsePaymentRequest} = require('./../../');
|
|
16
17
|
const {pay} = require('./../../');
|
|
@@ -28,6 +29,16 @@ test(`Pay private invoice`, async () => {
|
|
|
28
29
|
try {
|
|
29
30
|
const [{generate, lnd}, target, remote] = nodes;
|
|
30
31
|
|
|
32
|
+
await asyncRetry({interval, times}, async () => {
|
|
33
|
+
const wallet = await getWalletInfo({lnd});
|
|
34
|
+
|
|
35
|
+
await generate({});
|
|
36
|
+
|
|
37
|
+
if (!wallet.is_synced_to_chain) {
|
|
38
|
+
throw new Error('NotSyncedToChain');
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
31
42
|
const channel = await setupChannel({generate, lnd, to: target});
|
|
32
43
|
|
|
33
44
|
const remoteChannel = await setupChannel({
|
|
@@ -38,6 +49,8 @@ test(`Pay private invoice`, async () => {
|
|
|
38
49
|
});
|
|
39
50
|
|
|
40
51
|
const invoice = await asyncRetry({interval, times}, async () => {
|
|
52
|
+
await generate({});
|
|
53
|
+
|
|
41
54
|
const invoice = await createInvoice({
|
|
42
55
|
tokens,
|
|
43
56
|
is_including_private_channels: true,
|
|
@@ -62,6 +75,8 @@ test(`Pay private invoice`, async () => {
|
|
|
62
75
|
const decodedRequest = await decodePaymentRequest({lnd, request});
|
|
63
76
|
|
|
64
77
|
const route = await asyncRetry({interval, times}, async () => {
|
|
78
|
+
await generate({});
|
|
79
|
+
|
|
65
80
|
const {route} = await getRouteToDestination({
|
|
66
81
|
lnd,
|
|
67
82
|
cltv_delta: decodedRequest.cltv_delta,
|
|
@@ -61,6 +61,8 @@ test(`Propose a channel with a coop delay`, async () => {
|
|
|
61
61
|
try {
|
|
62
62
|
// Generate some funds for LND
|
|
63
63
|
await asyncRetry({times}, async () => {
|
|
64
|
+
await generate({});
|
|
65
|
+
|
|
64
66
|
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
65
67
|
|
|
66
68
|
await generate({});
|
|
@@ -16,10 +16,12 @@ const times = 2000;
|
|
|
16
16
|
test(`Remove a peer`, async () => {
|
|
17
17
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
18
18
|
|
|
19
|
-
const [{id, lnd}, target] = nodes;
|
|
19
|
+
const [{generate, id, lnd}, target] = nodes;
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
22
|
await asyncRetry({interval, times}, async () => {
|
|
23
|
+
await generate({});
|
|
24
|
+
|
|
23
25
|
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
24
26
|
});
|
|
25
27
|
|
|
@@ -17,7 +17,7 @@ const times = 2000;
|
|
|
17
17
|
test(`Send peer message`, async () => {
|
|
18
18
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
19
19
|
|
|
20
|
-
const [{id, lnd}, target] = nodes;
|
|
20
|
+
const [{generate, id, lnd}, target] = nodes;
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
23
|
await sendMessageToPeer({
|
|
@@ -38,6 +38,8 @@ test(`Send peer message`, async () => {
|
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
40
|
await asyncRetry({interval, times}, async () => {
|
|
41
|
+
await generate({});
|
|
42
|
+
|
|
41
43
|
await addPeer({
|
|
42
44
|
lnd,
|
|
43
45
|
public_key: target.id,
|
|
@@ -17,10 +17,12 @@ const times = 1000;
|
|
|
17
17
|
test(`Subscribe to peer messages`, async () => {
|
|
18
18
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
19
19
|
|
|
20
|
-
const [{lnd}, target, remote] = nodes;
|
|
20
|
+
const [{generate, lnd}, target, remote] = nodes;
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
23
|
await asyncRetry({interval, times}, async () => {
|
|
24
|
+
await generate({});
|
|
25
|
+
|
|
24
26
|
await addPeer({
|
|
25
27
|
lnd,
|
|
26
28
|
public_key: target.id,
|
|
@@ -28,10 +30,14 @@ test(`Subscribe to peer messages`, async () => {
|
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
await
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
await asyncRetry({interval, times}, async () => {
|
|
34
|
+
await target.generate({});
|
|
35
|
+
|
|
36
|
+
await addPeer({
|
|
37
|
+
lnd: target.lnd,
|
|
38
|
+
public_key: remote.id,
|
|
39
|
+
socket: remote.socket,
|
|
40
|
+
});
|
|
35
41
|
});
|
|
36
42
|
|
|
37
43
|
try {
|
|
@@ -52,7 +52,7 @@ test(`Subscribe to RPC requests`, async () => {
|
|
|
52
52
|
|
|
53
53
|
kills.push(kill);
|
|
54
54
|
|
|
55
|
-
const [{lnd, id: key}] = nodes;
|
|
55
|
+
const [{generate, lnd, id: key}] = nodes;
|
|
56
56
|
|
|
57
57
|
const rpcRequestsSub = (await subscribeToRpcRequests({lnd})).subscription;
|
|
58
58
|
|
|
@@ -64,6 +64,17 @@ test(`Subscribe to RPC requests`, async () => {
|
|
|
64
64
|
rpcRequestsSub.on('request', request => intercepted.push({request}));
|
|
65
65
|
rpcRequestsSub.on('response', response => intercepted.push({response}));
|
|
66
66
|
|
|
67
|
+
// Make sure that target is synced to the chain otherwise invoice can halt
|
|
68
|
+
await asyncRetry({interval, times}, async () => {
|
|
69
|
+
const wallet = await getWalletInfo({lnd});
|
|
70
|
+
|
|
71
|
+
await generate({});
|
|
72
|
+
|
|
73
|
+
if (!wallet.is_synced_to_chain) {
|
|
74
|
+
throw new Error('WaitingForSyncToChain');
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
67
78
|
const {id} = await createInvoice({lnd});
|
|
68
79
|
|
|
69
80
|
const invoicesSub = subscribeToInvoice({id, lnd});
|
|
@@ -14,9 +14,11 @@ const {createInvoice} = require('./../../');
|
|
|
14
14
|
const {fundPendingChannels} = require('./../../');
|
|
15
15
|
const {fundPsbt} = require('./../../');
|
|
16
16
|
const {getChannels} = require('./../../');
|
|
17
|
+
const {getChannel} = require('./../../');
|
|
17
18
|
const {getClosedChannels} = require('./../../');
|
|
18
19
|
const {getEphemeralChannelIds} = require('./../../');
|
|
19
20
|
const {getPendingChannels} = require('./../../');
|
|
21
|
+
const {getWalletInfo} = require('./../../');
|
|
20
22
|
const {openChannels} = require('./../../');
|
|
21
23
|
const {pay} = require('./../../');
|
|
22
24
|
const {signPsbt} = require('./../../');
|
|
@@ -30,9 +32,7 @@ const size = 2;
|
|
|
30
32
|
const times = 4000;
|
|
31
33
|
|
|
32
34
|
// Opening unconfirmed channels should in immediate channel opening
|
|
33
|
-
test(`Open unconfirmed channels`, async
|
|
34
|
-
t.after(() => exit());
|
|
35
|
-
|
|
35
|
+
test(`Open unconfirmed channels`, async () => {
|
|
36
36
|
// Unconfirmed channels are not supported on LND 0.15.0 and below
|
|
37
37
|
{
|
|
38
38
|
const {kill, nodes} = await spawnLightningCluster({});
|
|
@@ -67,6 +67,16 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
67
67
|
// Make some funds to use
|
|
68
68
|
await generate({count: maturity});
|
|
69
69
|
|
|
70
|
+
await asyncRetry({interval, times}, async () => {
|
|
71
|
+
const wallet = await getWalletInfo({lnd});
|
|
72
|
+
|
|
73
|
+
await generate({});
|
|
74
|
+
|
|
75
|
+
if (!wallet.is_synced_to_chain) {
|
|
76
|
+
throw new Error('NotSyncedToChain');
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
70
80
|
// Connect to the peer
|
|
71
81
|
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
72
82
|
|
|
@@ -78,9 +88,13 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
78
88
|
});
|
|
79
89
|
});
|
|
80
90
|
|
|
91
|
+
// Wait for channel open requests to be able to accept the proposal
|
|
81
92
|
const acceptSub = subscribeToOpenRequests({lnd: target.lnd});
|
|
93
|
+
|
|
94
|
+
// Listen for channel events
|
|
82
95
|
const channelsSub = subscribeToChannels({lnd});
|
|
83
96
|
|
|
97
|
+
// Channel closing and opening events should be emitted
|
|
84
98
|
const closings = [];
|
|
85
99
|
const opened = [];
|
|
86
100
|
|
|
@@ -118,11 +132,10 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
118
132
|
funding: psbt,
|
|
119
133
|
});
|
|
120
134
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
tokens: 100,
|
|
124
|
-
});
|
|
135
|
+
// Make an invoice to pay over the channel
|
|
136
|
+
const invoice = await createInvoice({lnd: target.lnd, tokens: 100});
|
|
125
137
|
|
|
138
|
+
// Wait for the trusted channel
|
|
126
139
|
const channel = await asyncRetry({interval, times}, async () => {
|
|
127
140
|
const {channels} = await getChannels({lnd, is_active: true});
|
|
128
141
|
|
|
@@ -148,11 +161,14 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
148
161
|
equal(event.is_trusted_funding, true, 'Channel event funding is trusted');
|
|
149
162
|
|
|
150
163
|
// Make sure the channel can be used immediately
|
|
151
|
-
await
|
|
164
|
+
await asyncRetry({interval, times}, async () => {
|
|
165
|
+
return await pay({lnd, request: invoice.request});
|
|
166
|
+
});
|
|
152
167
|
|
|
153
168
|
// Generate the channel into a block
|
|
154
169
|
await broadcastChainTransaction({lnd, transaction});
|
|
155
170
|
|
|
171
|
+
// Make sure that the channel id gets a confirmed id
|
|
156
172
|
const confirmed = await asyncRetry({interval, times}, async () => {
|
|
157
173
|
await generate({});
|
|
158
174
|
|
|
@@ -165,7 +181,7 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
165
181
|
return confirmed;
|
|
166
182
|
});
|
|
167
183
|
|
|
168
|
-
|
|
184
|
+
match(confirmed.id, /1[\d][\d]x1x0/, 'Channel id is real now');
|
|
169
185
|
equal(confirmed.is_trusted_funding, true, 'Channel funding was trusted');
|
|
170
186
|
equal(confirmed.other_ids.length, 1, 'Got ephemeral id');
|
|
171
187
|
|
|
@@ -184,6 +200,7 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
184
200
|
}
|
|
185
201
|
});
|
|
186
202
|
|
|
203
|
+
// Remove the channel
|
|
187
204
|
await asyncRetry({interval, times}, async () => {
|
|
188
205
|
await closeChannel({lnd, id: confirmed.id});
|
|
189
206
|
});
|
|
@@ -214,6 +231,7 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
214
231
|
funding: signedPrivate.psbt,
|
|
215
232
|
});
|
|
216
233
|
|
|
234
|
+
// Confirm the private channel
|
|
217
235
|
const privateConfirmed = await asyncRetry({interval, times}, async () => {
|
|
218
236
|
// Generate the channel into a block
|
|
219
237
|
await broadcastChainTransaction({
|
|
@@ -252,11 +270,13 @@ test(`Open unconfirmed channels`, async t => {
|
|
|
252
270
|
|
|
253
271
|
match(firstChannel.reference_id, /16000000x0/, 'Got first channel id');
|
|
254
272
|
match(secondChannel.reference_id, /16000000x0/, 'Got second channel id');
|
|
273
|
+
|
|
274
|
+
await kill({});
|
|
255
275
|
} catch (err) {
|
|
256
|
-
|
|
257
|
-
}
|
|
276
|
+
await kill({});
|
|
258
277
|
|
|
259
|
-
|
|
278
|
+
throw err;
|
|
279
|
+
}
|
|
260
280
|
|
|
261
281
|
return;
|
|
262
282
|
});
|
|
@@ -37,6 +37,16 @@ test(`Get sweep transactions`, async t => {
|
|
|
37
37
|
|
|
38
38
|
const [{generate, lnd}, target] = nodes;
|
|
39
39
|
|
|
40
|
+
await asyncRetry({interval, times}, async () => {
|
|
41
|
+
const wallet = await getWalletInfo({lnd});
|
|
42
|
+
|
|
43
|
+
await generate({});
|
|
44
|
+
|
|
45
|
+
if (!wallet.is_synced_to_chain) {
|
|
46
|
+
throw new Error('NotSyncedToChain');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
40
50
|
const channel = await setupChannel({
|
|
41
51
|
generate,
|
|
42
52
|
lnd,
|
|
@@ -3,6 +3,7 @@ const {equal} = require('node:assert').strict;
|
|
|
3
3
|
const {rejects} = require('node:assert').strict;
|
|
4
4
|
const test = require('node:test');
|
|
5
5
|
|
|
6
|
+
const asyncRetry = require('async/retry');
|
|
6
7
|
const {setupChannel} = require('ln-docker-daemons');
|
|
7
8
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
8
9
|
|
|
@@ -11,11 +12,14 @@ const {createInvoice} = require('./../../');
|
|
|
11
12
|
const {getChannels} = require('./../../');
|
|
12
13
|
const {getHeight} = require('./../../');
|
|
13
14
|
const {getPayment} = require('./../../');
|
|
15
|
+
const {getWalletInfo} = require('./../../');
|
|
14
16
|
const {payViaPaymentRequest} = require('./../../');
|
|
15
17
|
const {waitForRoute} = require('./../macros');
|
|
16
18
|
|
|
19
|
+
const interval = 50;
|
|
17
20
|
const size = 3;
|
|
18
21
|
const start = new Date().toISOString();
|
|
22
|
+
const times = 5000;
|
|
19
23
|
const tokens = 100;
|
|
20
24
|
|
|
21
25
|
// Paying an invoice should settle the invoice
|
|
@@ -24,6 +28,16 @@ test(`Get payment`, async () => {
|
|
|
24
28
|
|
|
25
29
|
const [{generate, lnd}, target, remote] = nodes;
|
|
26
30
|
|
|
31
|
+
await asyncRetry({interval, times}, async () => {
|
|
32
|
+
const wallet = await getWalletInfo({lnd: remote.lnd});
|
|
33
|
+
|
|
34
|
+
await remote.generate({});
|
|
35
|
+
|
|
36
|
+
if (!wallet.is_synced_to_chain) {
|
|
37
|
+
throw new Error('NotSyncedToChain');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
27
41
|
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
28
42
|
|
|
29
43
|
const {id} = invoice;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
const {equal} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
4
5
|
const {setupChannel} = require('ln-docker-daemons');
|
|
5
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
6
7
|
|
|
7
8
|
const {addPeer} = require('./../../');
|
|
8
9
|
const {getRouteConfidence} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
9
11
|
const {probeForRoute} = require('./../../');
|
|
10
12
|
const {waitForRoute} = require('./../macros');
|
|
11
13
|
|
|
12
14
|
const channelCapacityTokens = 1e6;
|
|
15
|
+
const interval = 50;
|
|
13
16
|
const size = 3;
|
|
17
|
+
const times = 5000;
|
|
14
18
|
const tokens = 1e6 / 2;
|
|
15
19
|
|
|
16
20
|
// Getting route confidence should return confidence in a route
|
|
@@ -19,6 +23,16 @@ test('Get route confidence', async () => {
|
|
|
19
23
|
|
|
20
24
|
const [{generate, lnd}, target, remote] = nodes;
|
|
21
25
|
|
|
26
|
+
await asyncRetry({interval, times}, async () => {
|
|
27
|
+
const wallet = await getWalletInfo({lnd});
|
|
28
|
+
|
|
29
|
+
await generate({});
|
|
30
|
+
|
|
31
|
+
if (!wallet.is_synced_to_chain) {
|
|
32
|
+
throw new Error('NotSyncedToChain');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
22
36
|
try {
|
|
23
37
|
// Create a channel from the control to the target node
|
|
24
38
|
await setupChannel({
|
|
@@ -3,6 +3,7 @@ const {equal} = require('node:assert').strict;
|
|
|
3
3
|
const {rejects} = require('node:assert').strict;
|
|
4
4
|
const test = require('node:test');
|
|
5
5
|
|
|
6
|
+
const asyncRetry = require('async/retry');
|
|
6
7
|
const {setupChannel} = require('ln-docker-daemons');
|
|
7
8
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
8
9
|
|
|
@@ -14,8 +15,10 @@ const {getWalletInfo} = require('./../../');
|
|
|
14
15
|
const {payViaPaymentRequest} = require('./../../');
|
|
15
16
|
const {waitForRoute} = require('./../macros');
|
|
16
17
|
|
|
18
|
+
const interval = 50;
|
|
17
19
|
const size = 3;
|
|
18
20
|
const start = new Date().toISOString();
|
|
21
|
+
const times = 3000;
|
|
19
22
|
const tlvType = '67890';
|
|
20
23
|
const tlvValue = '0102';
|
|
21
24
|
const tokens = 100;
|
|
@@ -29,6 +32,16 @@ test(`Pay via payment request`, async () => {
|
|
|
29
32
|
try {
|
|
30
33
|
await generate({count: 100});
|
|
31
34
|
|
|
35
|
+
await asyncRetry({interval, times}, async () => {
|
|
36
|
+
const wallet = await getWalletInfo({lnd: remote.lnd});
|
|
37
|
+
|
|
38
|
+
await remote.generate({});
|
|
39
|
+
|
|
40
|
+
if (!wallet.is_synced_to_chain) {
|
|
41
|
+
throw new Error('NotSyncedToChain');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
32
45
|
const channel = await setupChannel({generate, lnd, to: target});
|
|
33
46
|
|
|
34
47
|
// Make sure that an error is returned when there is no route
|
|
@@ -13,6 +13,7 @@ const {delay} = require('./../macros');
|
|
|
13
13
|
const {deleteForwardingReputations} = require('./../../');
|
|
14
14
|
const {getChainBalance} = require('./../../');
|
|
15
15
|
const {getFailedPayments} = require('./../../');
|
|
16
|
+
const {getWalletInfo} = require('./../../');
|
|
16
17
|
const {getWalletVersion} = require('./../../');
|
|
17
18
|
const {payViaRoutes} = require('./../../');
|
|
18
19
|
const {probeForRoute} = require('./../../');
|
|
@@ -24,6 +25,7 @@ const channelCapacityTokens = 1e6;
|
|
|
24
25
|
const confirmationCount = 20;
|
|
25
26
|
const count = 100;
|
|
26
27
|
const defaultFee = 1e3;
|
|
28
|
+
const interval = 50;
|
|
27
29
|
const size = 3;
|
|
28
30
|
const times = 1000;
|
|
29
31
|
const tokens = 1e6 / 2;
|
|
@@ -38,6 +40,16 @@ test('Probe for route', async () => {
|
|
|
38
40
|
// Send coins to remote so that it can accept a channel
|
|
39
41
|
await remote.generate({count});
|
|
40
42
|
|
|
43
|
+
await asyncRetry({interval, times}, async () => {
|
|
44
|
+
const wallet = await getWalletInfo({lnd: remote.lnd});
|
|
45
|
+
|
|
46
|
+
await remote.generate({});
|
|
47
|
+
|
|
48
|
+
if (!wallet.is_synced_to_chain) {
|
|
49
|
+
throw new Error('NotSyncedToChain');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
41
53
|
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
42
54
|
|
|
43
55
|
await setupChannel({
|
|
@@ -25,6 +25,8 @@ const size = 3;
|
|
|
25
25
|
const times = 1000;
|
|
26
26
|
const tokens = 100;
|
|
27
27
|
|
|
28
|
+
const asyncTimesSeries = require('async/timesSeries');
|
|
29
|
+
|
|
28
30
|
// Subscribing to forwards should show forwarding events
|
|
29
31
|
test('Subscribe to forwards', async () => {
|
|
30
32
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
@@ -40,6 +42,16 @@ test('Subscribe to forwards', async () => {
|
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
await asyncRetry({interval, times}, async () => {
|
|
46
|
+
const wallet = await getWalletInfo({lnd});
|
|
47
|
+
|
|
48
|
+
await generate({});
|
|
49
|
+
|
|
50
|
+
if (!wallet.is_synced_to_chain) {
|
|
51
|
+
throw new Error('NotSyncedToChain');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
43
55
|
try {
|
|
44
56
|
const {features} = await getWalletInfo({lnd});
|
|
45
57
|
const testSub = subscribeToForwards({lnd});
|
|
@@ -56,6 +68,8 @@ test('Subscribe to forwards', async () => {
|
|
|
56
68
|
});
|
|
57
69
|
|
|
58
70
|
await asyncRetry({interval, times}, async () => {
|
|
71
|
+
await generate({});
|
|
72
|
+
|
|
59
73
|
await addPeer({
|
|
60
74
|
lnd,
|
|
61
75
|
public_key: remote.id,
|
|
@@ -100,7 +114,6 @@ test('Subscribe to forwards', async () => {
|
|
|
100
114
|
tokens: channel.remote_balance,
|
|
101
115
|
});
|
|
102
116
|
|
|
103
|
-
|
|
104
117
|
await rejects(
|
|
105
118
|
payViaPaymentRequest({lnd, request: tooMuchInvoice.request}),
|
|
106
119
|
[503, 'PaymentPathfindingFailedToFindPossibleRoute'],
|
|
@@ -8,12 +8,15 @@ const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
|
8
8
|
const {createInvoice} = require('./../../');
|
|
9
9
|
const {delay} = require('./../macros');
|
|
10
10
|
const {getPayment} = require('./../../');
|
|
11
|
+
const {getWalletInfo} = require('./../../');
|
|
11
12
|
const {payViaPaymentRequest} = require('./../../');
|
|
12
13
|
const {subscribeToForwards} = require('./../../');
|
|
13
14
|
const {subscribeToPastPayments} = require('./../../');
|
|
14
15
|
const {waitForRoute} = require('./../macros');
|
|
15
16
|
|
|
17
|
+
const interval = 1000;
|
|
16
18
|
const size = 2;
|
|
19
|
+
const times = 1000;
|
|
17
20
|
const tokens = 100;
|
|
18
21
|
|
|
19
22
|
// Subscribing to past payments should notify on a payment
|
|
@@ -25,6 +28,22 @@ test(`Subscribe to past payment`, async () => {
|
|
|
25
28
|
|
|
26
29
|
const forwards = [];
|
|
27
30
|
const payments = [];
|
|
31
|
+
const sub = subscribeToPastPayments({lnd});
|
|
32
|
+
const sub2 = subscribeToForwards({lnd});
|
|
33
|
+
|
|
34
|
+
sub2.on('forward', forward => forwards.push(forward));
|
|
35
|
+
sub.on('payment', payment => payments.push(payment));
|
|
36
|
+
|
|
37
|
+
// Make sure that target is synced to the chain otherwise invoice can halt
|
|
38
|
+
await asyncRetry({interval, times}, async () => {
|
|
39
|
+
const wallet = await getWalletInfo({lnd: target.lnd});
|
|
40
|
+
|
|
41
|
+
await generate({});
|
|
42
|
+
|
|
43
|
+
if (!wallet.is_synced_to_chain) {
|
|
44
|
+
throw new Error('WaitingForSyncToChain');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
28
47
|
|
|
29
48
|
const invoice = await createInvoice({tokens, lnd: target.lnd});
|
|
30
49
|
|
|
@@ -32,12 +51,6 @@ test(`Subscribe to past payment`, async () => {
|
|
|
32
51
|
|
|
33
52
|
await setupChannel({generate, lnd, to: target});
|
|
34
53
|
|
|
35
|
-
const sub = subscribeToPastPayments({lnd});
|
|
36
|
-
const sub2 = subscribeToForwards({lnd});
|
|
37
|
-
|
|
38
|
-
sub2.on('forward', forward => forwards.push(forward));
|
|
39
|
-
sub.on('payment', payment => payments.push(payment));
|
|
40
|
-
|
|
41
54
|
await payViaPaymentRequest({lnd, request: invoice.request});
|
|
42
55
|
|
|
43
56
|
const {payment} = await getPayment({id, lnd});
|
|
@@ -7,14 +7,17 @@ const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
|
7
7
|
|
|
8
8
|
const {createInvoice} = require('./../../');
|
|
9
9
|
const {getPayment} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
10
11
|
const {payViaPaymentRequest} = require('./../../');
|
|
11
12
|
const {subscribeToForwards} = require('./../../');
|
|
12
13
|
const {subscribeToPayments} = require('./../../');
|
|
13
14
|
const {waitForRoute} = require('./../macros');
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const interval = 1000;
|
|
16
17
|
const size = 2;
|
|
18
|
+
const times = 1000;
|
|
17
19
|
const tokens = 100;
|
|
20
|
+
const unsupported = 'unknown method TrackPayments for service routerrpc.Router';
|
|
18
21
|
|
|
19
22
|
// Subscribing to payments should notify on a payment
|
|
20
23
|
test(`Subscribe to payments`, async () => {
|
|
@@ -28,6 +31,17 @@ test(`Subscribe to payments`, async () => {
|
|
|
28
31
|
const isPaying = [];
|
|
29
32
|
const payments = [];
|
|
30
33
|
|
|
34
|
+
// Make sure that target is synced to the chain otherwise invoice can halt
|
|
35
|
+
await asyncRetry({interval, times}, async () => {
|
|
36
|
+
const wallet = await getWalletInfo({lnd: target.lnd});
|
|
37
|
+
|
|
38
|
+
await generate({});
|
|
39
|
+
|
|
40
|
+
if (!wallet.is_synced_to_chain) {
|
|
41
|
+
throw new Error('WaitingForSyncToChain');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
31
45
|
const invoice = await createInvoice({tokens, lnd: target.lnd});
|
|
32
46
|
|
|
33
47
|
const {id} = invoice;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
const {equal} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
4
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
5
6
|
|
|
6
7
|
const {connectWatchtower} = require('./../../');
|
|
7
8
|
const {getConnectedWatchtowers} = require('./../../');
|
|
8
9
|
const {getTowerServerInfo} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
9
11
|
|
|
10
12
|
const conf = ['--watchtower.active', '--wtclient.active'];
|
|
13
|
+
const interval = 50;
|
|
11
14
|
const size = 2;
|
|
15
|
+
const times = 5000;
|
|
12
16
|
|
|
13
17
|
// Connecting to a watchtower should add a watchtower
|
|
14
18
|
test(`Connect watchtower`, async () => {
|
|
@@ -17,7 +21,17 @@ test(`Connect watchtower`, async () => {
|
|
|
17
21
|
lnd_configuration: conf
|
|
18
22
|
});
|
|
19
23
|
|
|
20
|
-
const [{lnd}, target] = nodes;
|
|
24
|
+
const [{generate, lnd}, target] = nodes;
|
|
25
|
+
|
|
26
|
+
await asyncRetry({interval, times}, async () => {
|
|
27
|
+
const wallet = await getWalletInfo({lnd});
|
|
28
|
+
|
|
29
|
+
await generate({});
|
|
30
|
+
|
|
31
|
+
if (!wallet.is_synced_to_chain) {
|
|
32
|
+
throw new Error('NotSyncedToChain');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
21
35
|
|
|
22
36
|
try {
|
|
23
37
|
const {tower} = await getTowerServerInfo({lnd: target.lnd});
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
const {equal} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
4
5
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
5
6
|
|
|
6
7
|
const {connectWatchtower} = require('./../../');
|
|
7
8
|
const {getConnectedWatchtowers} = require('./../../');
|
|
8
9
|
const {getTowerServerInfo} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
9
11
|
|
|
10
12
|
const conf = ['--watchtower.active', '--wtclient.active'];
|
|
13
|
+
const interval = 50;
|
|
11
14
|
const size = 2;
|
|
15
|
+
const times = 3000;
|
|
12
16
|
|
|
13
17
|
// Getting connected watchtowers should return watchtowers
|
|
14
18
|
test(`Get connected watchtowers`, async () => {
|
|
@@ -17,7 +21,17 @@ test(`Get connected watchtowers`, async () => {
|
|
|
17
21
|
lnd_configuration: conf
|
|
18
22
|
});
|
|
19
23
|
|
|
20
|
-
const [{lnd}, target] = nodes;
|
|
24
|
+
const [{generate, lnd}, target] = nodes;
|
|
25
|
+
|
|
26
|
+
await asyncRetry({interval, times}, async () => {
|
|
27
|
+
const wallet = await getWalletInfo({lnd});
|
|
28
|
+
|
|
29
|
+
await generate({});
|
|
30
|
+
|
|
31
|
+
if (!wallet.is_synced_to_chain) {
|
|
32
|
+
throw new Error('NotSyncedToChain');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
21
35
|
|
|
22
36
|
try {
|
|
23
37
|
const {tower} = await getTowerServerInfo({lnd: target.lnd});
|