ln-service 52.15.0 → 53.0.1
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 +17 -0
- package/README.md +112 -10
- package/package.json +7 -14
- package/test/autopilotrpc-integration/test_autopilot.js +9 -15
- package/test/chainrpc-integration/test_get_height.js +7 -10
- package/test/chainrpc-integration/test_subscribe_to_blocks.js +52 -31
- package/test/chainrpc-integration/test_subscribe_to_chain_address.js +72 -66
- package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +47 -16
- package/test/{integration → extra-integration}/test_recover_funds_from_channel.js +0 -0
- package/test/{integration → extra-integration}/test_recover_funds_from_channels.js +0 -0
- package/test/{integration → extra-integration}/test_restrict_macaroon.js +0 -0
- package/test/{integration → extra-integration}/test_revoke_access.js +0 -0
- package/test/{integration → extra-integration}/test_subscribe_to_rpc_requests.js +1 -1
- package/test/integration/test_add_peer.js +16 -12
- package/test/integration/test_cancel_pending_channel.js +20 -6
- package/test/integration/test_close_channel.js +15 -10
- package/test/integration/test_create_chain_address.js +3 -6
- package/test/integration/test_create_invoice.js +27 -23
- package/test/integration/test_decode_payment_request.js +30 -29
- package/test/integration/test_delete_payment.js +11 -8
- package/test/integration/test_delete_payments.js +13 -16
- package/test/integration/test_get_access_ids.js +4 -7
- package/test/integration/test_get_backup.js +12 -8
- package/test/integration/test_get_backups.js +8 -10
- package/test/integration/test_get_chain_balance.js +9 -53
- package/test/integration/test_get_chain_fee_estimate.js +21 -10
- package/test/integration/test_get_chain_transactions.js +30 -52
- package/test/integration/test_get_channel.js +7 -7
- package/test/integration/test_get_channel_balance.js +5 -6
- package/test/integration/test_get_channels.js +11 -10
- package/test/integration/test_get_closed_channels.js +169 -139
- package/test/integration/test_get_failed_payments.js +36 -39
- package/test/integration/test_get_fee_rates.js +6 -9
- package/test/integration/test_get_forwards.js +34 -35
- package/test/integration/test_get_invoice.js +7 -11
- package/test/integration/test_get_invoices.js +33 -30
- package/test/integration/test_get_methods.js +4 -7
- package/test/integration/test_get_network_centrality.js +14 -17
- package/test/integration/test_get_network_graph.js +12 -15
- package/test/integration/test_get_network_info.js +5 -6
- package/test/integration/test_get_node.js +15 -31
- package/test/integration/test_get_payments.js +10 -10
- package/test/integration/test_get_peers.js +10 -13
- package/test/integration/test_get_pending_coop.js +13 -18
- package/test/integration/test_get_pending_force.js +29 -21
- package/test/integration/test_get_route_to_destination.js +47 -40
- package/test/integration/test_get_utxos.js +17 -42
- package/test/integration/test_get_wallet_info.js +5 -12
- package/test/integration/test_open_channel.js +16 -9
- package/test/integration/test_open_channels.js +66 -66
- package/test/integration/test_pay.js +39 -36
- package/test/integration/test_pay_private_invoice.js +78 -71
- package/test/integration/test_payment_errors.js +13 -11
- package/test/integration/test_propose_channel.js +74 -53
- package/test/integration/test_push_funds.js +11 -15
- package/test/integration/test_rebalance.js +11 -22
- package/test/integration/test_remove_peer.js +13 -48
- package/test/integration/test_send_message_to_peer.js +25 -17
- package/test/integration/test_send_to_chain_address.js +60 -51
- package/test/integration/test_send_to_chain_addresses.js +30 -18
- package/test/integration/test_sign_message.js +3 -6
- package/test/integration/test_stop_daemon.js +3 -9
- package/test/integration/test_subscribe_to_backups.js +19 -11
- package/test/integration/test_subscribe_to_channels.js +28 -20
- package/test/integration/test_subscribe_to_graph.js +43 -22
- package/test/integration/test_subscribe_to_invoices.js +89 -103
- package/test/integration/test_subscribe_to_open_requests.js +47 -31
- package/test/integration/test_subscribe_to_peer_messages.js +51 -21
- package/test/integration/test_subscribe_to_peers.js +11 -16
- package/test/integration/test_subscribe_to_transactions.js +49 -45
- package/test/integration/test_update_routing_fees.js +12 -16
- package/test/integration/test_verify_access.js +5 -10
- package/test/integration/test_verify_backup.js +10 -8
- package/test/integration/test_verify_backups.js +11 -16
- package/test/integration/test_verify_message.js +6 -9
- package/test/invoicesrpc-integration/test_cancel_invoice.js +15 -22
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +15 -11
- package/test/invoicesrpc-integration/test_push_payment.js +53 -55
- package/test/invoicesrpc-integration/test_settle_invoice.js +25 -19
- package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +13 -11
- package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +20 -15
- package/test/macros/btcsuite_type_daemon.js +1 -1
- package/test/macros/chain_send_transaction.js +1 -1
- package/test/macros/change_password.js +15 -13
- package/test/macros/generate_blocks.js +24 -29
- package/test/macros/rpc.js +1 -0
- package/test/macros/setup_channel.js +23 -9
- package/test/macros/spawn_lnd.js +3 -1
- package/test/macros/wait_for_channel.js +8 -3
- package/test/macros/wait_for_route.js +2 -2
- package/test/routerrpc-integration/test_delete_forwarding_reputations.js +15 -22
- package/test/routerrpc-integration/test_disable_channel.js +8 -12
- package/test/routerrpc-integration/test_get_forwarding_confidence.js +17 -37
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +26 -25
- package/test/routerrpc-integration/test_get_pathfinding_settings.js +6 -12
- package/test/routerrpc-integration/test_get_payment.js +19 -26
- package/test/routerrpc-integration/test_get_route_confidence.js +15 -21
- package/test/routerrpc-integration/test_get_route_through_hops.js +29 -32
- package/test/routerrpc-integration/test_multipath_payment.js +18 -20
- package/test/routerrpc-integration/test_pay_via_payment_details.js +19 -34
- package/test/routerrpc-integration/test_pay_via_payment_request.js +17 -27
- package/test/routerrpc-integration/test_pay_via_routes.js +37 -37
- package/test/routerrpc-integration/test_probe_for_route.js +27 -33
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +96 -38
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +83 -77
- package/test/routerrpc-integration/test_subscribe_to_past_payments.js +34 -28
- package/test/routerrpc-integration/test_update_pathfinding_settings.js +7 -10
- package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +15 -14
- package/test/signerrpc-integration/test_sign_bytes.js +11 -15
- package/test/signerrpc-integration/test_sign_transaction.js +6 -7
- package/test/signerrpc-integration/test_verify_bytes_signature.js +11 -12
- package/test/versionrpc-integration/test_get_wallet_version.js +6 -7
- package/test/walletrpc-integration/test_fund_psbt.js +13 -12
- package/test/walletrpc-integration/test_get_chain_fee_rate.js +4 -8
- package/test/walletrpc-integration/test_get_locked_utxos.js +11 -27
- package/test/walletrpc-integration/test_get_public_key.js +5 -13
- package/test/walletrpc-integration/test_lock_utxo.js +16 -23
- package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +25 -6
- package/test/walletrpc-integration/test_sign_psbt.js +28 -19
- package/test/walletrpc-integration/test_unlock_utxo.js +16 -27
- package/test/walletrpc-integration/test_update_chain_transaction.js +6 -31
|
@@ -1,40 +1,70 @@
|
|
|
1
|
+
const {once} = require('events');
|
|
2
|
+
|
|
1
3
|
const asyncRetry = require('async/retry');
|
|
4
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
5
|
const {test} = require('@alexbosworth/tap');
|
|
3
6
|
|
|
4
7
|
const {createChainAddress} = require('./../../');
|
|
5
|
-
const {createCluster} = require('./../macros');
|
|
6
|
-
const {delay} = require('./../macros');
|
|
7
8
|
const {getChainBalance} = require('./../../');
|
|
8
9
|
const {getHeight} = require('./../../');
|
|
9
10
|
const {getUtxos} = require('./../../');
|
|
10
11
|
const {sendToChainAddress} = require('./../../');
|
|
12
|
+
const {subscribeToBlocks} = require('./../../');
|
|
11
13
|
const {subscribeToChainSpend} = require('./../../');
|
|
12
14
|
|
|
13
15
|
const confirmationCount = 6;
|
|
16
|
+
const count = 100;
|
|
14
17
|
const format = 'p2wpkh';
|
|
15
|
-
const interval =
|
|
16
|
-
const
|
|
18
|
+
const interval = 1;
|
|
19
|
+
const race = promises => Promise.race(promises);
|
|
20
|
+
const size = 2;
|
|
21
|
+
const times = 1000;
|
|
17
22
|
const tokens = 1e6;
|
|
18
23
|
|
|
19
24
|
// Subscribing to chain spend should push events on spend confirmations
|
|
20
25
|
test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
21
|
-
const cluster = await createCluster({is_remote_skipped: true});
|
|
22
26
|
let gotAddressConf = false;
|
|
23
27
|
|
|
24
|
-
const {
|
|
28
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
29
|
+
|
|
30
|
+
const [control, target] = nodes;
|
|
31
|
+
|
|
32
|
+
const cluster = {control, target};
|
|
33
|
+
|
|
34
|
+
const {address} = await createChainAddress({lnd: target.lnd});
|
|
35
|
+
const {lnd} = control;
|
|
36
|
+
|
|
37
|
+
// Wait for chainrpc to be active
|
|
38
|
+
await control.generate({count});
|
|
25
39
|
|
|
26
40
|
const startHeight = (await getHeight({lnd})).current_block_height;
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
await asyncRetry({interval, times}, async () => {
|
|
43
|
+
const subBlocks = subscribeToBlocks({lnd});
|
|
44
|
+
|
|
45
|
+
const [event] = await race([
|
|
46
|
+
once(subBlocks, 'block'),
|
|
47
|
+
once(subBlocks, 'error'),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
if (!event.height) {
|
|
51
|
+
throw new Error('ExpectedBlockEvent');
|
|
52
|
+
}
|
|
31
53
|
});
|
|
32
54
|
|
|
33
|
-
const sent = await
|
|
55
|
+
const sent = await asyncRetry({times}, async () => {
|
|
56
|
+
await control.generate({});
|
|
57
|
+
|
|
58
|
+
return await sendToChainAddress({address, lnd, tokens});
|
|
59
|
+
});
|
|
34
60
|
|
|
35
|
-
await
|
|
61
|
+
await control.generate({count: 1});
|
|
36
62
|
|
|
37
|
-
const
|
|
63
|
+
const {utxos} = await getUtxos({lnd});
|
|
64
|
+
|
|
65
|
+
const [utxo] = utxos;
|
|
66
|
+
|
|
67
|
+
await control.generate({count});
|
|
38
68
|
|
|
39
69
|
const sub = subscribeToChainSpend({
|
|
40
70
|
lnd,
|
|
@@ -54,7 +84,7 @@ test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
|
54
84
|
return gotAddressConf = true;
|
|
55
85
|
});
|
|
56
86
|
|
|
57
|
-
const toTarget = await createChainAddress({
|
|
87
|
+
const toTarget = await createChainAddress({lnd: target.lnd});
|
|
58
88
|
|
|
59
89
|
// Wait for generation to be over
|
|
60
90
|
await asyncRetry({interval, times}, async () => {
|
|
@@ -64,10 +94,11 @@ test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
|
64
94
|
address: toTarget.address,
|
|
65
95
|
is_send_all: true,
|
|
66
96
|
});
|
|
67
|
-
} catch (err) {
|
|
97
|
+
} catch (err) {
|
|
98
|
+
}
|
|
68
99
|
|
|
69
100
|
// Generate to confirm the tx
|
|
70
|
-
await
|
|
101
|
+
await control.generate({count: confirmationCount});
|
|
71
102
|
|
|
72
103
|
if (!gotAddressConf) {
|
|
73
104
|
throw new Error('ExpectedSubscribeToAddressSeesConfirmation');
|
|
@@ -76,7 +107,7 @@ test(`Subscribe to chain spend`, async ({end, equal}) => {
|
|
|
76
107
|
return;
|
|
77
108
|
});
|
|
78
109
|
|
|
79
|
-
await
|
|
110
|
+
await kill({});
|
|
80
111
|
|
|
81
112
|
equal(gotAddressConf, true, 'Subscribe to address sees confirmation');
|
|
82
113
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
5
|
const {addPeer} = require('./../../');
|
|
@@ -6,37 +7,40 @@ const {createCluster} = require('./../macros');
|
|
|
6
7
|
const {getPeers} = require('./../../');
|
|
7
8
|
|
|
8
9
|
const interval = 100;
|
|
10
|
+
const size = 2;
|
|
9
11
|
const times = 100;
|
|
12
|
+
const timeout = 1;
|
|
10
13
|
|
|
11
14
|
// Adding peers should result in a connected peer
|
|
12
15
|
test(`Add a peer`, async ({end, equal}) => {
|
|
13
|
-
const
|
|
16
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
14
17
|
|
|
15
|
-
const {lnd} =
|
|
16
|
-
const remoteNodeKey = cluster.remote.public_key;
|
|
18
|
+
const [{lnd}, target] = nodes;
|
|
17
19
|
|
|
18
20
|
const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
|
|
19
21
|
|
|
20
|
-
equal(connectedKeys.find(n => n ===
|
|
22
|
+
equal(connectedKeys.find(n => n === target.id), undefined, 'No peer');
|
|
21
23
|
|
|
22
24
|
await asyncRetry({interval, times}, async () => {
|
|
23
25
|
await addPeer({
|
|
24
26
|
lnd,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
timeout,
|
|
28
|
+
public_key: target.id,
|
|
29
|
+
socket: target.socket,
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
const {peers} = await getPeers({lnd});
|
|
31
33
|
|
|
32
|
-
const connected = peers.find(n => n.public_key ===
|
|
34
|
+
const connected = peers.find(n => n.public_key === target.id);
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
if (!connected) {
|
|
37
|
+
throw new Error('ExpectedConnectionToTarget');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
equal(connected.public_key, target.id, 'Connected to remote node');
|
|
35
41
|
});
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
await cluster.kill({});
|
|
39
|
-
})();
|
|
43
|
+
await kill({});
|
|
40
44
|
|
|
41
45
|
return end();
|
|
42
46
|
});
|
|
@@ -1,24 +1,38 @@
|
|
|
1
|
+
const asyncEach = require('async/each');
|
|
1
2
|
const asyncRetry = require('async/retry');
|
|
3
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
4
|
const {test} = require('@alexbosworth/tap');
|
|
3
5
|
|
|
6
|
+
const {addPeer} = require('./../../');
|
|
4
7
|
const {cancelPendingChannel} = require('./../../');
|
|
5
8
|
const {createCluster} = require('./../macros');
|
|
6
9
|
const {delay} = require('./../macros');
|
|
10
|
+
const {getChainBalance} = require('./../../');
|
|
7
11
|
const {openChannels} = require('./../../');
|
|
8
12
|
|
|
9
13
|
const capacity = 1e6;
|
|
14
|
+
const count = 100;
|
|
15
|
+
const interval = 100;
|
|
10
16
|
const race = promises => Promise.race(promises);
|
|
11
|
-
const
|
|
17
|
+
const size = 2;
|
|
18
|
+
const timeout = 1000 * 5;
|
|
19
|
+
const times = 200;
|
|
12
20
|
|
|
13
21
|
// Cancel a channel should result in no pending channels
|
|
14
22
|
test(`Cancel pending channel`, async ({end, equal}) => {
|
|
15
|
-
const
|
|
23
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
16
24
|
|
|
17
|
-
const
|
|
25
|
+
const [control, target] = nodes;
|
|
18
26
|
|
|
19
|
-
const
|
|
27
|
+
const {lnd} = control;
|
|
20
28
|
|
|
21
|
-
await
|
|
29
|
+
await control.generate({count});
|
|
30
|
+
|
|
31
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
32
|
+
|
|
33
|
+
const channels = [{capacity, partner_public_key: target.id}];
|
|
34
|
+
|
|
35
|
+
await asyncRetry({interval, times}, async () => {
|
|
22
36
|
const toCancel = await race([
|
|
23
37
|
delay(timeout),
|
|
24
38
|
openChannels({channels, lnd}),
|
|
@@ -29,7 +43,7 @@ test(`Cancel pending channel`, async ({end, equal}) => {
|
|
|
29
43
|
await cancelPendingChannel({id, lnd});
|
|
30
44
|
});
|
|
31
45
|
|
|
32
|
-
await
|
|
46
|
+
await kill({});
|
|
33
47
|
|
|
34
48
|
return end();
|
|
35
49
|
});
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {closeChannel} = require('./../../');
|
|
4
5
|
const {createCluster} = require('./../macros');
|
|
5
6
|
const {setupChannel} = require('./../macros');
|
|
6
7
|
|
|
8
|
+
const size = 2;
|
|
9
|
+
|
|
7
10
|
// Closing a channel should close the channel
|
|
8
11
|
test(`Close channel`, async ({end, equal}) => {
|
|
9
|
-
const
|
|
12
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
13
|
+
|
|
14
|
+
const [control, target] = nodes;
|
|
10
15
|
|
|
11
16
|
// Force close channel using tx id and vout
|
|
12
17
|
try {
|
|
13
18
|
const channelOpen = await setupChannel({
|
|
14
|
-
generate:
|
|
15
|
-
lnd:
|
|
16
|
-
to:
|
|
19
|
+
generate: control.generate,
|
|
20
|
+
lnd: control.lnd,
|
|
21
|
+
to: target,
|
|
17
22
|
});
|
|
18
23
|
|
|
19
24
|
const channelClose = await closeChannel({
|
|
20
25
|
is_force_close: true,
|
|
21
|
-
lnd:
|
|
26
|
+
lnd: control.lnd,
|
|
22
27
|
transaction_id: channelOpen.transaction_id,
|
|
23
28
|
transaction_vout: channelOpen.transaction_vout,
|
|
24
29
|
});
|
|
@@ -32,14 +37,14 @@ test(`Close channel`, async ({end, equal}) => {
|
|
|
32
37
|
// Coop close channel using the channel id
|
|
33
38
|
try {
|
|
34
39
|
const channelOpen = await setupChannel({
|
|
35
|
-
generate:
|
|
36
|
-
lnd:
|
|
37
|
-
to:
|
|
40
|
+
generate: control.generate,
|
|
41
|
+
lnd: control.lnd,
|
|
42
|
+
to: target,
|
|
38
43
|
});
|
|
39
44
|
|
|
40
45
|
const channelClose = await closeChannel({
|
|
41
46
|
id: channelOpen.id,
|
|
42
|
-
lnd:
|
|
47
|
+
lnd: control.lnd,
|
|
43
48
|
});
|
|
44
49
|
|
|
45
50
|
equal(channelClose.transaction_id.length, 64, 'Coop close id is returned');
|
|
@@ -48,7 +53,7 @@ test(`Close channel`, async ({end, equal}) => {
|
|
|
48
53
|
equal(err, null, 'Expected no error coop closing');
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
await
|
|
56
|
+
await kill({});
|
|
52
57
|
|
|
53
58
|
return end();
|
|
54
59
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const {address} = require('bitcoinjs-lib');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
5
|
const {createChainAddress} = require('./../../');
|
|
5
|
-
const {spawnLnd} = require('./../macros');
|
|
6
|
-
const {waitForTermination} = require('./../macros');
|
|
7
6
|
|
|
8
7
|
const formats = ['np2wpkh', 'p2wpkh'];
|
|
9
8
|
const p2shAddressVersion = 196;
|
|
@@ -12,7 +11,7 @@ const regtestBech32AddressHrp = 'bcrt';
|
|
|
12
11
|
|
|
13
12
|
// Creating addresses should result in addresses
|
|
14
13
|
test(`Create address results in address creation`, async ({end, equal}) => {
|
|
15
|
-
const {kill, lnd} = await
|
|
14
|
+
const [{kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
16
15
|
|
|
17
16
|
const createNewChainAddresses = formats
|
|
18
17
|
.map(async format => await createChainAddress({lnd, format}));
|
|
@@ -35,9 +34,7 @@ test(`Create address results in address creation`, async ({end, equal}) => {
|
|
|
35
34
|
equal(np2wpkh.address, unusedNp2wpkh.address, 'Nested is reused');
|
|
36
35
|
equal(p2wpkh.address, unusedP2wpkh.address, 'Native is reused');
|
|
37
36
|
|
|
38
|
-
kill();
|
|
39
|
-
|
|
40
|
-
await waitForTermination({lnd});
|
|
37
|
+
await kill({});
|
|
41
38
|
|
|
42
39
|
return end();
|
|
43
40
|
});
|
|
@@ -1,41 +1,45 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {createInvoice} = require('./../../');
|
|
4
5
|
const {parsePaymentRequest} = require('./../../');
|
|
5
|
-
const {spawnLnd} = require('./../macros');
|
|
6
|
-
const {waitForTermination} = require('./../macros');
|
|
7
6
|
|
|
8
7
|
// createInvoice should result in a created invoice
|
|
9
8
|
test(`Create an invoice`, async ({end, equal}) => {
|
|
10
|
-
const {kill, lnd} = await
|
|
9
|
+
const [{generate, kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
await generate({count: 100});
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
try {
|
|
14
|
+
const invoice = await createInvoice({lnd});
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
equal(invoice.created_at, parsed.created_at, 'Invoice has created at date');
|
|
18
|
-
equal(invoice.description, undefined, 'Default description is undefined');
|
|
19
|
-
equal(invoice.id, parsed.id, 'Invoice has id');
|
|
20
|
-
equal(invoice.mtokens, '0', 'Default mtokens are 0');
|
|
21
|
-
equal(!!invoice.request, true, 'Invoice has request');
|
|
22
|
-
equal(!!invoice.secret, true, 'Invoice returns secret');
|
|
23
|
-
equal(invoice.tokens, 0, 'Default tokens are 0');
|
|
16
|
+
const parsed = parsePaymentRequest({request: invoice.request});
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
equal(invoice.chain_address, undefined, 'Default address is undefined');
|
|
19
|
+
equal(invoice.created_at, parsed.created_at, 'Invoice has created date');
|
|
20
|
+
equal(invoice.description, undefined, 'Default description is undefined');
|
|
21
|
+
equal(invoice.id, parsed.id, 'Invoice has id');
|
|
22
|
+
equal(invoice.mtokens, '0', 'Default mtokens are 0');
|
|
23
|
+
equal(!!invoice.request, true, 'Invoice has request');
|
|
24
|
+
equal(!!invoice.secret, true, 'Invoice returns secret');
|
|
25
|
+
equal(invoice.tokens, 0, 'Default tokens are 0');
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} catch (err) {
|
|
30
|
-
const [code, message] = err;
|
|
27
|
+
try {
|
|
28
|
+
const duplicate = await createInvoice({lnd, secret: invoice.secret});
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
equal(duplicate, null, 'Expected no duplicate invoice');
|
|
31
|
+
} catch (err) {
|
|
32
|
+
const [code, message] = err;
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
equal(code, 409, 'Got expected error code');
|
|
35
|
+
equal(message, 'InvoiceWithGivenHashAlreadyExists', 'Got expected msg');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} catch (err) {
|
|
39
|
+
equal(err, null, 'Expected no error in create invoice');
|
|
40
|
+
}
|
|
37
41
|
|
|
38
|
-
await
|
|
42
|
+
await kill({});
|
|
39
43
|
|
|
40
44
|
return end();
|
|
41
45
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {createInvoice} = require('./../../');
|
|
4
5
|
const {decodePaymentRequest} = require('./../../');
|
|
5
6
|
const {getIdentity} = require('./../../');
|
|
6
|
-
const {spawnLnd} = require('./../macros');
|
|
7
|
-
const {waitForTermination} = require('./../macros');
|
|
8
7
|
|
|
9
8
|
const tests = [
|
|
10
9
|
{
|
|
@@ -23,33 +22,35 @@ const tests = [
|
|
|
23
22
|
|
|
24
23
|
tests.forEach(({description, expected}) => {
|
|
25
24
|
return test(description, async ({end, equal}) => {
|
|
26
|
-
const {kill, lnd} = await
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
const [{kill, lnd}] = (await spawnLightningCluster({})).nodes;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const {request} = await createInvoice({
|
|
29
|
+
lnd,
|
|
30
|
+
cltv_delta: expected.cltv_delta,
|
|
31
|
+
description: expected.description,
|
|
32
|
+
secret: expected.secret,
|
|
33
|
+
tokens: expected.tokens,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const decoded = await decodePaymentRequest({lnd, request});
|
|
37
|
+
|
|
38
|
+
equal(decoded.chain_addresses, expected.chain_addresses, 'Chain addr');
|
|
39
|
+
equal(decoded.cltv_delta, expected.cltv_delta, 'Decode cltv delta');
|
|
40
|
+
equal(!!decoded.created_at, true, 'Created at date');
|
|
41
|
+
equal(decoded.description, expected.description, 'Decode description');
|
|
42
|
+
equal(decoded.description_hash, expected.description_hash, 'Desc hash');
|
|
43
|
+
equal(decoded.destination, (await getIdentity({lnd})).public_key, 'Pk');
|
|
44
|
+
equal(!!decoded.expires_at, true, 'Expiration date decoded');
|
|
45
|
+
equal(decoded.id, expected.id, 'Decoded payment hash');
|
|
46
|
+
equal(decoded.mtokens, expected.mtokens, 'Decode millitokens');
|
|
47
|
+
equal(decoded.safe_tokens, expected.safe_tokens, 'Decode safe amount');
|
|
48
|
+
equal(decoded.tokens, expected.tokens, 'Decode tokens amount');
|
|
49
|
+
} catch (err) {
|
|
50
|
+
equal(err, null, 'Expected no error');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
await kill({});
|
|
53
54
|
|
|
54
55
|
return end();
|
|
55
56
|
});
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
|
-
const {createCluster} = require('./../macros');
|
|
4
4
|
const {createInvoice} = require('./../../');
|
|
5
5
|
const {deletePayment} = require('./../../');
|
|
6
6
|
const {getPayments} = require('./../../');
|
|
7
7
|
const {pay} = require('./../../');
|
|
8
8
|
const {setupChannel} = require('./../macros');
|
|
9
9
|
|
|
10
|
+
const size = 2;
|
|
10
11
|
const tokens = 100;
|
|
11
12
|
|
|
12
13
|
// Deleting a payment should delete the payment record
|
|
13
14
|
test('Delete payment', async ({afterEach, fail, end, equal, strictSame}) => {
|
|
14
|
-
const
|
|
15
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const [control, target] = nodes;
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const {lnd} = control;
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
await setupChannel({lnd, generate: control.generate, to: target});
|
|
22
|
+
|
|
23
|
+
const invoice = await createInvoice({tokens, lnd: target.lnd});
|
|
21
24
|
|
|
22
25
|
let paid;
|
|
23
26
|
|
|
@@ -26,7 +29,7 @@ test('Delete payment', async ({afterEach, fail, end, equal, strictSame}) => {
|
|
|
26
29
|
} catch (err) {
|
|
27
30
|
fail('Payment should be made to destination');
|
|
28
31
|
|
|
29
|
-
await
|
|
32
|
+
await kill({});
|
|
30
33
|
|
|
31
34
|
return end();
|
|
32
35
|
}
|
|
@@ -39,7 +42,7 @@ test('Delete payment', async ({afterEach, fail, end, equal, strictSame}) => {
|
|
|
39
42
|
} catch (err) {
|
|
40
43
|
strictSame(err, [501, 'DeletePaymentMethodNotSupported']);
|
|
41
44
|
|
|
42
|
-
await
|
|
45
|
+
await kill({});
|
|
43
46
|
|
|
44
47
|
return end();
|
|
45
48
|
}
|
|
@@ -48,7 +51,7 @@ test('Delete payment', async ({afterEach, fail, end, equal, strictSame}) => {
|
|
|
48
51
|
|
|
49
52
|
equal(priorLength - wipedLength, [paid].length, 'Payment deleted');
|
|
50
53
|
|
|
51
|
-
await
|
|
54
|
+
await kill({});
|
|
52
55
|
|
|
53
56
|
return end();
|
|
54
57
|
});
|
|
@@ -1,35 +1,32 @@
|
|
|
1
|
+
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
3
|
const {test} = require('@alexbosworth/tap');
|
|
2
4
|
|
|
3
|
-
const {createCluster} = require('./../macros');
|
|
4
5
|
const {createInvoice} = require('./../../');
|
|
5
6
|
const {deletePayments} = require('./../../');
|
|
6
7
|
const {getPayments} = require('./../../');
|
|
7
8
|
const {pay} = require('./../../');
|
|
8
9
|
const {setupChannel} = require('./../macros');
|
|
9
10
|
|
|
11
|
+
const size = 2;
|
|
12
|
+
const times = 1000;
|
|
10
13
|
const tokens = 100;
|
|
11
14
|
|
|
12
15
|
// Deleting payments should delete all payments
|
|
13
16
|
test('Delete payments', async ({afterEach, fail, end, equal}) => {
|
|
14
|
-
const
|
|
17
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
15
18
|
|
|
16
|
-
const
|
|
19
|
+
const [control, target] = nodes;
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
const {generate, lnd} = control;
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
await setupChannel({generate, lnd, to: target});
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
const invoice = await createInvoice({tokens, lnd: target.lnd});
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
fail('Payment should be made to destination');
|
|
28
|
-
|
|
29
|
-
await cluster.kill({});
|
|
30
|
-
|
|
31
|
-
return end();
|
|
32
|
-
}
|
|
27
|
+
const paid = await asyncRetry({times}, async () => {
|
|
28
|
+
return await pay({lnd, request: invoice.request});
|
|
29
|
+
});
|
|
33
30
|
|
|
34
31
|
const priorLength = (await getPayments({lnd})).payments.length;
|
|
35
32
|
|
|
@@ -39,7 +36,7 @@ test('Delete payments', async ({afterEach, fail, end, equal}) => {
|
|
|
39
36
|
|
|
40
37
|
equal(priorLength - wipedLength, [paid].length, 'Payment history deleted');
|
|
41
38
|
|
|
42
|
-
await
|
|
39
|
+
await kill({});
|
|
43
40
|
|
|
44
41
|
return end();
|
|
45
42
|
});
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
|
-
const {authenticatedLndGrpc} = require('./../../');
|
|
4
4
|
const {getAccessIds} = require('./../../');
|
|
5
5
|
const {grantAccess} = require('./../../');
|
|
6
6
|
const {spawnLnd} = require('./../macros');
|
|
7
|
-
const {waitForTermination} = require('./../macros');
|
|
8
7
|
|
|
9
8
|
const defaultId = '0';
|
|
10
9
|
const id = '1';
|
|
11
10
|
|
|
12
11
|
// Getting access ids should return root macaroon ids
|
|
13
12
|
test(`Get access ids`, async ({end, equal, rejects, strictSame}) => {
|
|
14
|
-
const
|
|
13
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
15
14
|
|
|
16
|
-
const {lnd
|
|
15
|
+
const [{lnd}] = nodes;
|
|
17
16
|
|
|
18
17
|
await grantAccess({id, lnd, is_ok_to_create_chain_addresses: true});
|
|
19
18
|
|
|
@@ -30,9 +29,7 @@ test(`Get access ids`, async ({end, equal, rejects, strictSame}) => {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
kill();
|
|
34
|
-
|
|
35
|
-
await waitForTermination({lnd});
|
|
32
|
+
await kill({});
|
|
36
33
|
|
|
37
34
|
return end();
|
|
38
35
|
});
|