• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16176630036

09 Jul 2025 05:55PM UTC coverage: 67.416% (+9.8%) from 57.611%
16176630036

Pull #10061

github

web-flow
Merge 52d963bae into 0e830da9d
Pull Request #10061: itest+lntest: fix flake in `testListSweeps`

0 of 44 new or added lines in 3 files covered. (0.0%)

26 existing lines in 6 files now uncovered.

135262 of 200639 relevant lines covered (67.42%)

21810.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lntest/rpc/wallet_kit.go
1
package rpc
2

3
import (
4
        "context"
5

6
        "github.com/lightningnetwork/lnd/lnrpc"
7
        "github.com/lightningnetwork/lnd/lnrpc/signrpc"
8
        "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
9
        "github.com/stretchr/testify/require"
10
)
11

12
// =====================
13
// WalletKitClient related RPCs.
14
// =====================
15

16
type (
17
        SignReq    *walletrpc.SignMessageWithAddrResponse
18
        VerifyResp *walletrpc.VerifyMessageWithAddrResponse
19
)
20

21
// FinalizePsbt makes a RPC call to node's ListUnspent and asserts.
22
func (h *HarnessRPC) ListUnspent(
23
        req *walletrpc.ListUnspentRequest) *walletrpc.ListUnspentResponse {
×
24

×
25
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
26
        defer cancel()
×
27

×
28
        resp, err := h.WalletKit.ListUnspent(ctxt, req)
×
29
        h.NoError(err, "ListUnspent")
×
30

×
31
        return resp
×
32
}
×
33

34
// DeriveKey makes a RPC call to the DeriveKey and asserts.
35
func (h *HarnessRPC) DeriveKey(kl *signrpc.KeyLocator) *signrpc.KeyDescriptor {
×
36
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
37
        defer cancel()
×
38

×
39
        key, err := h.WalletKit.DeriveKey(ctxt, kl)
×
40
        h.NoError(err, "DeriveKey")
×
41

×
42
        return key
×
43
}
×
44

45
// SendOutputs makes a RPC call to the node's WalletKitClient and asserts.
46
func (h *HarnessRPC) SendOutputs(
47
        req *walletrpc.SendOutputsRequest) *walletrpc.SendOutputsResponse {
×
48

×
49
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
50
        defer cancel()
×
51

×
52
        resp, err := h.WalletKit.SendOutputs(ctxt, req)
×
53
        h.NoError(err, "SendOutputs")
×
54

×
55
        return resp
×
56
}
×
57

58
// FundPsbt makes a RPC call to node's FundPsbt and asserts.
59
func (h *HarnessRPC) FundPsbt(
60
        req *walletrpc.FundPsbtRequest) *walletrpc.FundPsbtResponse {
×
61

×
62
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
63
        defer cancel()
×
64

×
65
        resp, err := h.WalletKit.FundPsbt(ctxt, req)
×
66
        h.NoError(err, "FundPsbt")
×
67

×
68
        return resp
×
69
}
×
70

71
// FundPsbtAssertErr makes a RPC call to the node's FundPsbt and asserts an
72
// error is returned.
73
func (h *HarnessRPC) FundPsbtAssertErr(req *walletrpc.FundPsbtRequest) {
×
74
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
75
        defer cancel()
×
76

×
77
        _, err := h.WalletKit.FundPsbt(ctxt, req)
×
78
        require.Error(h, err, "expected error returned")
×
79
}
×
80

81
// FinalizePsbt makes a RPC call to node's FinalizePsbt and asserts.
82
func (h *HarnessRPC) FinalizePsbt(
83
        req *walletrpc.FinalizePsbtRequest) *walletrpc.FinalizePsbtResponse {
×
84

×
85
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
86
        defer cancel()
×
87

×
88
        resp, err := h.WalletKit.FinalizePsbt(ctxt, req)
×
89
        h.NoError(err, "FinalizePsbt")
×
90

×
91
        return resp
×
92
}
×
93

94
// LabelTransactionAssertErr makes a RPC call to the node's LabelTransaction
95
// and asserts an error is returned. It then returns the error.
96
func (h *HarnessRPC) LabelTransactionAssertErr(
97
        req *walletrpc.LabelTransactionRequest) error {
×
98

×
99
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
100
        defer cancel()
×
101

×
102
        _, err := h.WalletKit.LabelTransaction(ctxt, req)
×
103
        require.Error(h, err, "expected error returned")
×
104

×
105
        return err
×
106
}
×
107

108
// LabelTransaction makes a RPC call to the node's LabelTransaction
109
// and asserts no error is returned.
110
func (h *HarnessRPC) LabelTransaction(req *walletrpc.LabelTransactionRequest) {
×
111
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
112
        defer cancel()
×
113

×
114
        _, err := h.WalletKit.LabelTransaction(ctxt, req)
×
115
        h.NoError(err, "LabelTransaction")
×
116
}
×
117

118
// DeriveNextKey makes a RPC call to the DeriveNextKey and asserts.
119
func (h *HarnessRPC) DeriveNextKey(
120
        req *walletrpc.KeyReq) *signrpc.KeyDescriptor {
×
121

×
122
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
123
        defer cancel()
×
124

×
125
        key, err := h.WalletKit.DeriveNextKey(ctxt, req)
×
126
        h.NoError(err, "DeriveNextKey")
×
127

×
128
        return key
×
129
}
×
130

131
// ListAddresses makes a RPC call to the ListAddresses and asserts.
132
func (h *HarnessRPC) ListAddresses(
133
        req *walletrpc.ListAddressesRequest) *walletrpc.ListAddressesResponse {
×
134

×
135
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
136
        defer cancel()
×
137

×
138
        key, err := h.WalletKit.ListAddresses(ctxt, req)
×
139
        h.NoError(err, "ListAddresses")
×
140

×
141
        return key
×
142
}
×
143

144
// SignMessageWithAddr makes a RPC call to the SignMessageWithAddr and asserts.
145
func (h *HarnessRPC) SignMessageWithAddr(
146
        req *walletrpc.SignMessageWithAddrRequest) SignReq {
×
147

×
148
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
149
        defer cancel()
×
150

×
151
        key, err := h.WalletKit.SignMessageWithAddr(ctxt, req)
×
152
        h.NoError(err, "SignMessageWithAddr")
×
153

×
154
        return key
×
155
}
×
156

157
// VerifyMessageWithAddr makes a RPC call to
158
// the VerifyMessageWithAddr and asserts.
159
func (h *HarnessRPC) VerifyMessageWithAddr(
160
        req *walletrpc.VerifyMessageWithAddrRequest) VerifyResp {
×
161

×
162
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
163
        defer cancel()
×
164

×
165
        key, err := h.WalletKit.VerifyMessageWithAddr(ctxt, req)
×
166
        h.NoError(err, "VerifyMessageWithAddr")
×
167

×
168
        return key
×
169
}
×
170

171
// ListSweeps makes a ListSweeps RPC call to the node's WalletKit client.
172
func (h *HarnessRPC) ListSweeps(
NEW
173
        req *walletrpc.ListSweepsRequest) *walletrpc.ListSweepsResponse {
×
174

×
175
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
176
        defer cancel()
×
177

×
178
        resp, err := h.WalletKit.ListSweeps(ctxt, req)
×
179
        h.NoError(err, "ListSweeps")
×
180

×
181
        return resp
×
182
}
×
183

184
// PendingSweeps makes a RPC call to the node's WalletKitClient and asserts.
185
func (h *HarnessRPC) PendingSweeps() *walletrpc.PendingSweepsResponse {
×
186
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
187
        defer cancel()
×
188

×
189
        req := &walletrpc.PendingSweepsRequest{}
×
190

×
191
        resp, err := h.WalletKit.PendingSweeps(ctxt, req)
×
192
        h.NoError(err, "PendingSweeps")
×
193

×
194
        return resp
×
195
}
×
196

197
// PublishTransaction makes an RPC call to the node's WalletKitClient and
198
// asserts.
199
func (h *HarnessRPC) PublishTransaction(
200
        req *walletrpc.Transaction) *walletrpc.PublishResponse {
×
201

×
202
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
203
        defer cancel()
×
204

×
205
        resp, err := h.WalletKit.PublishTransaction(ctxt, req)
×
206
        h.NoError(err, "PublishTransaction")
×
207

×
208
        return resp
×
209
}
×
210

211
// GetTransaction makes a RPC call to the node's WalletKitClient and asserts.
212
func (h *HarnessRPC) GetTransaction(
213
        req *walletrpc.GetTransactionRequest) *lnrpc.Transaction {
×
214

×
215
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
216
        defer cancel()
×
217

×
218
        resp, err := h.WalletKit.GetTransaction(ctxt, req)
×
219
        h.NoError(err, "GetTransaction")
×
220

×
221
        return resp
×
222
}
×
223

224
// RemoveTransaction makes an RPC call to the node's WalletKitClient and
225
// asserts.
226
//
227
//nolint:ll
228
func (h *HarnessRPC) RemoveTransaction(
229
        req *walletrpc.GetTransactionRequest) *walletrpc.RemoveTransactionResponse {
×
230

×
231
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
232
        defer cancel()
×
233

×
234
        resp, err := h.WalletKit.RemoveTransaction(ctxt, req)
×
235
        h.NoError(err, "RemoveTransaction")
×
236

×
237
        return resp
×
238
}
×
239

240
// BumpFee makes a RPC call to the node's WalletKitClient and asserts.
241
func (h *HarnessRPC) BumpFee(
242
        req *walletrpc.BumpFeeRequest) *walletrpc.BumpFeeResponse {
×
243

×
244
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
245
        defer cancel()
×
246

×
247
        resp, err := h.WalletKit.BumpFee(ctxt, req)
×
248
        h.NoError(err, "BumpFee")
×
249

×
250
        return resp
×
251
}
×
252

253
// BumpFeeAssertErr makes a RPC call to the node's WalletKitClient and asserts
254
// that an error is returned.
255
func (h *HarnessRPC) BumpFeeAssertErr(req *walletrpc.BumpFeeRequest) error {
×
256
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
257
        defer cancel()
×
258

×
259
        _, err := h.WalletKit.BumpFee(ctxt, req)
×
260
        require.Errorf(h, err, "%s: expect BumpFee to return an error", h.Name)
×
261

×
262
        return err
×
263
}
×
264

265
// BumpForceCloseFee makes a RPC call to the node's WalletKitClient and asserts.
266
//
267
//nolint:ll
268
func (h *HarnessRPC) BumpForceCloseFee(
269
        req *walletrpc.BumpForceCloseFeeRequest) *walletrpc.BumpForceCloseFeeResponse {
×
270

×
271
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
272
        defer cancel()
×
273

×
274
        resp, err := h.WalletKit.BumpForceCloseFee(ctxt, req)
×
275
        h.NoError(err, "BumpForceCloseFee")
×
276

×
277
        return resp
×
278
}
×
279

280
// ListAccounts makes a RPC call to the node's WalletKitClient and asserts.
281
func (h *HarnessRPC) ListAccounts(
282
        req *walletrpc.ListAccountsRequest) *walletrpc.ListAccountsResponse {
×
283

×
284
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
285
        defer cancel()
×
286

×
287
        resp, err := h.WalletKit.ListAccounts(ctxt, req)
×
288
        h.NoError(err, "ListAccounts")
×
289

×
290
        return resp
×
291
}
×
292

293
// ImportAccount makes a RPC call to the node's WalletKitClient and asserts.
294
func (h *HarnessRPC) ImportAccount(
295
        req *walletrpc.ImportAccountRequest) *walletrpc.ImportAccountResponse {
×
296

×
297
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
298
        defer cancel()
×
299

×
300
        resp, err := h.WalletKit.ImportAccount(ctxt, req)
×
301
        h.NoError(err, "ImportAccount")
×
302

×
303
        return resp
×
304
}
×
305

306
// ImportAccountAssertErr makes the ImportAccount RPC call and asserts an error
307
// is returned. It then returns the error.
308
func (h *HarnessRPC) ImportAccountAssertErr(
309
        req *walletrpc.ImportAccountRequest) error {
×
310

×
311
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
312
        defer cancel()
×
313

×
314
        _, err := h.WalletKit.ImportAccount(ctxt, req)
×
315
        require.Error(h, err)
×
316

×
317
        return err
×
318
}
×
319

320
// ImportPublicKey makes a RPC call to the node's WalletKitClient and asserts.
321
//
322
//nolint:ll
323
func (h *HarnessRPC) ImportPublicKey(
324
        req *walletrpc.ImportPublicKeyRequest) *walletrpc.ImportPublicKeyResponse {
×
325

×
326
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
327
        defer cancel()
×
328

×
329
        resp, err := h.WalletKit.ImportPublicKey(ctxt, req)
×
330
        h.NoError(err, "ImportPublicKey")
×
331

×
332
        return resp
×
333
}
×
334

335
// SignPsbt makes a RPC call to the node's WalletKitClient and asserts.
336
func (h *HarnessRPC) SignPsbt(
337
        req *walletrpc.SignPsbtRequest) *walletrpc.SignPsbtResponse {
×
338

×
339
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
340
        defer cancel()
×
341

×
342
        resp, err := h.WalletKit.SignPsbt(ctxt, req)
×
343
        h.NoError(err, "SignPsbt")
×
344

×
345
        return resp
×
346
}
×
347

348
// SignPsbtErr makes a RPC call to the node's WalletKitClient and asserts
349
// an error returned.
350
func (h *HarnessRPC) SignPsbtErr(req *walletrpc.SignPsbtRequest) error {
×
351
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
352
        defer cancel()
×
353

×
354
        _, err := h.WalletKit.SignPsbt(ctxt, req)
×
355
        require.Errorf(h, err, "%s: expect sign psbt to return an error",
×
356
                h.Name)
×
357

×
358
        return err
×
359
}
×
360

361
// ImportTapscript makes a RPC call to the node's WalletKitClient and asserts.
362
//
363
//nolint:ll
364
func (h *HarnessRPC) ImportTapscript(
365
        req *walletrpc.ImportTapscriptRequest) *walletrpc.ImportTapscriptResponse {
×
366

×
367
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
368
        defer cancel()
×
369

×
370
        resp, err := h.WalletKit.ImportTapscript(ctxt, req)
×
371
        h.NoError(err, "ImportTapscript")
×
372

×
373
        return resp
×
374
}
×
375

376
// RequiredReserve makes a RPC call to the node's WalletKitClient and asserts.
377
//
378
//nolint:ll
379
func (h *HarnessRPC) RequiredReserve(
380
        req *walletrpc.RequiredReserveRequest) *walletrpc.RequiredReserveResponse {
×
381

×
382
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
383
        defer cancel()
×
384

×
385
        resp, err := h.WalletKit.RequiredReserve(ctxt, req)
×
386
        h.NoError(err, "RequiredReserve")
×
387

×
388
        return resp
×
389
}
×
390

391
// ListLeases makes a ListLeases RPC call to the node's WalletKit client.
392
func (h *HarnessRPC) ListLeases() *walletrpc.ListLeasesResponse {
×
393
        ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
×
394
        defer cancel()
×
395

×
396
        resp, err := h.WalletKit.ListLeases(
×
397
                ctxt, &walletrpc.ListLeasesRequest{},
×
398
        )
×
399
        h.NoError(err, "ListLeases")
×
400

×
401
        return resp
×
402
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc