ln-service 52.16.1 → 53.0.0
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 +12 -0
- package/README.md +1 -8
- package/package.json +4 -12
- 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 +20 -14
- 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/change_password.js +14 -12
- package/test/macros/generate_blocks.js +23 -28
- package/test/macros/rpc.js +1 -0
- package/test/macros/setup_channel.js +23 -9
- package/test/macros/spawn_lnd.js +2 -0
- 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 -23
- 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 +39 -44
- 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,37 +1,19 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
|
-
const {chainSendTransaction} = require('./../macros');
|
|
5
|
-
const {createChainAddress} = require('./../../');
|
|
6
|
-
const {generateBlocks} = require('./../macros');
|
|
7
5
|
const {getChainBalance} = require('./../../');
|
|
8
|
-
const {mineTransaction} = require('./../macros');
|
|
9
|
-
const {spawnLnd} = require('./../macros');
|
|
10
|
-
const {waitForTermination} = require('./../macros');
|
|
11
|
-
const {waitForUtxo} = require('./../macros');
|
|
12
6
|
|
|
13
|
-
const count = 100;
|
|
14
|
-
const defaultFee = 1e3;
|
|
15
|
-
const defaultVout = 0;
|
|
16
7
|
const emptyChainBalance = 0;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const tokens = 1e8;
|
|
8
|
+
const interval = 1;
|
|
9
|
+
const times = 150;
|
|
10
|
+
const tokens = 5000000000;
|
|
21
11
|
|
|
22
12
|
// Getting chain balance should result in a chain balance
|
|
23
13
|
test(`Get the chain balance`, async ({end, equal}) => {
|
|
24
|
-
const
|
|
14
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
25
15
|
|
|
26
|
-
const
|
|
27
|
-
const host = node.listen_ip;
|
|
28
|
-
const {kill} = node;
|
|
29
|
-
const pass = node.chain_rpc_pass;
|
|
30
|
-
const port = node.chain_rpc_port;
|
|
31
|
-
const {lnd} = node;
|
|
32
|
-
const user = node.chain_rpc_user;
|
|
33
|
-
|
|
34
|
-
const {address} = await createChainAddress({format, lnd});
|
|
16
|
+
const [{generate, lnd}] = nodes;
|
|
35
17
|
|
|
36
18
|
// The initial chain balance should be zero
|
|
37
19
|
{
|
|
@@ -41,40 +23,14 @@ test(`Get the chain balance`, async ({end, equal}) => {
|
|
|
41
23
|
}
|
|
42
24
|
|
|
43
25
|
// Generate some funds for LND
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const [block] = blocks;
|
|
47
|
-
|
|
48
|
-
const [coinbaseTransaction] = block.transaction_ids;
|
|
49
|
-
|
|
50
|
-
const {transaction} = chainSendTransaction({
|
|
51
|
-
tokens,
|
|
52
|
-
destination: address,
|
|
53
|
-
fee: defaultFee,
|
|
54
|
-
private_key: node.mining_key,
|
|
55
|
-
spend_transaction_id: coinbaseTransaction,
|
|
56
|
-
spend_vout: defaultVout,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Wait for generation to be over
|
|
60
|
-
await asyncRetry({interval, times}, async () => {
|
|
61
|
-
await mineTransaction({cert, host, pass, port, transaction, user});
|
|
62
|
-
|
|
63
|
-
if (!(await getChainBalance({lnd})).chain_balance) {
|
|
64
|
-
throw new Error('ExpectedChainBalanceReflected');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return;
|
|
68
|
-
});
|
|
26
|
+
await generate({count: 100});
|
|
69
27
|
|
|
70
28
|
// Check that the balance is updated
|
|
71
29
|
const postDeposit = await getChainBalance({lnd});
|
|
72
30
|
|
|
73
|
-
equal(postDeposit.chain_balance
|
|
74
|
-
|
|
75
|
-
kill();
|
|
31
|
+
equal(postDeposit.chain_balance >= tokens, true, 'Got funds');
|
|
76
32
|
|
|
77
|
-
await
|
|
33
|
+
await kill({});
|
|
78
34
|
|
|
79
35
|
return end();
|
|
80
36
|
});
|
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
const
|
|
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 {createChainAddress} = require('./../../');
|
|
5
|
-
const {
|
|
6
|
-
const {delay} = require('./../macros');
|
|
6
|
+
const {getChainBalance} = require('./../../');
|
|
7
7
|
const {getChainFeeEstimate} = require('./../../');
|
|
8
8
|
|
|
9
|
-
const expectedFee =
|
|
9
|
+
const expectedFee = 8650;
|
|
10
10
|
const expectedFeeRate = 50;
|
|
11
|
-
const format = '
|
|
11
|
+
const format = 'np2wpkh';
|
|
12
|
+
const size = 2;
|
|
13
|
+
const times = 200;
|
|
12
14
|
const tokens = 1e6;
|
|
13
15
|
|
|
14
16
|
// Getting a chain fee estimate should return an estimate of the chain fee
|
|
15
17
|
test(`Get chain fee estimate`, async ({end, equal}) => {
|
|
16
|
-
const
|
|
18
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
17
19
|
|
|
18
|
-
const {lnd} =
|
|
20
|
+
const [control, {lnd}] = nodes;
|
|
19
21
|
|
|
20
|
-
const address1 = (await createChainAddress({
|
|
22
|
+
const address1 = (await createChainAddress({lnd})).address;
|
|
21
23
|
const address2 = (await createChainAddress({format, lnd})).address;
|
|
22
24
|
|
|
25
|
+
// Generate coins for the node
|
|
26
|
+
await asyncRetry({times}, async () => {
|
|
27
|
+
if (!(await getChainBalance({lnd: control.lnd})).chain_balance) {
|
|
28
|
+
await control.generate({});
|
|
29
|
+
|
|
30
|
+
throw new Error('ExpectedChainBalance');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
23
34
|
const estimate = await getChainFeeEstimate({
|
|
24
|
-
lnd:
|
|
35
|
+
lnd: control.lnd,
|
|
25
36
|
send_to: [
|
|
26
37
|
{address: address1, tokens: tokens / [address1, address2].length},
|
|
27
38
|
{address: address2, tokens: tokens / [address1, address2].length},
|
|
@@ -31,7 +42,7 @@ test(`Get chain fee estimate`, async ({end, equal}) => {
|
|
|
31
42
|
equal(estimate.fee, expectedFee, 'Total fee is estimated');
|
|
32
43
|
equal(estimate.tokens_per_vbyte, expectedFeeRate, 'Fee per vbyte is given');
|
|
33
44
|
|
|
34
|
-
await
|
|
45
|
+
await kill({});
|
|
35
46
|
|
|
36
47
|
return end();
|
|
37
48
|
});
|
|
@@ -1,62 +1,35 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
3
|
const {test} = require('@alexbosworth/tap');
|
|
3
4
|
|
|
4
|
-
const {chainSendTransaction} = require('./../macros');
|
|
5
|
-
const {createChainAddress} = require('./../../');
|
|
6
|
-
const {delay} = require('./../macros');
|
|
7
|
-
const {generateBlocks} = require('./../macros');
|
|
8
5
|
const {getChainBalance} = require('./../../');
|
|
9
6
|
const {getChainTransactions} = require('./../../');
|
|
10
|
-
const {
|
|
11
|
-
const {mineTransaction} = require('./../macros');
|
|
12
|
-
const {spawnLnd} = require('./../macros');
|
|
13
|
-
const {waitForTermination} = require('./../macros');
|
|
14
|
-
const {waitForUtxo} = require('./../macros');
|
|
7
|
+
const {getWalletInfo} = require('./../../');
|
|
15
8
|
|
|
16
9
|
const count = 100;
|
|
17
10
|
const defaultFee = 1e3;
|
|
18
|
-
const defaultVout = 0;
|
|
19
|
-
const emptyChainBalance = 0;
|
|
20
11
|
const format = 'np2wpkh';
|
|
21
|
-
const
|
|
22
|
-
const times = 20;
|
|
23
|
-
const tokens = 1e8;
|
|
12
|
+
const times = 300;
|
|
24
13
|
|
|
25
14
|
// Getting chain transactions should list out the chain transactions
|
|
26
|
-
test(`Get chain transactions`, async ({end, equal,
|
|
27
|
-
const
|
|
15
|
+
test(`Get chain transactions`, async ({end, equal, strictSame}) => {
|
|
16
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
28
17
|
|
|
29
|
-
const
|
|
30
|
-
const host = node.listen_ip;
|
|
31
|
-
const {kill} = node;
|
|
32
|
-
const pass = node.chain_rpc_pass;
|
|
33
|
-
const port = node.chain_rpc_port;
|
|
34
|
-
const {lnd} = node;
|
|
35
|
-
const user = node.chain_rpc_user;
|
|
36
|
-
|
|
37
|
-
const {address} = await createChainAddress({format, lnd});
|
|
18
|
+
const [{generate, lnd}] = nodes;
|
|
38
19
|
|
|
39
20
|
// Generate some funds for LND
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const [block] = blocks;
|
|
21
|
+
await generate({count});
|
|
43
22
|
|
|
44
|
-
|
|
23
|
+
await asyncRetry({interval: 10, times: 1000}, async () => {
|
|
24
|
+
const wallet = await getWalletInfo({lnd});
|
|
45
25
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
fee: defaultFee,
|
|
50
|
-
private_key: node.mining_key,
|
|
51
|
-
spend_transaction_id: coinbaseTransaction,
|
|
52
|
-
spend_vout: defaultVout,
|
|
26
|
+
if (!wallet.is_synced_to_chain) {
|
|
27
|
+
throw new Error('ExpectedWalletSyncedToChain');
|
|
28
|
+
}
|
|
53
29
|
});
|
|
54
30
|
|
|
55
31
|
// Wait for generation to be over
|
|
56
|
-
await asyncRetry({
|
|
57
|
-
// Generate to confirm the tx
|
|
58
|
-
await mineTransaction({cert, host, pass, port, transaction, user});
|
|
59
|
-
|
|
32
|
+
await asyncRetry({times}, async () => {
|
|
60
33
|
const {transactions} = await getChainTransactions({lnd});
|
|
61
34
|
|
|
62
35
|
const [tx] = transactions;
|
|
@@ -70,16 +43,22 @@ test(`Get chain transactions`, async ({end, equal, fail, strictSame}) => {
|
|
|
70
43
|
|
|
71
44
|
const {transactions} = await getChainTransactions({lnd});
|
|
72
45
|
|
|
73
|
-
equal(transactions.length,
|
|
46
|
+
equal(transactions.length > 1, true, 'Transaction found');
|
|
74
47
|
|
|
75
48
|
const [tx] = transactions;
|
|
76
49
|
|
|
50
|
+
equal(!!tx.block_id, true, 'Transaction has block id');
|
|
51
|
+
equal(!!tx.confirmation_count, true, 'Transaction confirm count');
|
|
52
|
+
equal(!!tx.confirmation_height, true, 'Transaction confirm height');
|
|
53
|
+
equal(!!tx.created_at, true, 'Transaction record create time');
|
|
54
|
+
equal(tx.description, undefined, 'No tx description');
|
|
55
|
+
equal(tx.fee, undefined, 'No transaction fee');
|
|
56
|
+
equal(!!tx.id, true, 'Transaction id');
|
|
77
57
|
equal(tx.is_confirmed, true, 'Transaction is confirmed');
|
|
78
58
|
equal(tx.is_outgoing, false, 'Transaction is incoming');
|
|
79
|
-
|
|
80
|
-
equal(tx.tokens,
|
|
81
|
-
|
|
82
|
-
const wallet = await getWalletVersion({lnd});
|
|
59
|
+
equal(tx.output_addresses.length, 1, 'Tx output address');
|
|
60
|
+
equal(tx.tokens, 5000000000, 'Got coinbase reward tokens');
|
|
61
|
+
equal(!!tx.transaction, true, 'Got transaction hex');
|
|
83
62
|
|
|
84
63
|
const onlyAfter = await getChainTransactions({
|
|
85
64
|
lnd,
|
|
@@ -88,10 +67,11 @@ test(`Get chain transactions`, async ({end, equal, fail, strictSame}) => {
|
|
|
88
67
|
|
|
89
68
|
equal(onlyAfter.transactions.length, [].length, 'No transactions after');
|
|
90
69
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
70
|
+
const [height] = transactions
|
|
71
|
+
.map(n => n.confirmation_height)
|
|
72
|
+
.sort((a, b) => a - b);
|
|
73
|
+
|
|
74
|
+
const onlyBefore = await getChainTransactions({lnd, before: height});
|
|
95
75
|
|
|
96
76
|
equal(onlyBefore.transactions.length, [].length, 'No tx before');
|
|
97
77
|
|
|
@@ -103,9 +83,7 @@ test(`Get chain transactions`, async ({end, equal, fail, strictSame}) => {
|
|
|
103
83
|
|
|
104
84
|
strictSame(between.transactions.length, [tx].length, 'One transaction');
|
|
105
85
|
|
|
106
|
-
kill();
|
|
107
|
-
|
|
108
|
-
await waitForTermination({lnd});
|
|
86
|
+
await kill({});
|
|
109
87
|
|
|
110
88
|
return end();
|
|
111
89
|
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
|
-
const {createCluster} = require('./../macros');
|
|
4
4
|
const {getChannel} = require('./../../');
|
|
5
5
|
const {getChannels} = require('./../../');
|
|
6
6
|
const {setupChannel} = require('./../macros');
|
|
7
7
|
|
|
8
|
-
const confirmationCount = 20;
|
|
9
8
|
const {ceil} = Math;
|
|
9
|
+
const size = 2;
|
|
10
10
|
|
|
11
11
|
// Getting a channel should return channel details from the channel graph
|
|
12
12
|
test(`Get channel`, async ({end, equal}) => {
|
|
13
|
-
const
|
|
13
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
14
14
|
|
|
15
|
-
const {lnd} =
|
|
15
|
+
const [{generate, lnd}, target] = nodes;
|
|
16
16
|
|
|
17
|
-
await setupChannel({
|
|
17
|
+
await setupChannel({generate, lnd, to: target});
|
|
18
18
|
|
|
19
19
|
const [channel] = (await getChannels({lnd})).channels;
|
|
20
20
|
|
|
21
21
|
const details = await getChannel({lnd, id: channel.id});
|
|
22
22
|
|
|
23
23
|
equal(details.capacity, channel.capacity, 'Capacity');
|
|
24
|
-
equal(details.policies.length,
|
|
24
|
+
equal(details.policies.length, size, 'Policies for both nodes');
|
|
25
25
|
|
|
26
26
|
details.policies.forEach(policy => {
|
|
27
27
|
equal(policy.base_fee_mtokens, '1000', 'Base fee mtokens');
|
|
@@ -41,7 +41,7 @@ test(`Get channel`, async ({end, equal}) => {
|
|
|
41
41
|
|
|
42
42
|
equal(Date.now() - new Date(details.updated_at) < 1e5, true, 'Updated at');
|
|
43
43
|
|
|
44
|
-
await
|
|
44
|
+
await kill({});
|
|
45
45
|
|
|
46
46
|
return end();
|
|
47
47
|
});
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
4
|
const {getChannelBalance} = require('./../../');
|
|
4
|
-
const {spawnLnd} = require('./../macros');
|
|
5
|
-
const {waitForTermination} = require('./../macros');
|
|
6
5
|
|
|
7
6
|
const emptyBalance = 0;
|
|
8
7
|
|
|
9
8
|
// Getting channel balance should result in a channel balance
|
|
10
9
|
test(`Get the channel balance`, async ({end, equal}) => {
|
|
11
|
-
const {kill,
|
|
10
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
11
|
+
|
|
12
|
+
const [{lnd}] = nodes;
|
|
12
13
|
|
|
13
14
|
const result = await getChannelBalance({lnd});
|
|
14
15
|
|
|
15
16
|
equal(result.channel_balance, emptyBalance, 'Valid channel balance');
|
|
16
17
|
|
|
17
|
-
kill();
|
|
18
|
-
|
|
19
|
-
await waitForTermination({lnd});
|
|
18
|
+
await kill({});
|
|
20
19
|
|
|
21
20
|
return end();
|
|
22
21
|
});
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
1
2
|
const {test} = require('@alexbosworth/tap');
|
|
2
3
|
|
|
3
|
-
const {createCluster} = require('./../macros');
|
|
4
4
|
const {getChannels} = require('./../../');
|
|
5
5
|
const {getWalletInfo} = require('./../../');
|
|
6
6
|
const {setupChannel} = require('./../macros');
|
|
7
7
|
|
|
8
|
+
const anchorFeatureBit = 23;
|
|
8
9
|
const giveTokens = 1e5;
|
|
9
10
|
const remoteCsv = 40;
|
|
11
|
+
const size = 2;
|
|
10
12
|
|
|
11
13
|
// Getting channels should return the list of channels
|
|
12
14
|
test(`Get channels`, async ({end, equal, ok}) => {
|
|
13
|
-
const
|
|
15
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
14
16
|
|
|
15
|
-
const {generate} =
|
|
16
|
-
const {lnd} = cluster.control;
|
|
17
|
+
const [{generate, lnd}, target] = nodes;
|
|
17
18
|
|
|
18
19
|
const chan = await setupChannel({
|
|
20
|
+
generate,
|
|
19
21
|
lnd,
|
|
20
|
-
generate: cluster.generate,
|
|
21
22
|
give: giveTokens,
|
|
22
23
|
partner_csv_delay: remoteCsv,
|
|
23
|
-
to:
|
|
24
|
+
to: target,
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
const [channel] = (await getChannels({lnd})).channels;
|
|
27
28
|
const {features} = await getWalletInfo({lnd});
|
|
28
|
-
const [targetChan] = (await getChannels({lnd:
|
|
29
|
+
const [targetChan] = (await getChannels({lnd: target.lnd})).channels;
|
|
29
30
|
|
|
30
|
-
const isAnchors = !!features.find(n => n.bit ===
|
|
31
|
+
const isAnchors = !!features.find(n => n.bit === anchorFeatureBit);
|
|
31
32
|
|
|
32
33
|
equal(targetChan.is_partner_initiated, true, 'Self-init channel');
|
|
33
34
|
|
|
@@ -73,7 +74,7 @@ test(`Get channels`, async ({end, equal, ok}) => {
|
|
|
73
74
|
equal(channel.is_partner_initiated, false, 'Partner initiated channel');
|
|
74
75
|
equal(channel.is_private, false, 'Channel not private');
|
|
75
76
|
equal(channel.local_reserve, 10000, 'Local reserve');
|
|
76
|
-
equal(channel.partner_public_key,
|
|
77
|
+
equal(channel.partner_public_key, target.id, 'Pubkey');
|
|
77
78
|
equal(channel.pending_payments.length, 0, 'No pending payments');
|
|
78
79
|
equal(channel.received, 0, 'Channel received');
|
|
79
80
|
equal(channel.remote_balance, 100000, 'Channel remote balance');
|
|
@@ -83,7 +84,7 @@ test(`Get channels`, async ({end, equal, ok}) => {
|
|
|
83
84
|
equal(channel.transaction_vout, 0, 'Channel transactin vout');
|
|
84
85
|
equal(channel.unsettled_balance, 0, 'Channel unsettled balance');
|
|
85
86
|
|
|
86
|
-
await
|
|
87
|
+
await kill({});
|
|
87
88
|
|
|
88
89
|
return end();
|
|
89
90
|
});
|