ln-service 53.6.0 → 53.7.3
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 +4 -0
- package/README.md +11 -3
- package/index.js +2 -2
- package/package.json +5 -4
- package/test/integration/test_add_peer.js +26 -20
- package/test/integration/test_delete_pending_channel.js +5 -2
- package/test/integration/test_get_closed_channels.js +0 -2
- package/test/integration/test_get_failed_payments.js +123 -119
- package/test/integration/test_get_invoice.js +0 -1
- package/test/integration/test_get_node.js +65 -49
- package/test/integration/test_get_peers.js +32 -21
- package/test/integration/test_get_pending_force.js +1 -1
- package/test/integration/test_get_wallet_info.js +35 -18
- package/test/integration/test_open_channels.js +22 -15
- package/test/integration/test_pay.js +0 -1
- package/test/integration/test_pay_private_invoice.js +0 -1
- package/test/integration/test_propose_channel.js +438 -421
- package/test/integration/test_remove_peer.js +13 -9
- package/test/integration/test_send_message_to_peer.js +39 -28
- package/test/integration/test_subscribe_to_channels.js +1 -2
- package/test/integration/test_subscribe_to_invoices.js +80 -78
- package/test/integration/test_subscribe_to_peer_messages.js +81 -73
- package/test/integration/test_subscribe_to_peers.js +23 -19
- package/test/invoicesrpc-integration/test_get_sweep_transactions.js +0 -2
- package/test/invoicesrpc-integration/test_subscribe_cancel_invoice.js +0 -1
- package/test/macros/wait_for_channel.js +1 -1
- package/test/routerrpc-integration/test_delete_forwarding_reputations.js +61 -27
- package/test/routerrpc-integration/test_get_forwarding_reputations.js +74 -42
- package/test/routerrpc-integration/test_get_route_confidence.js +38 -34
- package/test/routerrpc-integration/test_get_route_through_hops.js +45 -17
- package/test/routerrpc-integration/test_multipath_payment.js +0 -1
- package/test/routerrpc-integration/test_pay_via_payment_details.js +118 -111
- package/test/routerrpc-integration/test_pay_via_payment_request.js +92 -80
- package/test/routerrpc-integration/test_pay_via_routes.js +19 -1
- package/test/routerrpc-integration/test_probe_for_route.js +78 -74
- package/test/routerrpc-integration/test_subscribe_to_forward_requests.js +2 -3
- package/test/routerrpc-integration/test_subscribe_to_forwards.js +518 -505
- package/test/routerrpc-integration/test_subscribe_to_past_payments.js +0 -3
- package/test/tower_clientrpc-integration/test_get_connected_watchtowers.js +0 -3
- package/test/walletrpc-integration/test_fund_psbt.js +113 -1
- package/test/walletrpc-integration/test_partially_sign_psbt.js +12 -5
- package/test/walletrpc-integration/test_sign_psbt.js +4 -1
|
@@ -8,7 +8,6 @@ const {delay} = require('./../macros');
|
|
|
8
8
|
const {getHeight} = require('./../../');
|
|
9
9
|
const {getInvoice} = require('./../../');
|
|
10
10
|
const {getInvoices} = require('./../../');
|
|
11
|
-
const {getWalletVersion} = require('./../../');
|
|
12
11
|
const {payViaPaymentDetails} = require('./../../');
|
|
13
12
|
const {setupChannel} = require('./../macros');
|
|
14
13
|
const {waitForRoute} = require('./../macros');
|
|
@@ -25,140 +24,148 @@ test(`Pay`, async ({end, equal, rejects, strictSame}) => {
|
|
|
25
24
|
|
|
26
25
|
const [{generate, lnd}, target, remote] = nodes;
|
|
27
26
|
|
|
28
|
-
const channel = await setupChannel({lnd, generate, to: target});
|
|
29
|
-
|
|
30
|
-
const remoteChan = await setupChannel({
|
|
31
|
-
generate: target.generate,
|
|
32
|
-
lnd: target.lnd,
|
|
33
|
-
to: remote,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
37
|
-
|
|
38
|
-
const height = (await getHeight({lnd})).current_block_height;
|
|
39
|
-
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
40
|
-
|
|
41
|
-
const {features} = await decodePaymentRequest({
|
|
42
|
-
lnd,
|
|
43
|
-
request: invoice.request,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const expectedHops = [
|
|
47
|
-
{
|
|
48
|
-
channel: channel.id,
|
|
49
|
-
channel_capacity: 1000000,
|
|
50
|
-
fee: 1,
|
|
51
|
-
fee_mtokens: '1000',
|
|
52
|
-
forward: invoice.tokens,
|
|
53
|
-
forward_mtokens: (BigInt(invoice.tokens) * BigInt(1e3)).toString(),
|
|
54
|
-
public_key: target.id,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
channel: remoteChan.id,
|
|
58
|
-
channel_capacity: 1000000,
|
|
59
|
-
fee: 0,
|
|
60
|
-
fee_mtokens: '0',
|
|
61
|
-
forward: invoice.tokens,
|
|
62
|
-
forward_mtokens: '100000',
|
|
63
|
-
public_key: remote.id,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
await waitForRoute({lnd, destination: remote.id, tokens: invoice.tokens});
|
|
68
|
-
|
|
69
27
|
try {
|
|
70
|
-
const
|
|
71
|
-
features,
|
|
72
|
-
lnd,
|
|
73
|
-
destination: remote.id,
|
|
74
|
-
payment: invoice.payment,
|
|
75
|
-
tokens: invoice.tokens,
|
|
76
|
-
});
|
|
77
|
-
} catch (err) {
|
|
78
|
-
strictSame(err, [503, 'PaymentRejectedByDestination']);
|
|
79
|
-
}
|
|
28
|
+
const channel = await setupChannel({lnd, generate, to: target});
|
|
80
29
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
destination: remote.id,
|
|
86
|
-
id: invoice.id,
|
|
87
|
-
max_timeout_height: height + 46,
|
|
88
|
-
payment: invoice.payment,
|
|
89
|
-
tokens: invoice.tokens,
|
|
30
|
+
const remoteChan = await setupChannel({
|
|
31
|
+
generate: target.generate,
|
|
32
|
+
lnd: target.lnd,
|
|
33
|
+
to: remote,
|
|
90
34
|
});
|
|
91
35
|
|
|
92
|
-
|
|
93
|
-
} catch (err) {
|
|
94
|
-
strictSame(err, [503, 'PaymentPathfindingFailedToFindPossibleRoute'], 'Fail');
|
|
95
|
-
}
|
|
36
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
96
37
|
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
38
|
+
const height = (await getHeight({lnd})).current_block_height;
|
|
39
|
+
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
40
|
+
|
|
41
|
+
const {features} = await decodePaymentRequest({
|
|
100
42
|
lnd,
|
|
101
|
-
|
|
102
|
-
id: invoice.id,
|
|
103
|
-
max_timeout_height: height + 90,
|
|
104
|
-
messages: [{type: tlvType, value: tlvData}],
|
|
105
|
-
payment: invoice.payment,
|
|
106
|
-
tokens: invoice.tokens,
|
|
43
|
+
request: invoice.request,
|
|
107
44
|
});
|
|
108
45
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
46
|
+
const expectedHops = [
|
|
47
|
+
{
|
|
48
|
+
channel: channel.id,
|
|
49
|
+
channel_capacity: 1000000,
|
|
50
|
+
fee: 1,
|
|
51
|
+
fee_mtokens: '1000',
|
|
52
|
+
forward: invoice.tokens,
|
|
53
|
+
forward_mtokens: (BigInt(invoice.tokens) * BigInt(1e3)).toString(),
|
|
54
|
+
public_key: target.id,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
channel: remoteChan.id,
|
|
58
|
+
channel_capacity: 1000000,
|
|
59
|
+
fee: 0,
|
|
60
|
+
fee_mtokens: '0',
|
|
61
|
+
forward: invoice.tokens,
|
|
62
|
+
forward_mtokens: '100000',
|
|
63
|
+
public_key: remote.id,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
await waitForRoute({lnd, destination: remote.id, tokens: invoice.tokens});
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const paid = await payViaPaymentDetails({
|
|
71
|
+
features,
|
|
72
|
+
lnd,
|
|
73
|
+
destination: remote.id,
|
|
74
|
+
payment: invoice.payment,
|
|
75
|
+
tokens: invoice.tokens,
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
strictSame(err, [503, 'PaymentRejectedByDestination']);
|
|
79
|
+
}
|
|
120
80
|
|
|
121
|
-
|
|
122
|
-
|
|
81
|
+
try {
|
|
82
|
+
const tooSoonCltv = await payViaPaymentDetails({
|
|
83
|
+
features,
|
|
84
|
+
lnd,
|
|
85
|
+
destination: remote.id,
|
|
86
|
+
id: invoice.id,
|
|
87
|
+
max_timeout_height: height + 46,
|
|
88
|
+
payment: invoice.payment,
|
|
89
|
+
tokens: invoice.tokens,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
equal(tooSoonCltv, null, 'Should not be able to pay a too soon CLTV');
|
|
93
|
+
} catch (err) {
|
|
94
|
+
strictSame(
|
|
95
|
+
err,
|
|
96
|
+
[503, 'PaymentPathfindingFailedToFindPossibleRoute'],
|
|
97
|
+
'Fail'
|
|
98
|
+
);
|
|
99
|
+
}
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
101
|
+
try {
|
|
102
|
+
const paid = await payViaPaymentDetails({
|
|
103
|
+
features,
|
|
104
|
+
lnd,
|
|
105
|
+
destination: remote.id,
|
|
106
|
+
id: invoice.id,
|
|
107
|
+
max_timeout_height: height + 90,
|
|
108
|
+
messages: [{type: tlvType, value: tlvData}],
|
|
109
|
+
payment: invoice.payment,
|
|
110
|
+
tokens: invoice.tokens,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
equal(paid.confirmed_at > start, true, 'Confirm date was received');
|
|
114
|
+
equal(paid.fee, 1, 'Fee tokens paid');
|
|
115
|
+
equal(paid.fee_mtokens, '1000', 'Fee mtokens tokens paid');
|
|
116
|
+
equal(paid.id, invoice.id, 'Payment hash is equal on both sides');
|
|
117
|
+
equal(paid.mtokens, '101000', 'Paid mtokens');
|
|
118
|
+
equal(paid.secret, invoice.secret, 'Paid for invoice secret');
|
|
119
|
+
|
|
120
|
+
paid.hops.forEach(n => {
|
|
121
|
+
equal(n.timeout === height + 40 || n.timeout === height + 43, true);
|
|
122
|
+
|
|
123
|
+
delete n.timeout;
|
|
124
|
+
|
|
125
|
+
return;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
strictSame(paid.hops, expectedHops, 'Hops are returned');
|
|
129
|
+
} catch (err) {
|
|
130
|
+
equal(err, null, 'No error is thrown when payment is attempted');
|
|
131
|
+
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
{
|
|
134
|
+
const {payments} = await getInvoice({id: invoice.id, lnd: remote.lnd});
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
if (!!payments) {
|
|
137
|
+
const [payment] = payments;
|
|
134
138
|
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
if (!!payment && !!payment.messages.length) {
|
|
140
|
+
const [message] = payment.messages;
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
equal(message.type, tlvType, 'Got TLV type');
|
|
143
|
+
equal(message.value, tlvData, 'Got TLV value');
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
|
-
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
{
|
|
149
|
+
const {invoices} = await getInvoices({lnd: remote.lnd});
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
const [{payments}] = invoices;
|
|
148
152
|
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
if (!!payments.length) {
|
|
154
|
+
const [payment] = payments;
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
if (!!payment && !!payment.messages.length) {
|
|
157
|
+
const [message] = payment.messages;
|
|
154
158
|
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
equal(message.type, tlvType, 'Got TLV type');
|
|
160
|
+
equal(message.value, tlvData, 'Got TLV value');
|
|
161
|
+
}
|
|
157
162
|
}
|
|
158
163
|
}
|
|
164
|
+
} catch (err) {
|
|
165
|
+
equal(err, null, 'Expected no error');
|
|
166
|
+
} finally {
|
|
167
|
+
await kill({});
|
|
159
168
|
}
|
|
160
169
|
|
|
161
|
-
await kill({});
|
|
162
|
-
|
|
163
170
|
return end();
|
|
164
171
|
});
|
|
@@ -22,99 +22,111 @@ test(`Pay via payment request`, async ({end, equal, rejects, strictSame}) => {
|
|
|
22
22
|
|
|
23
23
|
const [{generate, lnd}, target, remote] = nodes;
|
|
24
24
|
|
|
25
|
-
const channel = await setupChannel({generate, lnd, to: target});
|
|
26
|
-
|
|
27
|
-
// Make sure that an error is returned when there is no route
|
|
28
25
|
try {
|
|
29
|
-
|
|
26
|
+
await generate({count: 100});
|
|
30
27
|
|
|
31
|
-
await
|
|
32
|
-
payViaPaymentRequest({lnd, request}),
|
|
33
|
-
[503, 'PaymentPathfindingFailedToFindPossibleRoute'],
|
|
34
|
-
'A payment with no route returns an error'
|
|
35
|
-
);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
equal(err, null, 'Expected no error creating invoice');
|
|
38
|
-
}
|
|
28
|
+
const channel = await setupChannel({generate, lnd, to: target});
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
to: remote,
|
|
44
|
-
});
|
|
30
|
+
// Make sure that an error is returned when there is no route
|
|
31
|
+
try {
|
|
32
|
+
const {request} = await createInvoice({tokens, lnd: remote.lnd});
|
|
45
33
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
await rejects(
|
|
35
|
+
payViaPaymentRequest({lnd, request}),
|
|
36
|
+
[503, 'PaymentPathfindingFailedToFindPossibleRoute'],
|
|
37
|
+
'A payment with no route returns an error'
|
|
38
|
+
);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
equal(err, null, 'Expected no error creating invoice');
|
|
41
|
+
}
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
55
|
-
|
|
56
|
-
const paid = await payViaPaymentRequest({
|
|
57
|
-
lnd,
|
|
58
|
-
max_timeout_height: height + 40 + 43,
|
|
59
|
-
messages: [{type: tlvType, value: tlvValue}],
|
|
60
|
-
request: invoice.request,
|
|
43
|
+
await addPeer({
|
|
44
|
+
lnd: target.lnd,
|
|
45
|
+
public_key: remote.id,
|
|
46
|
+
socket: remote.socket,
|
|
61
47
|
});
|
|
62
48
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
equal(paid.mtokens, '101000', 'Paid mtokens');
|
|
68
|
-
equal(paid.secret, invoice.secret, 'Paid for invoice secret');
|
|
69
|
-
|
|
70
|
-
paid.hops.forEach(n => {
|
|
71
|
-
equal(n.timeout === height + 40 || n.timeout === height + 43, true);
|
|
72
|
-
|
|
73
|
-
delete n.timeout;
|
|
74
|
-
|
|
75
|
-
return;
|
|
49
|
+
const remoteChan = await setupChannel({
|
|
50
|
+
lnd: target.lnd,
|
|
51
|
+
generate: target.generate,
|
|
52
|
+
to: remote,
|
|
76
53
|
});
|
|
77
54
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
56
|
+
|
|
57
|
+
await waitForRoute({lnd, tokens, destination: remote.id});
|
|
58
|
+
|
|
59
|
+
// When a route exists, payment is successful
|
|
60
|
+
try {
|
|
61
|
+
const commitTxFee = channel.commit_transaction_fee;
|
|
62
|
+
const height = (await getWalletInfo({lnd})).current_block_height;
|
|
63
|
+
const invoice = await createInvoice({tokens, lnd: remote.lnd});
|
|
64
|
+
|
|
65
|
+
const paid = await payViaPaymentRequest({
|
|
66
|
+
lnd,
|
|
67
|
+
max_timeout_height: height + 40 + 43,
|
|
68
|
+
messages: [{type: tlvType, value: tlvValue}],
|
|
69
|
+
request: invoice.request,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
equal(paid.confirmed_at > start, true, 'Got confirmation date');
|
|
73
|
+
equal(paid.fee, 1, 'Fee tokens paid');
|
|
74
|
+
equal(paid.fee_mtokens, '1000', 'Fee mtokens tokens paid');
|
|
75
|
+
equal(paid.id, invoice.id, 'Payment hash is equal on both sides');
|
|
76
|
+
equal(paid.mtokens, '101000', 'Paid mtokens');
|
|
77
|
+
equal(paid.secret, invoice.secret, 'Paid for invoice secret');
|
|
78
|
+
|
|
79
|
+
paid.hops.forEach(n => {
|
|
80
|
+
equal(n.timeout === height + 40 || n.timeout === height + 43, true);
|
|
81
|
+
|
|
82
|
+
delete n.timeout;
|
|
83
|
+
|
|
84
|
+
return;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const expectedHops = [
|
|
88
|
+
{
|
|
89
|
+
channel: channel.id,
|
|
90
|
+
channel_capacity: 1000000,
|
|
91
|
+
fee: 1,
|
|
92
|
+
fee_mtokens: '1000',
|
|
93
|
+
forward: 100,
|
|
94
|
+
forward_mtokens: invoice.mtokens,
|
|
95
|
+
public_key: target.id,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
channel: remoteChan.id,
|
|
99
|
+
channel_capacity: 1000000,
|
|
100
|
+
fee: 0,
|
|
101
|
+
fee_mtokens: '0',
|
|
102
|
+
forward: 100,
|
|
103
|
+
forward_mtokens: '100000',
|
|
104
|
+
public_key: remote.id,
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
strictSame(paid.hops, expectedHops, 'Hops are returned');
|
|
109
|
+
|
|
110
|
+
const {payments} = await getInvoice({id: paid.id, lnd: remote.lnd});
|
|
111
|
+
|
|
112
|
+
if (!!payments.length) {
|
|
113
|
+
const [payment] = payments;
|
|
114
|
+
|
|
115
|
+
if (!!payment.messages.length) {
|
|
116
|
+
const [message] = payment.messages;
|
|
117
|
+
|
|
118
|
+
equal(message.type, tlvType, 'Got TLV message type');
|
|
119
|
+
equal(message.value, tlvValue, 'Got TLV message value');
|
|
120
|
+
}
|
|
111
121
|
}
|
|
122
|
+
} catch (err) {
|
|
123
|
+
equal(err, null, 'Expected no error paying payment request');
|
|
112
124
|
}
|
|
113
125
|
} catch (err) {
|
|
114
|
-
equal(err,
|
|
126
|
+
equal(err, 'Expected no errors');
|
|
127
|
+
} finally {
|
|
128
|
+
await kill({});
|
|
115
129
|
}
|
|
116
130
|
|
|
117
|
-
await kill({});
|
|
118
|
-
|
|
119
131
|
return end();
|
|
120
132
|
});
|
|
@@ -18,6 +18,7 @@ const {openChannel} = require('./../../');
|
|
|
18
18
|
const {payViaRoutes} = require('./../../');
|
|
19
19
|
const {routeFromChannels} = require('./../../');
|
|
20
20
|
const {setupChannel} = require('./../macros');
|
|
21
|
+
const {subscribeToForwardRequests} = require('./../../');
|
|
21
22
|
const {waitForChannel} = require('./../macros');
|
|
22
23
|
const {waitForPendingChannel} = require('./../macros');
|
|
23
24
|
const {waitForRoute} = require('./../macros');
|
|
@@ -27,6 +28,7 @@ const confirmationCount = 6;
|
|
|
27
28
|
const defaultFee = 1e3;
|
|
28
29
|
const defaultVout = 0;
|
|
29
30
|
const interval = 10;
|
|
31
|
+
const intermediateRecord = {type: '65536', value: '5678'};
|
|
30
32
|
const mtokPadding = '000';
|
|
31
33
|
const regtestChain = '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206';
|
|
32
34
|
const reserveRatio = 0.99;
|
|
@@ -39,7 +41,7 @@ const tokens = 100;
|
|
|
39
41
|
const txIdHexLength = 32 * 2;
|
|
40
42
|
|
|
41
43
|
// Paying via routes should successfully pay via routes
|
|
42
|
-
test(`Pay via routes`, async ({end, equal}) => {
|
|
44
|
+
test(`Pay via routes`, async ({end, equal, strictSame}) => {
|
|
43
45
|
const {kill, nodes} = await spawnLightningCluster({size});
|
|
44
46
|
|
|
45
47
|
const [{generate, lnd}, target, remote] = nodes;
|
|
@@ -170,10 +172,26 @@ test(`Pay via routes`, async ({end, equal}) => {
|
|
|
170
172
|
equal(lowFeeErrMessage, 'FeeInsufficient', 'Low fee returns low fee msg');
|
|
171
173
|
}
|
|
172
174
|
|
|
175
|
+
const [hopToTarget] = route.hops;
|
|
176
|
+
|
|
177
|
+
hopToTarget.messages = [intermediateRecord];
|
|
178
|
+
|
|
173
179
|
route.messages = [{type: tlvType, value: tlvValue}];
|
|
174
180
|
|
|
181
|
+
const sub = subscribeToForwardRequests({lnd: target.lnd});
|
|
182
|
+
|
|
183
|
+
const forwardMessages = [];
|
|
184
|
+
|
|
185
|
+
sub.on('forward_request', request => {
|
|
186
|
+
request.messages.forEach(message => forwardMessages.push(message));
|
|
187
|
+
|
|
188
|
+
return request.accept();
|
|
189
|
+
});
|
|
190
|
+
|
|
175
191
|
const payment = await payViaRoutes({id, lnd, routes: [route]});
|
|
176
192
|
|
|
193
|
+
strictSame(forwardMessages, [intermediateRecord], 'Got intermediate record');
|
|
194
|
+
|
|
177
195
|
equal(payment.confirmed_at > start, true, 'Paid has confirm date');
|
|
178
196
|
|
|
179
197
|
const paidInvoice = await getInvoice({id, lnd: remote.lnd});
|