ln-service 54.1.0 → 54.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Versions
2
2
 
3
- ## 54.1.0
3
+ ## 54.1.2
4
+
5
+ - `subscribeToRpcRequests`: Fix support for LND 0.15.1
6
+
7
+ ## 54.1.1
4
8
 
5
9
  - `subscribeToPayments`: Add method to listen to all outgoing payments
6
10
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.18.1",
13
13
  "invoices": "2.2.0",
14
- "lightning": "6.1.0",
14
+ "lightning": "6.1.2",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.9.0"
@@ -71,5 +71,5 @@
71
71
  "integration-test-0.12.0": "DOCKER_LND_VERSION=v0.12.0-beta npm run test",
72
72
  "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/peersrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
73
73
  },
74
- "version": "54.1.0"
74
+ "version": "54.1.2"
75
75
  }
@@ -1,38 +1,51 @@
1
+ const {spawnLightningCluster} = require('ln-docker-daemons');
1
2
  const {test} = require('@alexbosworth/tap');
2
3
 
3
4
  const asyncRetry = require('async/retry');
4
5
  const {closeChannel} = require('./../../');
5
6
  const {createInvoice} = require('./../../');
7
+ const {delay} = require('./../macros');
6
8
  const {getWalletInfo} = require('./../../');
7
9
  const {openChannel} = require('./../../');
8
10
  const {payViaRoutes} = require('./../../');
9
- const {spawnLnd} = require('./../macros');
11
+ const {sendMessageToPeer} = require('./../../');
10
12
  const {subscribeToInvoice} = require('./../../');
11
13
  const {subscribeToRpcRequests} = require('./../../');
12
- const {waitForTermination} = require('./../macros');
13
14
 
15
+ const message = '00';
14
16
  const subscribeInvoiceUri = '/invoicesrpc.Invoices/SubscribeSingleInvoice';
15
17
 
16
18
  // Subscribing to RPC requests should listen for RPC requests
17
19
  test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
18
- const spawned = await (async () => {
20
+ // LND 0.13.4 and below do not support subscribing to RPC requests
21
+ {
22
+ const [{id, kill, lnd}] = (await spawnLightningCluster({})).nodes;
23
+
19
24
  try {
20
- return await spawnLnd({intercept: true});
25
+ await sendMessageToPeer({lnd, message, public_key: id});
21
26
  } catch (err) {
22
- return;
27
+ const [, code] = err;
28
+
29
+ if (code === 'SendMessageToPeerMethodNotSupported') {
30
+ await kill({});
31
+
32
+ return end();
33
+ }
23
34
  }
24
- })();
25
35
 
26
- // LND 0.13.4 and below do not support rpc interception
27
- if (!spawned) {
28
- return end();
36
+ await kill({});
29
37
  }
30
38
 
31
- const {lnd} = spawned;
32
- const pubKey = spawned.public_key;
39
+ const {kill, nodes} = await spawnLightningCluster({
40
+ lnd_configuration: ['--rpcmiddleware.enable'],
41
+ });
42
+
43
+ const [{lnd, id: key}] = nodes;
33
44
 
34
45
  const rpcRequestsSub = (await subscribeToRpcRequests({lnd})).subscription;
35
46
 
47
+ await delay(2000);
48
+
36
49
  const intercepted = [];
37
50
 
38
51
  rpcRequestsSub.on('error', error => intercepted.push({error}));
@@ -94,7 +107,7 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
94
107
  await openChannel({
95
108
  lnd,
96
109
  local_tokens: 1e6,
97
- partner_public_key: spawned.public_key,
110
+ partner_public_key: key,
98
111
  });
99
112
 
100
113
  fail('ExpectedChannelCannotBeOpened');
@@ -102,6 +115,8 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
102
115
  strictSame(err, [400, 'CannotOpenChannelToOwnNode'], 'RPC req accepted');
103
116
  }
104
117
 
118
+ await delay(2000);
119
+
105
120
  subscription.removeAllListeners();
106
121
  }
107
122
 
@@ -127,7 +142,7 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
127
142
  lnd,
128
143
  give_tokens: 1e5,
129
144
  local_tokens: 1e6,
130
- partner_public_key: spawned.public_key,
145
+ partner_public_key: Buffer.alloc(33, 2).toString('hex'),
131
146
  });
132
147
 
133
148
  fail('ExpectedChannelRejected');
@@ -186,12 +201,14 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
186
201
  is_intercepting_pay_via_routes_requests: true,
187
202
  });
188
203
 
204
+ await delay(2000);
205
+
189
206
  subscription.on('pay_via_route_request', async intercepted => {
190
207
  // Stop all route requests that have a non zero fee and pay to own key
191
208
  const feeMtokens = intercepted.request.route.fee_mtokens;
192
209
  const [finalHop] = intercepted.request.route.hops.reverse();
193
210
 
194
- if (feeMtokens === '0' && finalHop.public_key === pubKey) {
211
+ if (feeMtokens === '0' && finalHop.public_key === key) {
195
212
  await intercepted.reject({message: 'message'});
196
213
  } else {
197
214
  await intercepted.accept({});
@@ -212,7 +229,7 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
212
229
  fee_mtokens: '0',
213
230
  forward: 0,
214
231
  forward_mtokens: '1',
215
- public_key: pubKey,
232
+ public_key: key,
216
233
  timeout: 1,
217
234
  }],
218
235
  mtokens: '1',
@@ -232,9 +249,7 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
232
249
  subscription.removeAllListeners();
233
250
  }
234
251
 
235
- spawned.kill({});
236
-
237
- await waitForTermination({lnd: spawned.lnd});
252
+ await kill({});
238
253
 
239
254
  return end();
240
255
  });