ln-service 53.5.0 → 53.7.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Versions
2
2
 
3
+ ## 53.7.0
4
+
5
+ - `payViaRoutes`, `subscribeToPayViaRoutes`: Add support for relay messages
6
+
7
+ ## 53.6.0
8
+
9
+ - `partiallySignPsbt`: Add method to add a partial signature to a PSBT
10
+
11
+ ## 53.5.2
12
+
13
+ - `getPayments`: Correct paging issue that prevented paging through all results
14
+
3
15
  ## 53.5.0
4
16
 
5
17
  - `createWallet`: Add support for returning the admin `macaroon`
package/README.md CHANGED
@@ -187,6 +187,7 @@ for `unlocker` methods.
187
187
  - [openChannel](#openchannel) - Open a new channel
188
188
  - [openChannels](#openchannels) - Open channels with external funding
189
189
  - [parsePaymentRequest](#parsepaymentrequest) - Parse a BOLT11 Payment Request
190
+ - [partiallySignPsbt](#partiallysignpsbt) - Sign a PSBT without finalizing it
190
191
  - [pay](#pay) - Send a payment
191
192
  - [payViaPaymentDetails](#payviapaymentdetails) - Pay using decomposed details
192
193
  - [payViaPaymentRequest](#payviapaymentrequest) - Pay using a payment request
@@ -2529,7 +2530,7 @@ LND 0.11.1 and below do not return `last_reconnected` or `reconnection_rate`
2529
2530
  }]
2530
2531
  is_inbound: <Is Inbound Peer Bool>
2531
2532
  [is_sync_peer]: <Is Syncing Graph Data Bool>
2532
- [last_reconnected]: <Peer Last Reconnected At ISO 8601 Date String>
2533
+ [last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
2533
2534
  ping_time: <Ping Latency Milliseconds Number>
2534
2535
  public_key: <Node Identity Public Key String>
2535
2536
  [reconnection_rate]: <Count of Reconnections Over Time Number>
@@ -3392,6 +3393,46 @@ const {parsePaymentRequest} = require('ln-service');
3392
3393
  const requestDetails = parsePaymentRequest({request: 'paymentRequestString'});
3393
3394
  ```
3394
3395
 
3396
+ ### partiallySignPsbt
3397
+
3398
+ Sign a PSBT to produce a partially signed PSBT
3399
+
3400
+ Requires `onchain:write` permission
3401
+
3402
+ Requires LND built with `walletrpc` tag
3403
+
3404
+ This method is not supported in LND 0.14.1 and below
3405
+
3406
+ {
3407
+ lnd: <Authenticated LND API Object>
3408
+ psbt: <Funded PSBT Hex String>
3409
+ }
3410
+
3411
+ @returns via cbk or Promise
3412
+ {
3413
+ psbt: <Partially Signed PSBT Hex String>
3414
+ }
3415
+
3416
+
3417
+ Example:
3418
+
3419
+ ```node
3420
+ const {broadcastChainTransaction} = require('ln-service');
3421
+ const {fundPsbt, partiallySignPsbt} = require('ln-service');
3422
+ const {extractTransaction, finalizePsbt} = require('psbt');
3423
+
3424
+ const funding = await fundPsbt({
3425
+ lnd,
3426
+ outputs: [{address: chainAddress, tokens: 100000}]
3427
+ })
3428
+
3429
+ const finalize = finalizePsbt({psbt: funding.psbt});
3430
+
3431
+ const {transaction} = extractTransaction({psbt: finalize.psbt});
3432
+
3433
+ await broadcastChainTransaction({lnd, transaction});
3434
+ ```
3435
+
3395
3436
  ### pay
3396
3437
 
3397
3438
  Make a payment.
@@ -3665,6 +3706,10 @@ Requires `offchain:write` permission
3665
3706
  fee_mtokens: <Fee Millitokens String>
3666
3707
  forward: <Forward Tokens Number>
3667
3708
  forward_mtokens: <Forward Millitokens String>
3709
+ [messages]: [{
3710
+ type: <Message Type Number String>
3711
+ value: <Message Raw Value Hex Encoded String>
3712
+ }]
3668
3713
  [public_key]: <Public Key Hex String>
3669
3714
  timeout: <Timeout Block Height Number>
3670
3715
  }]
@@ -5651,6 +5696,10 @@ Requires `offchain:write` permission
5651
5696
  fee_mtokens: <Fee Millitokens String>
5652
5697
  forward: <Forward Tokens Number>
5653
5698
  forward_mtokens: <Forward Millitokens String>
5699
+ [messages]: [{
5700
+ type: <Message Type Number String>
5701
+ value: <Message Raw Value Hex Encoded String>
5702
+ }]
5654
5703
  public_key: <Public Key Hex String>
5655
5704
  timeout: <Timeout Block Height Number>
5656
5705
  }]
package/index.js CHANGED
@@ -76,6 +76,7 @@ const {lockUtxo} = require('lightning');
76
76
  const {openChannel} = require('lightning');
77
77
  const {openChannels} = require('lightning');
78
78
  const {parsePaymentRequest} = require('invoices');
79
+ const {partiallySignPsbt} = require('lightning');
79
80
  const {pay} = require('lightning');
80
81
  const {payViaPaymentDetails} = require('lightning');
81
82
  const {payViaPaymentRequest} = require('lightning');
@@ -215,6 +216,7 @@ module.exports = {
215
216
  openChannel,
216
217
  openChannels,
217
218
  parsePaymentRequest,
219
+ partiallySignPsbt,
218
220
  pay,
219
221
  payViaPaymentDetails,
220
222
  payViaPaymentRequest,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.17.2",
13
13
  "invoices": "2.0.3",
14
- "lightning": "5.3.3",
14
+ "lightning": "5.6.0",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.4.2"
@@ -26,12 +26,12 @@
26
26
  "bitcoinjs-lib": "6.0.1",
27
27
  "bn.js": "5.2.0",
28
28
  "ecpair": "2.0.1",
29
- "ln-docker-daemons": "2.2.0",
29
+ "ln-docker-daemons": "2.2.3",
30
30
  "portfinder": "1.0.28",
31
- "psbt": "1.1.10",
31
+ "psbt": "1.1.11",
32
32
  "rimraf": "3.0.2",
33
33
  "secp256k1": "4.0.3",
34
- "tiny-secp256k1": "2.1.2",
34
+ "tiny-secp256k1": "2.2.0",
35
35
  "uuid": "8.3.2",
36
36
  "varuint-bitcoin": "1.1.2"
37
37
  },
@@ -53,7 +53,17 @@
53
53
  "url": "https://github.com/alexbosworth/ln-service.git"
54
54
  },
55
55
  "scripts": {
56
+ "integration-test-daily-lnd-build": "DOCKER_LND_VERSION=daily-testing-only npm run test",
57
+ "integration-test-0.14.1": "DOCKER_LND_VERSION=v0.14.1-beta npm run test",
58
+ "integration-test-0.14.0": "DOCKER_LND_VERSION=v0.14.0-beta npm run test",
59
+ "integration-test-0.13.4": "DOCKER_LND_VERSION=v0.13.4-beta npm run test",
60
+ "integration-test-0.13.3": "DOCKER_LND_VERSION=v0.13.3-beta npm run test",
61
+ "integration-test-0.13.2": "DOCKER_LND_VERSION=v0.13.2-beta npm run test",
62
+ "integration-test-0.13.1": "DOCKER_LND_VERSION=v0.13.1-beta npm run test",
63
+ "integration-test-0.13.0": "DOCKER_LND_VERSION=v0.13.0-beta npm run test",
64
+ "integration-test-0.12.1": "DOCKER_LND_VERSION=v0.12.1-beta npm run test",
65
+ "integration-test-0.12.0": "DOCKER_LND_VERSION=v0.12.0-beta npm run test",
56
66
  "test": "echo $DOCKER_LND_VERSION && tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 200 test/autopilotrpc-integration/*.js test/chainrpc-integration/*.js test/integration/*.js test/invoicesrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
57
67
  },
58
- "version": "53.5.0"
68
+ "version": "53.7.0"
59
69
  }
@@ -17,30 +17,34 @@ test(`Add a peer`, async ({end, equal}) => {
17
17
 
18
18
  const [{lnd}, target] = nodes;
19
19
 
20
- const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
20
+ try {
21
+ const connectedKeys = (await getPeers({lnd})).peers.map(n => n.public_key);
21
22
 
22
- equal(connectedKeys.find(n => n === target.id), undefined, 'No peer');
23
+ equal(connectedKeys.find(n => n === target.id), undefined, 'No peer');
23
24
 
24
- await asyncRetry({interval, times}, async () => {
25
- await addPeer({
26
- lnd,
27
- timeout,
28
- public_key: target.id,
29
- socket: target.socket,
30
- });
31
-
32
- const {peers} = await getPeers({lnd});
25
+ await asyncRetry({interval, times}, async () => {
26
+ await addPeer({
27
+ lnd,
28
+ timeout,
29
+ public_key: target.id,
30
+ socket: target.socket,
31
+ });
33
32
 
34
- const connected = peers.find(n => n.public_key === target.id);
33
+ const {peers} = await getPeers({lnd});
35
34
 
36
- if (!connected) {
37
- throw new Error('ExpectedConnectionToTarget');
38
- }
35
+ const connected = peers.find(n => n.public_key === target.id);
39
36
 
40
- equal(connected.public_key, target.id, 'Connected to remote node');
41
- });
37
+ if (!connected) {
38
+ throw new Error('ExpectedConnectionToTarget');
39
+ }
42
40
 
43
- await kill({});
41
+ equal(connected.public_key, target.id, 'Connected to remote node');
42
+ });
43
+ } catch (err) {
44
+ equal(err, null, 'Expected no error');
45
+ } finally {
46
+ await kill({});
47
+ }
44
48
 
45
49
  return end();
46
50
  });
@@ -31,7 +31,7 @@ const timeout = 1000 * 5;
31
31
  const times = 200;
32
32
 
33
33
  // Forfeiting a pending channel should remove the pending channel
34
- test(`Forfeit pending channel`, async ({end, equal}) => {
34
+ test(`Forfeit pending channel`, async ({end, equal, strictSame}) => {
35
35
  const {kill, nodes} = await spawnLightningCluster({size});
36
36
 
37
37
  const [control, target, remote] = nodes;
@@ -136,16 +136,20 @@ test(`Forfeit pending channel`, async ({end, equal}) => {
136
136
  equal(code, 503, 'Pending channel cannot be canceled');
137
137
  }
138
138
 
139
- await deletePendingChannel({
140
- lnd,
141
- confirmed_transaction: transaction,
142
- pending_transaction: stuckTx.transaction,
143
- pending_transaction_vout: pending.transaction_vout,
144
- });
139
+ try {
140
+ await deletePendingChannel({
141
+ lnd,
142
+ confirmed_transaction: transaction,
143
+ pending_transaction: stuckTx.transaction,
144
+ pending_transaction_vout: pending.transaction_vout,
145
+ });
145
146
 
146
- const [stillPending] = (await getPendingChannels({lnd})).pending_channels;
147
+ const [notPending] = (await getPendingChannels({lnd})).pending_channels;
147
148
 
148
- equal(stillPending, undefined, 'Conflicting pending channel deleted');
149
+ equal(notPending, undefined, 'Conflicting pending channel deleted');
150
+ } catch (err) {
151
+ strictSame(err, [501, 'DeletePendingChannelMethodNotSupported']);
152
+ }
149
153
  } catch (err) {
150
154
  equal(err, null, 'No error is expected');
151
155
  } finally {
@@ -28,128 +28,132 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
28
28
 
29
29
  const [{generate, lnd}, target, remote] = nodes;
30
30
 
31
- const {address} = await createChainAddress({lnd: remote.lnd});
32
-
33
- await generate({count});
34
-
35
- // Send coins to remote so that it can accept the channel
36
- await sendToChainAddress({lnd, address, tokens: channelCapacityTokens});
37
-
38
- // Generate to confirm the tx
39
- await generate({count: confirmationCount});
40
- await remote.generate({count: confirmationCount});
41
-
42
- await setupChannel({
43
- generate,
44
- lnd,
45
- capacity: channelCapacityTokens + channelCapacityTokens,
46
- to: target,
47
- });
48
-
49
- await setupChannel({
50
- capacity: channelCapacityTokens,
51
- lnd: target.lnd,
52
- generate: target.generate,
53
- generator: target,
54
- give: Math.round(channelCapacityTokens / 2),
55
- to: remote,
56
- });
57
-
58
- await addPeer({lnd, public_key: remote.id, socket: remote.socket});
59
-
60
- const invoice = await createInvoice({tokens, lnd: remote.lnd});
61
-
62
- const bigInvoice = await createInvoice({
63
- tokens: (channelCapacityTokens / 2) + (channelCapacityTokens / 4),
64
- lnd: remote.lnd,
65
- });
66
-
67
31
  try {
68
- await pay({lnd, request: bigInvoice.request});
69
- } catch (err) {
70
- }
71
-
72
- // Create a new channel to increase total edge liquidity
73
- await setupChannel({
74
- capacity: channelCapacityTokens,
75
- lnd: target.lnd,
76
- generate: target.generate,
77
- generator: target,
78
- to: remote,
79
- });
80
-
81
- await deleteForwardingReputations({lnd});
82
-
83
- await asyncRetry({times}, async () => {
84
- await pay({lnd, request: invoice.request});
85
- });
86
-
87
- {
88
- const {payments} = await getFailedPayments({lnd});
89
-
90
- const [payment] = payments.filter(n => n.mtokens === bigInvoice.mtokens);
91
-
92
- equal(payment.destination, remote.id, 'Payment to');
93
- equal(payment.confirmed_at, undefined, 'No confirmation date');
94
- equal(!!payment.created_at, true, 'Got payment created date');
95
- equal(payment.fee, undefined, 'No fee when not paid');
96
- equal(payment.fee_mtokens, undefined, 'No fee mtokens when not paid');
97
- equal(!!payment.id, true, 'Got a payment id');
98
- equal(!!payment.index, true, 'Got payment index');
99
- equal(payment.is_confirmed, false, 'Failed payment is not confirmed');
100
- equal(payment.is_outgoing, true, 'Failed payment is outgoing');
101
- equal(payment.mtokens, bigInvoice.mtokens, 'Payment has mtokens');
102
- equal(payment.request, bigInvoice.request, 'Probe has a request');
103
- equal(payment.secret, undefined, 'Failed has no secret');
104
- equal(payment.safe_fee, undefined, 'Failed has no fee');
105
- equal(payment.safe_tokens, bigInvoice.tokens, 'Failed has safe tokens');
106
- equal(payment.tokens, bigInvoice.tokens, 'Failed has tokens');
107
-
108
- const gotFailed = await getPayment({lnd, id: payment.id});
109
-
110
- strictSame(
111
- gotFailed,
112
- {
113
- failed: {
114
- is_insufficient_balance: false,
115
- is_invalid_payment: false,
116
- is_pathfinding_timeout: false,
117
- is_route_not_found: true,
32
+ const {address} = await createChainAddress({lnd: remote.lnd});
33
+
34
+ await generate({count});
35
+
36
+ // Send coins to remote so that it can accept the channel
37
+ await sendToChainAddress({lnd, address, tokens: channelCapacityTokens});
38
+
39
+ // Generate to confirm the tx
40
+ await generate({count: confirmationCount});
41
+ await remote.generate({count: confirmationCount});
42
+
43
+ await setupChannel({
44
+ generate,
45
+ lnd,
46
+ capacity: channelCapacityTokens + channelCapacityTokens,
47
+ to: target,
48
+ });
49
+
50
+ await setupChannel({
51
+ capacity: channelCapacityTokens,
52
+ lnd: target.lnd,
53
+ generate: target.generate,
54
+ generator: target,
55
+ give: Math.round(channelCapacityTokens / 2),
56
+ to: remote,
57
+ });
58
+
59
+ await addPeer({lnd, public_key: remote.id, socket: remote.socket});
60
+
61
+ const invoice = await createInvoice({tokens, lnd: remote.lnd});
62
+
63
+ const bigInvoice = await createInvoice({
64
+ tokens: (channelCapacityTokens / 2) + (channelCapacityTokens / 4),
65
+ lnd: remote.lnd,
66
+ });
67
+
68
+ try {
69
+ await pay({lnd, request: bigInvoice.request});
70
+ } catch (err) {
71
+ }
72
+
73
+ // Create a new channel to increase total edge liquidity
74
+ await setupChannel({
75
+ capacity: channelCapacityTokens,
76
+ lnd: target.lnd,
77
+ generate: target.generate,
78
+ generator: target,
79
+ to: remote,
80
+ });
81
+
82
+ await deleteForwardingReputations({lnd});
83
+
84
+ await asyncRetry({times}, async () => {
85
+ await pay({lnd, request: invoice.request});
86
+ });
87
+
88
+ {
89
+ const {payments} = await getFailedPayments({lnd});
90
+
91
+ const [payment] = payments.filter(n => n.mtokens === bigInvoice.mtokens);
92
+
93
+ equal(payment.destination, remote.id, 'Payment to');
94
+ equal(payment.confirmed_at, undefined, 'No confirmation date');
95
+ equal(!!payment.created_at, true, 'Got payment created date');
96
+ equal(payment.fee, undefined, 'No fee when not paid');
97
+ equal(payment.fee_mtokens, undefined, 'No fee mtokens when not paid');
98
+ equal(!!payment.id, true, 'Got a payment id');
99
+ equal(!!payment.index, true, 'Got payment index');
100
+ equal(payment.is_confirmed, false, 'Failed payment is not confirmed');
101
+ equal(payment.is_outgoing, true, 'Failed payment is outgoing');
102
+ equal(payment.mtokens, bigInvoice.mtokens, 'Payment has mtokens');
103
+ equal(payment.request, bigInvoice.request, 'Probe has a request');
104
+ equal(payment.secret, undefined, 'Failed has no secret');
105
+ equal(payment.safe_fee, undefined, 'Failed has no fee');
106
+ equal(payment.safe_tokens, bigInvoice.tokens, 'Failed has safe tokens');
107
+ equal(payment.tokens, bigInvoice.tokens, 'Failed has tokens');
108
+
109
+ const gotFailed = await getPayment({lnd, id: payment.id});
110
+
111
+ strictSame(
112
+ gotFailed,
113
+ {
114
+ failed: {
115
+ is_insufficient_balance: false,
116
+ is_invalid_payment: false,
117
+ is_pathfinding_timeout: false,
118
+ is_route_not_found: true,
119
+ },
120
+ is_confirmed: false,
121
+ is_failed: true,
122
+ is_pending: false,
123
+ payment: undefined,
124
+ pending: undefined,
118
125
  },
119
- is_confirmed: false,
120
- is_failed: true,
121
- is_pending: false,
122
- payment: undefined,
123
- pending: undefined,
124
- },
125
- 'Got failed state'
126
- );
127
- }
128
-
129
- {
130
- const {payments} = await getPayments({lnd});
131
-
132
- const [payment] = payments;
133
-
134
- equal(payment.destination, remote.id, 'Paid to');
135
- equal(!!payment.confirmed_at, true, 'Got confirmation date');
136
- equal(!!payment.created_at, true, 'Got payment start date');
137
- equal(payment.fee, 1, 'Got fee paid');
138
- equal(payment.fee_mtokens, '1500', 'Got fee mtokens paid');
139
- strictSame(payment.hops, [target.id], 'Got hops');
140
- equal(!!payment.id, true, 'Got a payment id');
141
- equal(!!payment.index, true, 'Got payment index');
142
- equal(payment.is_confirmed, true, 'Failed payment is not confirmed');
143
- equal(payment.is_outgoing, true, 'Failed payment is outgoing');
144
- equal(payment.mtokens, invoice.mtokens, 'Payment has mtokens');
145
- equal(payment.request, invoice.request, 'Payment has a request');
146
- equal(!!payment.secret, true, 'Failed has no secret');
147
- equal(payment.safe_fee, 2, 'Failed has no fee');
148
- equal(payment.safe_tokens, invoice.tokens, 'Failed has safe tokens');
149
- equal(payment.tokens, invoice.tokens, 'Failed has tokens');
126
+ 'Got failed state'
127
+ );
128
+ }
129
+
130
+ {
131
+ const {payments} = await getPayments({lnd});
132
+
133
+ const [payment] = payments;
134
+
135
+ equal(payment.destination, remote.id, 'Paid to');
136
+ equal(!!payment.confirmed_at, true, 'Got confirmation date');
137
+ equal(!!payment.created_at, true, 'Got payment start date');
138
+ equal(payment.fee, 1, 'Got fee paid');
139
+ equal(payment.fee_mtokens, '1500', 'Got fee mtokens paid');
140
+ strictSame(payment.hops, [target.id], 'Got hops');
141
+ equal(!!payment.id, true, 'Got a payment id');
142
+ equal(!!payment.index, true, 'Got payment index');
143
+ equal(payment.is_confirmed, true, 'Failed payment is not confirmed');
144
+ equal(payment.is_outgoing, true, 'Failed payment is outgoing');
145
+ equal(payment.mtokens, invoice.mtokens, 'Payment has mtokens');
146
+ equal(payment.request, invoice.request, 'Payment has a request');
147
+ equal(!!payment.secret, true, 'Failed has no secret');
148
+ equal(payment.safe_fee, 2, 'Failed has no fee');
149
+ equal(payment.safe_tokens, invoice.tokens, 'Failed has safe tokens');
150
+ equal(payment.tokens, invoice.tokens, 'Failed has tokens');
151
+ }
152
+ } catch (err) {
153
+ strictSame(err, null, 'Expected no error');
154
+ } finally {
155
+ await kill({});
150
156
  }
151
157
 
152
- await kill({});
153
-
154
158
  return end();
155
159
  });
@@ -9,7 +9,7 @@ const {setupChannel} = require('./../macros');
9
9
 
10
10
  const interval = 100;
11
11
  const size = 3;
12
- const times = 300;
12
+ const times = 800;
13
13
 
14
14
  // Getting the network centrality should return the centrality scores
15
15
  test(`Get network centrality`, async ({end, equal, strictSame}) => {
@@ -19,42 +19,50 @@ test(`Get network centrality`, async ({end, equal, strictSame}) => {
19
19
 
20
20
  const {lnd} = control;
21
21
 
22
- await setupChannel({lnd, generate: control.generate, to: target});
22
+ try {
23
+ await control.generate({count: 100});
23
24
 
24
- await setupChannel({
25
- generate: target.generate,
26
- lnd: target.lnd,
27
- to: remote,
28
- });
29
-
30
- await asyncRetry({interval, times}, async () => {
31
25
  await addPeer({lnd, public_key: remote.id, socket: remote.socket});
32
26
 
33
- const {nodes} = await getNetworkCentrality({lnd});
34
-
35
- const controlScore = nodes.find(n => n.public_key === control.id);
36
- const remoteScore = nodes.find(n => n.public_key === remote.id);
37
- const targetScore = nodes.find(n => n.public_key === target.id);
38
-
39
- if (!targetScore.betweenness || !targetScore.betweenness_normalized) {
40
- throw new Error('UnexpectedValueForTargetScoreBetweenness');
41
- }
42
-
43
- if (targetScore.betweenness !== 1e6) {
44
- throw new Error('WrongBetweennessScore');
45
- }
46
-
47
- equal(controlScore.betweenness, 0, 'No centrality on control');
48
- equal(controlScore.betweenness_normalized, 0, 'No centrality on control');
49
- equal(remoteScore.betweenness, 0, 'No centrality on remote');
50
- equal(remoteScore.betweenness_normalized, 0, 'No centrality on remote');
51
- equal(targetScore.betweenness, 1e6, 'Centrality around target');
52
- equal(targetScore.betweenness_normalized, 1e6, 'Centrality around target');
53
-
54
- return;
55
- });
56
-
57
- await kill({});
27
+ await setupChannel({lnd, generate: control.generate, to: target});
28
+
29
+ await setupChannel({
30
+ generate: target.generate,
31
+ lnd: target.lnd,
32
+ to: remote,
33
+ });
34
+
35
+ await asyncRetry({interval, times}, async () => {
36
+ await addPeer({lnd, public_key: remote.id, socket: remote.socket});
37
+
38
+ const {nodes} = await getNetworkCentrality({lnd});
39
+
40
+ const controlScore = nodes.find(n => n.public_key === control.id);
41
+ const remoteScore = nodes.find(n => n.public_key === remote.id);
42
+ const targetScore = nodes.find(n => n.public_key === target.id);
43
+
44
+ if (!targetScore.betweenness || !targetScore.betweenness_normalized) {
45
+ throw new Error('UnexpectedValueForTargetScoreBetweenness');
46
+ }
47
+
48
+ if (targetScore.betweenness !== 1e6) {
49
+ throw new Error('WrongBetweennessScore');
50
+ }
51
+
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');
58
+
59
+ return;
60
+ });
61
+ } catch (err) {
62
+ equal(err, null, 'Expected no error');
63
+ } finally {
64
+ await kill({});
65
+ }
58
66
 
59
67
  return end();
60
68
  });