ln-service 56.7.0 → 56.8.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -0
  3. package/package.json +10 -11
  4. package/test/autopilotrpc-integration/test_autopilot.js +30 -16
  5. package/test/chainrpc-integration/test_get_block.js +14 -11
  6. package/test/chainrpc-integration/test_get_height.js +10 -4
  7. package/test/chainrpc-integration/test_subscribe_to_blocks.js +10 -9
  8. package/test/chainrpc-integration/test_subscribe_to_chain_address.js +11 -9
  9. package/test/chainrpc-integration/test_subscribe_to_chain_spend.js +9 -8
  10. package/test/integration/test_add_peer.js +12 -6
  11. package/test/integration/test_cancel_pending_channel.js +9 -12
  12. package/test/integration/test_close_channel.js +12 -11
  13. package/test/integration/test_create_chain_address.js +5 -3
  14. package/test/integration/test_create_invoice.js +19 -15
  15. package/test/integration/test_decode_payment_request.js +19 -16
  16. package/test/integration/test_delete_payment.js +11 -30
  17. package/test/integration/test_delete_payments.js +8 -8
  18. package/test/integration/test_delete_pending_channel.js +13 -27
  19. package/test/integration/test_get_access_ids.js +7 -15
  20. package/test/integration/test_get_backup.js +12 -14
  21. package/test/integration/test_get_backups.js +11 -9
  22. package/test/integration/test_get_chain_balance.js +8 -8
  23. package/test/integration/test_get_chain_fee_estimate.js +8 -6
  24. package/test/integration/test_get_chain_transactions.js +22 -21
  25. package/test/integration/test_get_channel.js +19 -17
  26. package/test/integration/test_get_channel_balance.js +6 -4
  27. package/test/integration/test_get_channels.js +42 -39
  28. package/test/integration/test_get_closed_channels.js +95 -114
  29. package/test/integration/test_get_failed_payments.js +43 -42
  30. package/test/integration/test_get_fee_rates.js +13 -11
  31. package/test/integration/test_get_forwards.js +27 -24
  32. package/test/integration/test_get_invoice.js +31 -24
  33. package/test/integration/test_get_invoices.js +18 -15
  34. package/test/integration/test_get_methods.js +13 -16
  35. package/test/integration/test_get_network_centrality.js +15 -13
  36. package/test/integration/test_get_network_graph.js +36 -23
  37. package/test/integration/test_get_network_info.js +13 -11
  38. package/test/integration/test_get_node.js +27 -21
  39. package/test/integration/test_get_payments.js +20 -18
  40. package/test/integration/test_get_peers.js +16 -14
  41. package/test/integration/test_get_pending_coop.js +49 -39
  42. package/test/integration/test_get_pending_force.js +67 -90
  43. package/test/integration/test_get_pending_payments.js +23 -24
  44. package/test/integration/test_get_route_to_destination.js +15 -15
  45. package/test/integration/test_get_settlement_status.js +13 -9
  46. package/test/integration/test_get_utxos.js +13 -11
  47. package/test/integration/test_get_wallet_info.js +20 -16
  48. package/test/integration/test_grant_access.js +20 -23
  49. package/test/integration/test_open_channel.js +10 -8
  50. package/test/integration/test_open_channels.js +11 -10
  51. package/test/integration/test_pay.js +18 -27
  52. package/test/integration/test_pay_private_invoice.js +11 -24
  53. package/test/integration/test_payment_errors.js +10 -11
  54. package/test/integration/test_propose_channel.js +70 -105
  55. package/test/integration/test_push_funds.js +8 -10
  56. package/test/integration/test_rebalance.js +44 -32
  57. package/test/integration/test_recover_funds_from_channel.js +13 -11
  58. package/test/integration/test_recover_funds_from_channels.js +13 -11
  59. package/test/integration/test_remove_peer.js +8 -6
  60. package/test/integration/test_restrict_macaroon.js +8 -5
  61. package/test/integration/test_revoke_access.js +19 -24
  62. package/test/integration/test_send_message_to_peer.js +11 -6
  63. package/test/integration/test_send_to_chain_address.js +13 -12
  64. package/test/integration/test_send_to_chain_addresses.js +10 -8
  65. package/test/integration/test_sign_message.js +6 -4
  66. package/test/integration/test_stop_daemon.js +7 -4
  67. package/test/integration/test_subscribe_to_backups.js +7 -5
  68. package/test/integration/test_subscribe_to_channels.js +10 -21
  69. package/test/integration/test_subscribe_to_graph.js +17 -9
  70. package/test/integration/test_subscribe_to_invoices.js +10 -8
  71. package/test/integration/test_subscribe_to_open_requests.js +13 -12
  72. package/test/integration/test_subscribe_to_peer_messages.js +8 -5
  73. package/test/integration/test_subscribe_to_peers.js +7 -6
  74. package/test/integration/test_subscribe_to_rpc_requests.js +202 -191
  75. package/test/integration/test_subscribe_to_transactions.js +6 -4
  76. package/test/integration/test_trusted_funding.js +17 -11
  77. package/test/integration/test_update_routing_fees.js +8 -5
  78. package/test/integration/test_verify_access.js +8 -6
  79. package/test/integration/test_verify_backup.js +6 -6
  80. package/test/integration/test_verify_backups.js +6 -6
  81. package/test/integration/test_verify_message.js +5 -3
  82. package/test/invoicesrpc-integration/test_cancel_invoice.js +6 -5
  83. package/test/invoicesrpc-integration/test_get_sweep_transactions.js +6 -7
  84. package/test/invoicesrpc-integration/test_push_payment.js +7 -6
  85. package/test/invoicesrpc-integration/test_settle_invoice.js +10 -6
  86. package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +8 -7
  87. package/test/invoicesrpc-integration/test_subscribe_settle_invoice.js +8 -7
  88. package/test/peersrpc-integration/test_add_external_socket.js +7 -5
  89. package/test/peersrpc-integration/test_remove_external_socket.js +7 -5
  90. package/test/peersrpc-integration/test_update_alias.js +8 -6
  91. package/test/peersrpc-integration/test_update_color.js +8 -6
  92. package/test/routerrpc-integration/test_delete_forwarding_reputations.js +8 -6
  93. package/test/routerrpc-integration/test_disable_channel.js +6 -4
  94. package/test/routerrpc-integration/test_get_forwarding_confidence.js +7 -5
  95. package/test/routerrpc-integration/test_get_forwarding_reputations.js +12 -7
  96. package/test/routerrpc-integration/test_get_pathfinding_settings.js +7 -5
  97. package/test/routerrpc-integration/test_get_payment.js +10 -6
  98. package/test/routerrpc-integration/test_get_route_confidence.js +6 -4
  99. package/test/routerrpc-integration/test_get_route_through_hops.js +8 -7
  100. package/test/routerrpc-integration/test_is_destination_payable.js +48 -0
  101. package/test/routerrpc-integration/test_multipath_payment.js +8 -5
  102. package/test/routerrpc-integration/test_pay_via_payment_details.js +11 -9
  103. package/test/routerrpc-integration/test_pay_via_payment_request.js +11 -7
  104. package/test/routerrpc-integration/test_pay_via_routes.js +8 -11
  105. package/test/routerrpc-integration/test_probe_for_route.js +10 -7
  106. package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +10 -7
  107. package/test/routerrpc-integration/test_subscribe_to_forwards.js +23 -19
  108. package/test/routerrpc-integration/test_subscribe_to_past_payments.js +8 -6
  109. package/test/routerrpc-integration/test_subscribe_to_payments.js +18 -17
  110. package/test/routerrpc-integration/test_update_pathfinding_settings.js +8 -6
  111. package/test/runner.js +30 -0
  112. package/test/signerrpc-integration/test_begin_group_signing_session.js +8 -5
  113. package/test/signerrpc-integration/test_diffie_hellman_compute_secret.js +7 -4
  114. package/test/signerrpc-integration/test_sign_bytes.js +5 -3
  115. package/test/signerrpc-integration/test_sign_taproot.js +6 -4
  116. package/test/signerrpc-integration/test_sign_transaction.js +5 -3
  117. package/test/signerrpc-integration/test_verify_bytes_signature.js +5 -4
  118. package/test/tower_clientrpc-integration/test_connect_watchtower.js +7 -4
  119. package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +7 -4
  120. package/test/tower_serverrpc-integration/test_get_tower_server_info.js +6 -3
  121. package/test/versionrpc-integration/test_get_wallet_version.js +16 -12
  122. package/test/walletrpc-integration/test_broadcast_chain_transaction.js +5 -3
  123. package/test/walletrpc-integration/test_fund_psbt.js +5 -10
  124. package/test/walletrpc-integration/test_get_chain_addresses.js +9 -7
  125. package/test/walletrpc-integration/test_get_chain_fee_rate.js +5 -3
  126. package/test/walletrpc-integration/test_get_locked_utxos.js +8 -20
  127. package/test/walletrpc-integration/test_get_master_public_keys.js +9 -6
  128. package/test/walletrpc-integration/test_get_public_key.js +5 -3
  129. package/test/walletrpc-integration/test_lock_utxo.js +9 -5
  130. package/test/walletrpc-integration/test_partially_sign_psbt.js +7 -4
  131. package/test/walletrpc-integration/test_request_chain_fee_increase.js +8 -4
  132. package/test/walletrpc-integration/test_send_to_chain_output_scripts.js +7 -4
  133. package/test/walletrpc-integration/test_sign_chain_address_message.js +6 -6
  134. package/test/walletrpc-integration/test_sign_psbt.js +6 -4
  135. package/test/walletrpc-integration/test_unlock_utxo.js +8 -4
  136. package/test/walletrpc-integration/test_update_chain_transaction.js +5 -3
  137. package/test/walletrpc-integration/test_verify_chain_address_message.js +6 -4
  138. package/test/extra-integration/test_change_password.js +0 -15
  139. package/test/extra-integration/test_get_wallet_status.js +0 -45
  140. package/test/extra-integration/test_no_macaroon.js +0 -20
  141. package/test/extra-integration/tower_clientrpc-integration/test_disconnect_watchtower.js +0 -51
  142. package/test/extra-integration/tower_clientrpc-integration/test_update_connected_watchtower.js +0 -76
  143. package/test/grpc-integration/test_authenticated_lnd_grpc.js +0 -40
  144. package/test/routers-integration/test_gateway_router.js +0 -87
@@ -1,14 +1,17 @@
1
+ const {deepStrictEqual} = require('node:assert').strict;
2
+ const {strictEqual} = require('node:assert').strict;
3
+ const test = require('node:test');
4
+
1
5
  const asyncRetry = require('async/retry');
6
+ const {setupChannel} = require('ln-docker-daemons');
2
7
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
8
 
5
9
  const {addPeer} = require('./../../');
6
10
  const {createInvoice} = require('./../../');
7
- const {delay} = require('./../macros');
8
11
  const {getForwards} = require('./../../');
9
12
  const {pay} = require('./../../');
10
- const {setupChannel} = require('./../macros');
11
13
 
14
+ const delay = n => new Promise(resolve => setTimeout(resolve, n));
12
15
  const interval = 100;
13
16
  const limit = 1;
14
17
  const size = 3;
@@ -16,7 +19,7 @@ const times = 1000;
16
19
  const tokens = 100;
17
20
 
18
21
  // Getting forwarded payments should return all forwarded payments
19
- test('Get forwards', async ({end, equal, strictSame}) => {
22
+ test('Get forwards', async () => {
20
23
  const {kill, nodes} = await spawnLightningCluster({size});
21
24
 
22
25
  const [{generate, lnd}, target, remote] = nodes;
@@ -46,37 +49,37 @@ test('Get forwards', async ({end, equal, strictSame}) => {
46
49
 
47
50
  const page1 = await getForwards({limit, lnd: target.lnd});
48
51
 
49
- equal(!!page1.next, true, 'Page 1 leads to page 2');
52
+ strictEqual(!!page1.next, true, 'Page 1 leads to page 2');
50
53
 
51
54
  {
52
55
  const [forward] = page1.forwards;
53
56
 
54
- equal(!!forward.created_at, true, 'Forward created at');
55
- equal(forward.fee, 1, 'Forward fee charged');
56
- equal(forward.fee_mtokens, '1000', 'Forward fee charged');
57
- equal(!!forward.incoming_channel, true, 'Forward incoming channel');
58
- equal(forward.tokens, 100, 'Forwarded tokens count');
59
- equal(!!forward.outgoing_channel, true, 'Forward outgoing channel');
57
+ strictEqual(!!forward.created_at, true, 'Forward created at');
58
+ strictEqual(forward.fee, 1, 'Forward fee charged');
59
+ strictEqual(forward.fee_mtokens, '1000', 'Forward fee charged');
60
+ strictEqual(!!forward.incoming_channel, true, 'Forward incoming channel');
61
+ strictEqual(forward.tokens, 100, 'Forwarded tokens count');
62
+ strictEqual(!!forward.outgoing_channel, true, 'Forward outgoing channel');
60
63
  }
61
64
 
62
65
  const page2 = await getForwards({lnd: target.lnd, token: page1.next});
63
66
 
64
- equal(!!page2.next, true, 'Page 2 leads to page 3');
67
+ strictEqual(!!page2.next, true, 'Page 2 leads to page 3');
65
68
 
66
69
  {
67
70
  const [forward] = page2.forwards;
68
71
 
69
- equal(forward.tokens, 101, 'Second forward tokens count');
72
+ strictEqual(forward.tokens, 101, 'Second forward tokens count');
70
73
  }
71
74
 
72
75
  const page3 = await getForwards({lnd: target.lnd, token: page2.next});
73
76
 
74
- equal(!!page3.next, true, 'Page 3 leads to page 4');
77
+ strictEqual(!!page3.next, true, 'Page 3 leads to page 4');
75
78
 
76
79
  {
77
80
  const [forward] = page3.forwards;
78
81
 
79
- equal(forward.tokens, 102, 'Third forward tokens count');
82
+ strictEqual(forward.tokens, 102, 'Third forward tokens count');
80
83
 
81
84
  // Check "before" based paging
82
85
  const prev0 = await getForwards({
@@ -87,17 +90,17 @@ test('Get forwards', async ({end, equal, strictSame}) => {
87
90
 
88
91
  const [firstForward] = prev0.forwards;
89
92
 
90
- equal(firstForward.tokens, 100, 'Previous row #1');
93
+ strictEqual(firstForward.tokens, 100, 'Previous row #1');
91
94
 
92
95
  const prev1 = await getForwards({lnd: target.lnd, token: prev0.next});
93
96
 
94
97
  const [secondForward] = prev1.forwards;
95
98
 
96
- equal(secondForward.tokens, 101, 'Previous row #2');
99
+ strictEqual(secondForward.tokens, 101, 'Previous row #2');
97
100
 
98
101
  const prev2 = await getForwards({lnd: target.lnd, token: prev1.next});
99
102
 
100
- equal(prev2.next, undefined, 'Ended paging of previous rows');
103
+ strictEqual(prev2.next, undefined, 'Ended paging of previous rows');
101
104
 
102
105
  // Check "after" based paging
103
106
  const after0 = await getForwards({
@@ -107,23 +110,23 @@ test('Get forwards', async ({end, equal, strictSame}) => {
107
110
  lnd: target.lnd,
108
111
  });
109
112
 
110
- strictSame(after0.forwards, prev0.forwards, 'After is inclusive of start');
113
+ deepStrictEqual(after0.forwards, prev0.forwards, 'After is inclusive');
111
114
 
112
115
  const after1 = await getForwards({lnd: target.lnd, token: after0.next});
113
116
 
114
- strictSame(after1.forwards, prev1.forwards, 'Iterating before, after');
117
+ deepStrictEqual(after1.forwards, prev1.forwards, 'Iterating before');
115
118
 
116
119
  const after2 = await getForwards({lnd: target.lnd, token: after1.next});
117
120
 
118
- equal(after2.next, undefined, 'Before is non-inclusive');
121
+ strictEqual(after2.next, undefined, 'Before is non-inclusive');
119
122
  }
120
123
 
121
124
  const page4 = await getForwards({lnd: target.lnd, token: page3.next});
122
125
 
123
- equal(page4.forwards.length, [].length, 'Page 4 has no results');
124
- equal(page4.next, undefined, 'Page 4 leads to nowhere');
126
+ strictEqual(page4.forwards.length, [].length, 'Page 4 has no results');
127
+ strictEqual(page4.next, undefined, 'Page 4 leads to nowhere');
125
128
 
126
129
  await kill({});
127
130
 
128
- return end();
131
+ return;
129
132
  });
@@ -1,10 +1,12 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const {setupChannel} = require('ln-docker-daemons');
1
5
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
6
 
4
7
  const {createInvoice} = require('./../../');
5
8
  const {getInvoice} = require('./../../');
6
9
  const {pay} = require('./../../');
7
- const {setupChannel} = require('./../macros');
8
10
 
9
11
  const description = 'description';
10
12
  const secret = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f';
@@ -12,49 +14,54 @@ const size = 2;
12
14
  const tokens = 42;
13
15
 
14
16
  // getInvoice results in invoice details
15
- test(`Get an invoice`, async ({end, equal}) => {
17
+ test(`Get an invoice`, async () => {
16
18
  const {kill, nodes} = await spawnLightningCluster({size});
17
19
 
18
20
  const [{generate, lnd}, target] = nodes;
19
21
 
20
- const channel = await setupChannel({generate, lnd, give: 1e5, to: target});
22
+ const channel = await setupChannel({
23
+ generate,
24
+ lnd,
25
+ give_tokens: 1e5,
26
+ to: target,
27
+ });
21
28
 
22
29
  const created = await createInvoice({description, lnd, secret, tokens});
23
30
 
24
31
  const invoice = await getInvoice({lnd, id: created.id});
25
32
 
26
- equal(invoice.description, description, 'Invoice description');
27
- equal(invoice.is_private, false, 'Invoice is public');
28
- equal(invoice.received, 0, 'Invoice received tokens');
29
- equal(invoice.received_mtokens, '0', 'Invoice received mtokens');
30
- equal(invoice.secret, secret, 'Invoice secret');
31
- equal(invoice.tokens, tokens, 'Invoice tokens');
33
+ strictEqual(invoice.description, description, 'Invoice description');
34
+ strictEqual(invoice.is_private, false, 'Invoice is public');
35
+ strictEqual(invoice.received, 0, 'Invoice received tokens');
36
+ strictEqual(invoice.received_mtokens, '0', 'Invoice received mtokens');
37
+ strictEqual(invoice.secret, secret, 'Invoice secret');
38
+ strictEqual(invoice.tokens, tokens, 'Invoice tokens');
32
39
 
33
40
  await pay({lnd: target.lnd, request: created.request});
34
41
 
35
42
  const paid = await getInvoice({lnd, id: created.id});
36
43
 
37
44
  if (!!paid.payments.length) {
38
- equal(paid.payments.length, [created.request].length, 'Paid only once');
45
+ strictEqual(paid.payments.length, [created.request].length, 'Paid once');
39
46
 
40
47
  const [payment] = paid.payments;
41
48
 
42
- equal(payment.canceled_at, undefined, 'Payment was not canceled');
43
- equal(!!payment.confirmed_at, true, 'Payment settle date returned');
44
- equal(!!payment.created_at, true, 'Payment first held date returned');
45
- equal(!!payment.created_height, true, 'Payment height');
46
- equal(payment.in_channel, channel.id, 'Payment channel id returned');
47
- equal(payment.is_canceled, false, 'Payment not canceled');
48
- equal(payment.is_confirmed, true, 'Payment was settled');
49
- equal(payment.is_held, false, 'Payment is no longer held');
50
- equal(payment.mtokens, (BigInt(tokens) * BigInt(1e3)).toString(), 'Mtoks');
51
- equal(payment.pending_index, undefined, 'Pending index not defined');
52
- equal(payment.tokens, tokens, 'Payment tokens returned');
49
+ strictEqual(payment.canceled_at, undefined, 'Payment was not canceled');
50
+ strictEqual(!!payment.confirmed_at, true, 'Payment settle date returned');
51
+ strictEqual(!!payment.created_at, true, 'Payment first held date');
52
+ strictEqual(!!payment.created_height, true, 'Payment height');
53
+ strictEqual(payment.in_channel, channel.id, 'Payment channel id returned');
54
+ strictEqual(payment.is_canceled, false, 'Payment not canceled');
55
+ strictEqual(payment.is_confirmed, true, 'Payment was settled');
56
+ strictEqual(payment.is_held, false, 'Payment is no longer held');
57
+ strictEqual(payment.mtokens, (BigInt(tokens) * BigInt(1e3)).toString());
58
+ strictEqual(payment.pending_index, undefined, 'Pending index not defined');
59
+ strictEqual(payment.tokens, tokens, 'Payment tokens returned');
53
60
  }
54
61
 
55
- equal(paid.is_confirmed, true, 'Invoice has been paid');
62
+ strictEqual(paid.is_confirmed, true, 'Invoice has been paid');
56
63
 
57
64
  await kill({});
58
65
 
59
- return end();
66
+ return;
60
67
  });
@@ -1,6 +1,9 @@
1
+ const {deepStrictEqual} = require('node:assert').strict;
2
+ const {strictEqual} = require('node:assert').strict;
3
+ const test = require('node:test');
4
+
1
5
  const asyncEach = require('async/each');
2
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
7
 
5
8
  const {cancelHodlInvoice} = require('./../../');
6
9
  const {createInvoice} = require('./../../');
@@ -9,7 +12,7 @@ const {getInvoices} = require('./../../');
9
12
  const limit = 1;
10
13
 
11
14
  // createInvoice should result in a created invoice
12
- test(`Create an invoice`, async ({end, equal, strictSame}) => {
15
+ test(`Create an invoice`, async () => {
13
16
  const {kill, nodes} = await spawnLightningCluster({});
14
17
 
15
18
  try {
@@ -25,15 +28,15 @@ test(`Create an invoice`, async ({end, equal, strictSame}) => {
25
28
 
26
29
  const firstPage = await getInvoices({limit, lnd});
27
30
 
28
- equal(!!firstPage.next, true, 'First page has a next token');
31
+ strictEqual(!!firstPage.next, true, 'First page has a next token');
29
32
 
30
33
  const secondPage = await getInvoices({lnd, token: firstPage.next});
31
34
 
32
- equal(!!secondPage.next, true, 'Second page has a next token');
35
+ strictEqual(!!secondPage.next, true, 'Second page has a next token');
33
36
 
34
37
  const thirdPage = await getInvoices({lnd, token: secondPage.next});
35
38
 
36
- equal(!!thirdPage.next, false, 'Third page has no next token');
39
+ strictEqual(!!thirdPage.next, false, 'Third page has no next token');
37
40
 
38
41
  const receivedInvoices = []
39
42
  .concat(firstPage.invoices)
@@ -43,28 +46,28 @@ test(`Create an invoice`, async ({end, equal, strictSame}) => {
43
46
  receivedInvoices.forEach((invoice, i) => {
44
47
  const expected = invoices[i];
45
48
 
46
- equal(invoice.chain_address, expected.chain_address, 'Chain address');
47
- equal(invoice.confirmed_at, expected.confirmed_at, 'Confirmed at');
48
- equal(invoice.id, expected.id, 'Invoice id');
49
- equal(invoice.request, expected.request, 'Payment request');
50
- equal(invoice.secret, expected.secret, 'Payment secret');
51
- equal(invoice.tokens, expected.tokens, 'Tokens');
49
+ strictEqual(invoice.chain_address, expected.chain_address, 'Address');
50
+ strictEqual(invoice.confirmed_at, expected.confirmed_at, 'Confirmed at');
51
+ strictEqual(invoice.id, expected.id, 'Invoice id');
52
+ strictEqual(invoice.request, expected.request, 'Payment request');
53
+ strictEqual(invoice.secret, expected.secret, 'Payment secret');
54
+ strictEqual(invoice.tokens, expected.tokens, 'Tokens');
52
55
  });
53
56
 
54
57
  const reversed = invoices.slice().reverse();
55
58
 
56
- await asyncEach(reversed.filter((n, i) => !!i), async (invoice) => {
59
+ await asyncEach(reversed.filter((n, i) => !!i), async invoice => {
57
60
  return await cancelHodlInvoice({lnd, id: invoice.id});
58
61
  });
59
62
 
60
63
  const unconfirmed = await getInvoices({limit, lnd, is_unconfirmed: true});
61
64
 
62
- strictSame(unconfirmed, thirdPage, 'Pending invoices are ignored');
65
+ deepStrictEqual(unconfirmed, thirdPage, 'Pending invoices are ignored');
63
66
  } catch (err) {
64
- equal(err, null, 'No error is expected');
67
+ strictEqual(err, null, 'No error is expected');
65
68
  }
66
69
 
67
70
  await kill({});
68
71
 
69
- return end();
72
+ return;
70
73
  });
@@ -1,33 +1,30 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
5
 
4
6
  const {getMethods} = require('./../../');
5
7
 
8
+ const {isArray} = Array;
9
+
6
10
  // Getting LND methods should result in LND methods returned
7
- test(`Get LND methods`, async ({end, equal, type}) => {
11
+ test(`Get LND methods`, async () => {
8
12
  const {kill, nodes} = await spawnLightningCluster({});
9
13
 
10
14
  const [{lnd}] = nodes;
11
15
 
12
- try {
13
- const {methods} = await getMethods({lnd});
14
-
15
- const [method] = methods;
16
+ const {methods} = await getMethods({lnd});
16
17
 
17
- type(method.endpoint, 'string', 'Has endpoint path');
18
- type(method.permissions, Array, 'Has array of permissions');
18
+ const [method] = methods;
19
19
 
20
- const [permission] = method.permissions;
20
+ strictEqual(typeof method.endpoint, 'string', 'Has endpoint path');
21
+ strictEqual(isArray(method.permissions), true, 'Has array of permissions');
21
22
 
22
- type(permission, 'string', 'Has permission');
23
- } catch (err) {
24
- const [code, message] = err;
23
+ const [permission] = method.permissions;
25
24
 
26
- equal(code, 501, 'Method not supported yet');
27
- equal(message, 'ListPermissionsMethodNotSupported', 'Not supported msg');
28
- }
25
+ strictEqual(typeof permission, 'string', 'Has permission');
29
26
 
30
27
  await kill({});
31
28
 
32
- return end();
29
+ return;
33
30
  });
@@ -1,18 +1,20 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const asyncRetry = require('async/retry');
5
+ const {setupChannel} = require('ln-docker-daemons');
2
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
7
 
5
8
  const {addPeer} = require('./../../');
6
9
  const {getNetworkCentrality} = require('./../../');
7
10
  const {getWalletInfo} = require('./../../');
8
- const {setupChannel} = require('./../macros');
9
11
 
10
12
  const interval = 100;
11
13
  const size = 3;
12
14
  const times = 800;
13
15
 
14
16
  // Getting the network centrality should return the centrality scores
15
- test(`Get network centrality`, async ({end, equal, strictSame}) => {
17
+ test(`Get network centrality`, async () => {
16
18
  const {kill, nodes} = await spawnLightningCluster({size});
17
19
 
18
20
  const [control, target, remote] = nodes;
@@ -49,20 +51,20 @@ test(`Get network centrality`, async ({end, equal, strictSame}) => {
49
51
  throw new Error('WrongBetweennessScore');
50
52
  }
51
53
 
52
- equal(controlScore.betweenness, 0, 'No centrality on control');
53
- equal(controlScore.betweenness_normalized, 0, 'No control centrality');
54
- equal(remoteScore.betweenness, 0, 'No centrality on remote');
55
- equal(remoteScore.betweenness_normalized, 0, 'No centrality on remote');
56
- equal(targetScore.betweenness, 1e6, 'Centrality around target');
57
- equal(targetScore.betweenness_normalized, 1e6, 'Centrality at target');
54
+ strictEqual(controlScore.betweenness, 0, 'No centrality on control');
55
+ strictEqual(controlScore.betweenness_normalized, 0, 'No centrality');
56
+ strictEqual(remoteScore.betweenness, 0, 'No centrality on remote');
57
+ strictEqual(remoteScore.betweenness_normalized, 0, 'No centrality');
58
+ strictEqual(targetScore.betweenness, 1e6, 'Centrality around target');
59
+ strictEqual(targetScore.betweenness_normalized, 1e6, 'Centrality');
58
60
 
59
61
  return;
60
62
  });
61
63
  } catch (err) {
62
- equal(err, null, 'Expected no error');
63
- } finally {
64
- await kill({});
64
+ strictEqual(err, null, 'Expected no error');
65
65
  }
66
66
 
67
- return end();
67
+ await kill({});
68
+
69
+ return;
68
70
  });
@@ -1,10 +1,12 @@
1
+ const {deepStrictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const asyncRetry = require('async/retry');
5
+ const {setupChannel} = require('ln-docker-daemons');
2
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
7
 
5
8
  const {getNetworkGraph} = require('./../../');
6
9
  const {getNode} = require('./../../');
7
- const {setupChannel} = require('./../macros');
8
10
 
9
11
  const {ceil} = Math;
10
12
  const interval = 250;
@@ -12,7 +14,7 @@ const size = 3;
12
14
  const times = 50;
13
15
 
14
16
  // Getting the network graph should return the public nodes and connections
15
- test(`Get network graph`, async ({end, equal, strictSame}) => {
17
+ test(`Get network graph`, async () => {
16
18
  const {kill, nodes} = await spawnLightningCluster({size});
17
19
 
18
20
  const [control, target] = nodes;
@@ -40,35 +42,46 @@ test(`Get network graph`, async ({end, equal, strictSame}) => {
40
42
  if (!!nodeDetails && !!nodeDetails.channels.length) {
41
43
  const [chan] = nodeDetails.channels;
42
44
 
43
- strictSame(chan, channel, 'Graph channel matches node details channel');
45
+ deepStrictEqual(chan, channel, 'Graph channel matches node details');
44
46
  }
45
47
 
46
- equal(node.alias, control.id.slice(0, 20), 'Node alias is own');
47
- equal(node.color, '#3399ff', 'Node color is default');
48
- equal(node.public_key, control.id, 'Node pubkey is own');
49
- equal(node.sockets.length, 1, 'Socket');
50
- equal(new Date() - new Date(node.updated_at) < 1e5, true, 'Recent update');
48
+ deepStrictEqual(node.alias, control.id.slice(0, 20), 'Node alias is own');
49
+ deepStrictEqual(node.color, '#3399ff', 'Node color is default');
50
+ deepStrictEqual(node.public_key, control.id, 'Node pubkey is own');
51
+ deepStrictEqual(node.sockets.length, 1, 'Socket');
52
+ deepStrictEqual(new Date() - new Date(node.updated_at) < 1e5, true, 'At');
51
53
 
52
54
  channel.policies.forEach(policy => {
53
- equal(policy.base_fee_mtokens, '1000', 'Default channel base fee');
54
- equal([40, 80].includes(policy.cltv_delta), true, 'Default CLTV delta');
55
- equal(policy.fee_rate, 1, 'Default channel fee rate');
56
- equal(policy.is_disabled, false, 'Channels are active');
57
- equal(policy.max_htlc_mtokens, `${ceil(channel.capacity * 0.99)}000`);
58
- equal(!!policy.min_htlc_mtokens, true, 'Default min htlc value');
59
- equal(!!policy.public_key, true, 'Policy has public key');
60
- equal(new Date() - new Date(policy.updated_at) < 1e5, true, 'Updated at');
55
+ deepStrictEqual(policy.base_fee_mtokens, '1000', 'Default channel base');
56
+ deepStrictEqual([40, 80].includes(policy.cltv_delta), true, 'Cltv delta');
57
+ deepStrictEqual(policy.fee_rate, 1, 'Default channel fee rate');
58
+ deepStrictEqual(policy.is_disabled, false, 'Channels are active');
59
+ deepStrictEqual(
60
+ policy.max_htlc_mtokens,
61
+ `${ceil(channel.capacity * 0.99)}000`
62
+ );
63
+ deepStrictEqual(!!policy.min_htlc_mtokens, true, 'Default min htlc value');
64
+ deepStrictEqual(!!policy.public_key, true, 'Policy has public key');
65
+ deepStrictEqual(new Date()-new Date(policy.updated_at) < 1e5, true, 'At');
61
66
 
62
67
  return;
63
68
  });
64
69
 
65
- equal(channel.capacity, expectedChannel.capacity, 'Channel capacity');
66
- equal(channel.id, expectedChannel.id, 'Channel id');
67
- equal(channel.transaction_id, expectedChannel.transaction_id, 'Chan tx id');
68
- equal(channel.transaction_vout, expectedChannel.transaction_vout, 'Tx Vout');
69
- equal(new Date() - new Date(channel.updated_at) < 1e5, true, 'Updated at');
70
+ deepStrictEqual(channel.capacity, expectedChannel.capacity, 'Capacity');
71
+ deepStrictEqual(channel.id, expectedChannel.id, 'Channel id');
72
+ deepStrictEqual(channel.transaction_id, expectedChannel.transaction_id, 'T');
73
+ deepStrictEqual(
74
+ channel.transaction_vout,
75
+ expectedChannel.transaction_vout,
76
+ 'Tx Vout'
77
+ );
78
+ deepStrictEqual(
79
+ new Date() - new Date(channel.updated_at) < 1e5,
80
+ true,
81
+ 'Updated at'
82
+ );
70
83
 
71
84
  await kill({});
72
85
 
73
- return end();
86
+ return;
74
87
  });
@@ -1,14 +1,16 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
4
+ const {setupChannel} = require('ln-docker-daemons');
1
5
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
- const {test} = require('@alexbosworth/tap');
3
6
 
4
7
  const {getNetworkInfo} = require('./../../');
5
- const {setupChannel} = require('./../macros');
6
8
 
7
9
  const size = 2;
8
10
  const tokens = 1e6;
9
11
 
10
12
  // Getting the network info should return basic network statistics
11
- test(`Get network info`, async ({end, equal}) => {
13
+ test(`Get network info`, async () => {
12
14
  const {kill, nodes} = await spawnLightningCluster({size});
13
15
 
14
16
  const [{generate, lnd}, target] = nodes;
@@ -17,15 +19,15 @@ test(`Get network info`, async ({end, equal}) => {
17
19
 
18
20
  const result = await getNetworkInfo({lnd});
19
21
 
20
- equal(result.average_channel_size, tokens, 'Average channel size');
21
- equal(result.channel_count, 1, 'Channel count');
22
- equal(result.max_channel_size, tokens, 'Maximum channel size');
23
- equal(result.median_channel_size, tokens, 'Median channel size');
24
- equal(result.min_channel_size, tokens, 'Minimum channel size');
25
- equal(result.not_recently_updated_policy_count, 0, 'Not updated count');
26
- equal(result.total_capacity, tokens, 'Total capacity');
22
+ strictEqual(result.average_channel_size, tokens, 'Average channel size');
23
+ strictEqual(result.channel_count, 1, 'Channel count');
24
+ strictEqual(result.max_channel_size, tokens, 'Maximum channel size');
25
+ strictEqual(result.median_channel_size, tokens, 'Median channel size');
26
+ strictEqual(result.min_channel_size, tokens, 'Minimum channel size');
27
+ strictEqual(result.not_recently_updated_policy_count, 0, 'No updated count');
28
+ strictEqual(result.total_capacity, tokens, 'Total capacity');
27
29
 
28
30
  await kill({});
29
31
 
30
- return end();
32
+ return;
31
33
  });
@@ -1,12 +1,13 @@
1
+ const {strictEqual} = require('node:assert').strict;
2
+ const test = require('node:test');
3
+
1
4
  const asyncRetry = require('async/retry');
5
+ const {setupChannel} = require('ln-docker-daemons');
2
6
  const {spawnLightningCluster} = require('ln-docker-daemons');
3
- const {test} = require('@alexbosworth/tap');
4
7
 
5
8
  const {addPeer} = require('./../../');
6
- const {delay} = require('./../macros');
7
9
  const {getIdentity} = require('./../../');
8
10
  const {getNode} = require('./../../');
9
- const {setupChannel} = require('./../macros');
10
11
  const {updateRoutingFees} = require('./../../');
11
12
 
12
13
  const baseFee = 1337;
@@ -15,6 +16,7 @@ const cltvDelta = 42;
15
16
  const confirmationCount = 20;
16
17
  const defaultFee = 1e3;
17
18
  const defaultAliasLength = '00000000000000000000'.length;
19
+ const delay = n => new Promise(resolve => setTimeout(resolve, n));
18
20
  const feeRate = 21;
19
21
  const interval = 10;
20
22
  const mtokPerTok = BigInt(1e3);
@@ -22,7 +24,7 @@ const size = 3;
22
24
  const times = 1000;
23
25
 
24
26
  // Getting a node should return the public graph node info
25
- test(`Get node`, async ({end, equal, strictSame}) => {
27
+ test(`Get node`, async () => {
26
28
  const {kill, nodes} = await spawnLightningCluster({size});
27
29
 
28
30
  const [{generate, id, lnd}, target, remote] = nodes;
@@ -65,7 +67,7 @@ test(`Get node`, async ({end, equal, strictSame}) => {
65
67
  public_key: id,
66
68
  });
67
69
 
68
- equal(channels.length, [].length, 'Channels are omitted')
70
+ strictEqual(channels.length, [].length, 'Channels are omitted');
69
71
  }
70
72
 
71
73
  if (!!node.channels.length) {
@@ -73,27 +75,31 @@ test(`Get node`, async ({end, equal, strictSame}) => {
73
75
 
74
76
  const policy = policies.find(n => n.public_key === id);
75
77
 
76
- equal(BigInt(policy.base_fee_mtokens), BigInt(baseFee)*mtokPerTok, 'bf');
77
- equal(policy.cltv_delta, cltvDelta, 'Got expected cltv delta');
78
- equal(policy.fee_rate, feeRate, 'Got expected fee rate');
79
- equal(policy.is_disabled, false, 'Channel is not disabled');
80
- equal(policy.max_htlc_mtokens, '990000000', 'Max HTLC mtokens returned');
81
- equal(policy.min_htlc_mtokens, '1000', 'Min HTLC mtokens returned');
78
+ strictEqual(
79
+ BigInt(policy.base_fee_mtokens),
80
+ BigInt(baseFee) * mtokPerTok,
81
+ 'bf'
82
+ );
83
+ strictEqual(policy.cltv_delta, cltvDelta, 'Got expected cltv delta');
84
+ strictEqual(policy.fee_rate, feeRate, 'Got expected fee rate');
85
+ strictEqual(policy.is_disabled, false, 'Channel is not disabled');
86
+ strictEqual(policy.max_htlc_mtokens, '990000000', 'Max HTLC returned');
87
+ strictEqual(policy.min_htlc_mtokens, '1000', 'Min HTLC returned');
82
88
  }
83
89
 
84
90
  const [socket] = node.sockets;
85
91
 
86
- equal(node.alias, id.slice(0, defaultAliasLength), 'Alias');
87
- equal(node.color, '#3399ff', 'Color');
88
- equal(node.sockets.length, 1, 'Socket');
89
- equal(!!socket.socket, true, 'Ip, port');
90
- equal(socket.type, 'tcp', 'Socket type');
91
- equal(node.updated_at.length, 24, 'Update date');
92
+ strictEqual(node.alias, id.slice(0, defaultAliasLength), 'Alias');
93
+ strictEqual(node.color, '#3399ff', 'Color');
94
+ strictEqual(node.sockets.length, 1, 'Socket');
95
+ strictEqual(!!socket.socket, true, 'Ip, port');
96
+ strictEqual(socket.type, 'tcp', 'Socket type');
97
+ strictEqual(node.updated_at.length, 24, 'Update date');
92
98
  } catch (err) {
93
- strictSame(err, null, 'Expected no error');
94
- } finally {
95
- await kill({});
99
+ strictEqual(err, null, 'Expected no error');
96
100
  }
97
101
 
98
- return end();
102
+ await kill({});
103
+
104
+ return;
99
105
  });