Skip to content

Commit 4d34eb9

Browse files
committed
build: fixup new linter issues
1 parent 451311d commit 4d34eb9

File tree

6 files changed

+42
-34
lines changed

6 files changed

+42
-34
lines changed

client_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestLoopOutSuccess(t *testing.T) {
6565
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
6666

6767
// Expect client to register for conf.
68-
confIntent := ctx.AssertRegisterConf(false, req.HtlcConfirmations)
68+
confIntent := ctx.Context.AssertRegisterConf(false, req.HtlcConfirmations)
6969

7070
testLoopOutSuccess(ctx, testRequest.Amount, info.SwapHash,
7171
signalPrepaymentResult, signalSwapPaymentResult, false,
@@ -89,7 +89,7 @@ func TestLoopOutFailOffchain(t *testing.T) {
8989
signalSwapPaymentResult := ctx.AssertPaid(swapInvoiceDesc)
9090
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
9191

92-
ctx.AssertRegisterConf(false, defaultConfirmations)
92+
ctx.Context.AssertRegisterConf(false, defaultConfirmations)
9393

9494
signalSwapPaymentResult(
9595
errors.New(lndclient.PaymentResultUnknownPaymentHash),
@@ -274,7 +274,9 @@ func testLoopOutResume(t *testing.T, confs uint32, expired, preimageRevealed,
274274
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
275275

276276
// Expect client to register for our expected number of confirmations.
277-
confIntent := ctx.AssertRegisterConf(preimageRevealed, int32(confs))
277+
confIntent := ctx.Context.AssertRegisterConf(
278+
preimageRevealed, int32(confs),
279+
)
278280

279281
htlc, err := GetHtlc(
280282
hash, &pendingSwap.Contract.SwapContract,
@@ -325,7 +327,7 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
325327

326328
// Expect a signing request in the non taproot case.
327329
if scriptVersion != swap.HtlcV3 {
328-
<-ctx.Lnd.SignOutputRawChannel
330+
<-ctx.Context.Lnd.SignOutputRawChannel
329331
}
330332

331333
if !preimageRevealed {
@@ -345,14 +347,14 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
345347
ctx.expiryChan <- testTime
346348
ctx.assertPreimagePush(testPreimage)
347349
}
348-
<-ctx.Lnd.SignOutputRawChannel
350+
<-ctx.Context.Lnd.SignOutputRawChannel
349351
}
350352

351353
// Expect client on-chain sweep of HTLC.
352354
sweepTx := ctx.ReceiveTx()
353355

354356
require.Equal(
355-
ctx.T, htlcOutpoint.Hash[:],
357+
ctx.Context.T, htlcOutpoint.Hash[:],
356358
sweepTx.TxIn[0].PreviousOutPoint.Hash[:],
357359
"client not sweeping from htlc tx",
358360
)
@@ -369,12 +371,12 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
369371
// Check preimage.
370372
clientPreImage := sweepTx.TxIn[0].Witness[preImageIndex]
371373
clientPreImageHash := sha256.Sum256(clientPreImage)
372-
require.Equal(ctx.T, hash, lntypes.Hash(clientPreImageHash))
374+
require.Equal(ctx.Context.T, hash, lntypes.Hash(clientPreImageHash))
373375

374376
// Since we successfully published our sweep, we expect the preimage to
375377
// have been pushed to our mock server.
376378
preimage, err := lntypes.MakePreimage(clientPreImage)
377-
require.NoError(ctx.T, err)
379+
require.NoError(ctx.Context.T, err)
378380

379381
if scriptVersion != swap.HtlcV3 {
380382
ctx.assertPreimagePush(preimage)

liquidity/loopin.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ type loopInSwapSuggestion struct {
1919

2020
// amount returns the amount of the swap suggestion.
2121
func (l *loopInSwapSuggestion) amount() btcutil.Amount {
22-
return l.Amount
22+
return l.LoopInRequest.Amount
2323
}
2424

2525
// fees returns the highest fees that we could pay for the swap suggestion.
2626
func (l *loopInSwapSuggestion) fees() btcutil.Amount {
2727
return worstCaseInFees(
28-
l.MaxMinerFee, l.MaxSwapFee, defaultLoopInSweepFee,
28+
l.LoopInRequest.MaxMinerFee, l.LoopInRequest.MaxSwapFee,
29+
defaultLoopInSweepFee,
2930
)
3031
}
3132

@@ -37,12 +38,12 @@ func (l *loopInSwapSuggestion) channels() []lnwire.ShortChannelID {
3738

3839
// peers returns the peer that a loop in swap is restricted to, if it is set.
3940
func (l *loopInSwapSuggestion) peers(_ map[uint64]route.Vertex) []route.Vertex {
40-
if l.LastHop == nil {
41+
if l.LoopInRequest.LastHop == nil {
4142
return nil
4243
}
4344

4445
return []route.Vertex{
45-
*l.LastHop,
46+
*l.LoopInRequest.LastHop,
4647
}
4748
}
4849

liquidity/loopout.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@ type loopOutSwapSuggestion struct {
2020

2121
// amount returns the amount being swapped.
2222
func (l *loopOutSwapSuggestion) amount() btcutil.Amount {
23-
return l.Amount
23+
return l.OutRequest.Amount
2424
}
2525

2626
// fees returns the maximum fees we could possibly pay for this swap.
2727
func (l *loopOutSwapSuggestion) fees() btcutil.Amount {
2828
return worstCaseOutFees(
29-
l.MaxPrepayRoutingFee, l.MaxSwapRoutingFee, l.MaxSwapFee,
30-
l.MaxMinerFee, l.MaxPrepayAmount,
29+
l.OutRequest.MaxPrepayRoutingFee, l.OutRequest.MaxSwapRoutingFee,
30+
l.OutRequest.MaxSwapFee, l.OutRequest.MaxMinerFee,
31+
l.OutRequest.MaxPrepayAmount,
3132
)
3233
}
3334

3435
// channels returns the set of channels the loop out swap is restricted to.
3536
func (l *loopOutSwapSuggestion) channels() []lnwire.ShortChannelID {
36-
channels := make([]lnwire.ShortChannelID, len(l.OutgoingChanSet))
37+
channels := make(
38+
[]lnwire.ShortChannelID, len(l.OutRequest.OutgoingChanSet),
39+
)
3740

38-
for i, id := range l.OutgoingChanSet {
41+
for i, id := range l.OutRequest.OutgoingChanSet {
3942
channels[i] = lnwire.NewShortChanIDFromInt(id)
4043
}
4144

@@ -48,7 +51,7 @@ func (l *loopOutSwapSuggestion) peers(
4851

4952
peers := make(map[route.Vertex]struct{}, len(knownChans))
5053

51-
for _, channel := range l.OutgoingChanSet {
54+
for _, channel := range l.OutRequest.OutgoingChanSet {
5255
peer, ok := knownChans[channel]
5356
if !ok {
5457
log.Warnf("peer for channel: %v unknown", channel)

test/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (ctx *Context) AssertPaid(
161161
expectedMemo)
162162
}
163163

164-
payReq := ctx.DecodeInvoice(swapPayment.Invoice)
164+
payReq := ctx.DecodeInvoice(swapPayment.SendPaymentRequest.Invoice)
165165

166166
_, ok := ctx.PaidInvoices[*payReq.Description]
167167
require.False(

test/lnd_services_mock.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,7 @@ func (s *LndMockServices) DecodeInvoice(request string) (*zpay32.Invoice,
262262
func (s *LndMockServices) SetFeeEstimate(confTarget int32,
263263
feeEstimate chainfee.SatPerKWeight) {
264264

265-
s.WalletKit.(*mockWalletKit).setFeeEstimate(confTarget, feeEstimate)
265+
s.LndServices.WalletKit.(*mockWalletKit).setFeeEstimate(
266+
confTarget, feeEstimate,
267+
)
266268
}

testcontext_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,45 +140,45 @@ func (ctx *testContext) finish() {
140140
ctx.stop()
141141
select {
142142
case err := <-ctx.runErr:
143-
require.NoError(ctx.T, err)
143+
require.NoError(ctx.Context.T, err)
144144

145145
case <-time.After(test.Timeout):
146-
ctx.T.Fatal("client not stopping")
146+
ctx.Context.T.Fatal("client not stopping")
147147
}
148148

149149
ctx.assertIsDone()
150150
}
151151
func (ctx *testContext) assertIsDone() {
152-
require.NoError(ctx.T, ctx.Lnd.IsDone())
153-
require.NoError(ctx.T, ctx.store.isDone())
152+
require.NoError(ctx.Context.T, ctx.Context.Lnd.IsDone())
153+
require.NoError(ctx.Context.T, ctx.store.isDone())
154154

155155
select {
156156
case <-ctx.statusChan:
157-
ctx.T.Fatalf("not all status updates read")
157+
ctx.Context.T.Fatalf("not all status updates read")
158158
default:
159159
}
160160
}
161161

162162
func (ctx *testContext) assertStored() {
163-
ctx.T.Helper()
163+
ctx.Context.T.Helper()
164164

165165
ctx.store.assertLoopOutStored()
166166
}
167167

168168
func (ctx *testContext) assertStorePreimageReveal() {
169-
ctx.T.Helper()
169+
ctx.Context.T.Helper()
170170

171171
ctx.store.assertStorePreimageReveal()
172172
}
173173

174174
func (ctx *testContext) assertStoreFinished(expectedResult loopdb.SwapState) {
175-
ctx.T.Helper()
175+
ctx.Context.T.Helper()
176176

177177
ctx.store.assertStoreFinished(expectedResult)
178178
}
179179

180180
func (ctx *testContext) assertStatus(expectedState loopdb.SwapState) {
181-
ctx.T.Helper()
181+
ctx.Context.T.Helper()
182182

183183
for {
184184
select {
@@ -191,7 +191,7 @@ func (ctx *testContext) assertStatus(expectedState loopdb.SwapState) {
191191
return
192192
}
193193
case <-time.After(test.Timeout):
194-
ctx.T.Fatalf("expected status %v not "+
194+
ctx.Context.T.Fatalf("expected status %v not "+
195195
"received in time", expectedState)
196196
}
197197
}
@@ -218,7 +218,7 @@ func (ctx *testContext) publishHtlc(script []byte,
218218
Tx: &htlcTx,
219219
}:
220220
case <-time.After(test.Timeout):
221-
ctx.T.Fatalf("htlc confirmed not consumed")
221+
ctx.Context.T.Fatalf("htlc confirmed not consumed")
222222
}
223223

224224
return wire.OutPoint{
@@ -238,7 +238,7 @@ func (ctx *testContext) trackPayment(status lnrpc.Payment_PaymentStatus) {
238238
}:
239239

240240
case <-time.After(test.Timeout):
241-
ctx.T.Fatalf("could not send payment update")
241+
ctx.Context.T.Fatalf("could not send payment update")
242242
}
243243
}
244244

@@ -247,9 +247,9 @@ func (ctx *testContext) trackPayment(status lnrpc.Payment_PaymentStatus) {
247247
func (ctx *testContext) assertPreimagePush(preimage lntypes.Preimage) {
248248
select {
249249
case pushedPreimage := <-ctx.serverMock.preimagePush:
250-
require.Equal(ctx.T, preimage, pushedPreimage)
250+
require.Equal(ctx.Context.T, preimage, pushedPreimage)
251251

252252
case <-time.After(test.Timeout):
253-
ctx.T.Fatalf("preimage not pushed")
253+
ctx.Context.T.Fatalf("preimage not pushed")
254254
}
255255
}

0 commit comments

Comments
 (0)