mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
build: fixup new linter issues
This commit is contained in:
parent
451311d582
commit
4d34eb97ce
6 changed files with 42 additions and 34 deletions
|
|
@ -65,7 +65,7 @@ func TestLoopOutSuccess(t *testing.T) {
|
|||
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
|
||||
|
||||
// Expect client to register for conf.
|
||||
confIntent := ctx.AssertRegisterConf(false, req.HtlcConfirmations)
|
||||
confIntent := ctx.Context.AssertRegisterConf(false, req.HtlcConfirmations)
|
||||
|
||||
testLoopOutSuccess(ctx, testRequest.Amount, info.SwapHash,
|
||||
signalPrepaymentResult, signalSwapPaymentResult, false,
|
||||
|
|
@ -89,7 +89,7 @@ func TestLoopOutFailOffchain(t *testing.T) {
|
|||
signalSwapPaymentResult := ctx.AssertPaid(swapInvoiceDesc)
|
||||
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
|
||||
|
||||
ctx.AssertRegisterConf(false, defaultConfirmations)
|
||||
ctx.Context.AssertRegisterConf(false, defaultConfirmations)
|
||||
|
||||
signalSwapPaymentResult(
|
||||
errors.New(lndclient.PaymentResultUnknownPaymentHash),
|
||||
|
|
@ -274,7 +274,9 @@ func testLoopOutResume(t *testing.T, confs uint32, expired, preimageRevealed,
|
|||
signalPrepaymentResult := ctx.AssertPaid(prepayInvoiceDesc)
|
||||
|
||||
// Expect client to register for our expected number of confirmations.
|
||||
confIntent := ctx.AssertRegisterConf(preimageRevealed, int32(confs))
|
||||
confIntent := ctx.Context.AssertRegisterConf(
|
||||
preimageRevealed, int32(confs),
|
||||
)
|
||||
|
||||
htlc, err := GetHtlc(
|
||||
hash, &pendingSwap.Contract.SwapContract,
|
||||
|
|
@ -325,7 +327,7 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
|
||||
// Expect a signing request in the non taproot case.
|
||||
if scriptVersion != swap.HtlcV3 {
|
||||
<-ctx.Lnd.SignOutputRawChannel
|
||||
<-ctx.Context.Lnd.SignOutputRawChannel
|
||||
}
|
||||
|
||||
if !preimageRevealed {
|
||||
|
|
@ -345,14 +347,14 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
ctx.expiryChan <- testTime
|
||||
ctx.assertPreimagePush(testPreimage)
|
||||
}
|
||||
<-ctx.Lnd.SignOutputRawChannel
|
||||
<-ctx.Context.Lnd.SignOutputRawChannel
|
||||
}
|
||||
|
||||
// Expect client on-chain sweep of HTLC.
|
||||
sweepTx := ctx.ReceiveTx()
|
||||
|
||||
require.Equal(
|
||||
ctx.T, htlcOutpoint.Hash[:],
|
||||
ctx.Context.T, htlcOutpoint.Hash[:],
|
||||
sweepTx.TxIn[0].PreviousOutPoint.Hash[:],
|
||||
"client not sweeping from htlc tx",
|
||||
)
|
||||
|
|
@ -369,12 +371,12 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
// Check preimage.
|
||||
clientPreImage := sweepTx.TxIn[0].Witness[preImageIndex]
|
||||
clientPreImageHash := sha256.Sum256(clientPreImage)
|
||||
require.Equal(ctx.T, hash, lntypes.Hash(clientPreImageHash))
|
||||
require.Equal(ctx.Context.T, hash, lntypes.Hash(clientPreImageHash))
|
||||
|
||||
// Since we successfully published our sweep, we expect the preimage to
|
||||
// have been pushed to our mock server.
|
||||
preimage, err := lntypes.MakePreimage(clientPreImage)
|
||||
require.NoError(ctx.T, err)
|
||||
require.NoError(ctx.Context.T, err)
|
||||
|
||||
if scriptVersion != swap.HtlcV3 {
|
||||
ctx.assertPreimagePush(preimage)
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ type loopInSwapSuggestion struct {
|
|||
|
||||
// amount returns the amount of the swap suggestion.
|
||||
func (l *loopInSwapSuggestion) amount() btcutil.Amount {
|
||||
return l.Amount
|
||||
return l.LoopInRequest.Amount
|
||||
}
|
||||
|
||||
// fees returns the highest fees that we could pay for the swap suggestion.
|
||||
func (l *loopInSwapSuggestion) fees() btcutil.Amount {
|
||||
return worstCaseInFees(
|
||||
l.MaxMinerFee, l.MaxSwapFee, defaultLoopInSweepFee,
|
||||
l.LoopInRequest.MaxMinerFee, l.LoopInRequest.MaxSwapFee,
|
||||
defaultLoopInSweepFee,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -37,12 +38,12 @@ func (l *loopInSwapSuggestion) channels() []lnwire.ShortChannelID {
|
|||
|
||||
// peers returns the peer that a loop in swap is restricted to, if it is set.
|
||||
func (l *loopInSwapSuggestion) peers(_ map[uint64]route.Vertex) []route.Vertex {
|
||||
if l.LastHop == nil {
|
||||
if l.LoopInRequest.LastHop == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return []route.Vertex{
|
||||
*l.LastHop,
|
||||
*l.LoopInRequest.LastHop,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,22 +20,25 @@ type loopOutSwapSuggestion struct {
|
|||
|
||||
// amount returns the amount being swapped.
|
||||
func (l *loopOutSwapSuggestion) amount() btcutil.Amount {
|
||||
return l.Amount
|
||||
return l.OutRequest.Amount
|
||||
}
|
||||
|
||||
// fees returns the maximum fees we could possibly pay for this swap.
|
||||
func (l *loopOutSwapSuggestion) fees() btcutil.Amount {
|
||||
return worstCaseOutFees(
|
||||
l.MaxPrepayRoutingFee, l.MaxSwapRoutingFee, l.MaxSwapFee,
|
||||
l.MaxMinerFee, l.MaxPrepayAmount,
|
||||
l.OutRequest.MaxPrepayRoutingFee, l.OutRequest.MaxSwapRoutingFee,
|
||||
l.OutRequest.MaxSwapFee, l.OutRequest.MaxMinerFee,
|
||||
l.OutRequest.MaxPrepayAmount,
|
||||
)
|
||||
}
|
||||
|
||||
// channels returns the set of channels the loop out swap is restricted to.
|
||||
func (l *loopOutSwapSuggestion) channels() []lnwire.ShortChannelID {
|
||||
channels := make([]lnwire.ShortChannelID, len(l.OutgoingChanSet))
|
||||
channels := make(
|
||||
[]lnwire.ShortChannelID, len(l.OutRequest.OutgoingChanSet),
|
||||
)
|
||||
|
||||
for i, id := range l.OutgoingChanSet {
|
||||
for i, id := range l.OutRequest.OutgoingChanSet {
|
||||
channels[i] = lnwire.NewShortChanIDFromInt(id)
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +51,7 @@ func (l *loopOutSwapSuggestion) peers(
|
|||
|
||||
peers := make(map[route.Vertex]struct{}, len(knownChans))
|
||||
|
||||
for _, channel := range l.OutgoingChanSet {
|
||||
for _, channel := range l.OutRequest.OutgoingChanSet {
|
||||
peer, ok := knownChans[channel]
|
||||
if !ok {
|
||||
log.Warnf("peer for channel: %v unknown", channel)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ func (ctx *Context) AssertPaid(
|
|||
expectedMemo)
|
||||
}
|
||||
|
||||
payReq := ctx.DecodeInvoice(swapPayment.Invoice)
|
||||
payReq := ctx.DecodeInvoice(swapPayment.SendPaymentRequest.Invoice)
|
||||
|
||||
_, ok := ctx.PaidInvoices[*payReq.Description]
|
||||
require.False(
|
||||
|
|
|
|||
|
|
@ -262,5 +262,7 @@ func (s *LndMockServices) DecodeInvoice(request string) (*zpay32.Invoice,
|
|||
func (s *LndMockServices) SetFeeEstimate(confTarget int32,
|
||||
feeEstimate chainfee.SatPerKWeight) {
|
||||
|
||||
s.WalletKit.(*mockWalletKit).setFeeEstimate(confTarget, feeEstimate)
|
||||
s.LndServices.WalletKit.(*mockWalletKit).setFeeEstimate(
|
||||
confTarget, feeEstimate,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,45 +140,45 @@ func (ctx *testContext) finish() {
|
|||
ctx.stop()
|
||||
select {
|
||||
case err := <-ctx.runErr:
|
||||
require.NoError(ctx.T, err)
|
||||
require.NoError(ctx.Context.T, err)
|
||||
|
||||
case <-time.After(test.Timeout):
|
||||
ctx.T.Fatal("client not stopping")
|
||||
ctx.Context.T.Fatal("client not stopping")
|
||||
}
|
||||
|
||||
ctx.assertIsDone()
|
||||
}
|
||||
func (ctx *testContext) assertIsDone() {
|
||||
require.NoError(ctx.T, ctx.Lnd.IsDone())
|
||||
require.NoError(ctx.T, ctx.store.isDone())
|
||||
require.NoError(ctx.Context.T, ctx.Context.Lnd.IsDone())
|
||||
require.NoError(ctx.Context.T, ctx.store.isDone())
|
||||
|
||||
select {
|
||||
case <-ctx.statusChan:
|
||||
ctx.T.Fatalf("not all status updates read")
|
||||
ctx.Context.T.Fatalf("not all status updates read")
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (ctx *testContext) assertStored() {
|
||||
ctx.T.Helper()
|
||||
ctx.Context.T.Helper()
|
||||
|
||||
ctx.store.assertLoopOutStored()
|
||||
}
|
||||
|
||||
func (ctx *testContext) assertStorePreimageReveal() {
|
||||
ctx.T.Helper()
|
||||
ctx.Context.T.Helper()
|
||||
|
||||
ctx.store.assertStorePreimageReveal()
|
||||
}
|
||||
|
||||
func (ctx *testContext) assertStoreFinished(expectedResult loopdb.SwapState) {
|
||||
ctx.T.Helper()
|
||||
ctx.Context.T.Helper()
|
||||
|
||||
ctx.store.assertStoreFinished(expectedResult)
|
||||
}
|
||||
|
||||
func (ctx *testContext) assertStatus(expectedState loopdb.SwapState) {
|
||||
ctx.T.Helper()
|
||||
ctx.Context.T.Helper()
|
||||
|
||||
for {
|
||||
select {
|
||||
|
|
@ -191,7 +191,7 @@ func (ctx *testContext) assertStatus(expectedState loopdb.SwapState) {
|
|||
return
|
||||
}
|
||||
case <-time.After(test.Timeout):
|
||||
ctx.T.Fatalf("expected status %v not "+
|
||||
ctx.Context.T.Fatalf("expected status %v not "+
|
||||
"received in time", expectedState)
|
||||
}
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ func (ctx *testContext) publishHtlc(script []byte,
|
|||
Tx: &htlcTx,
|
||||
}:
|
||||
case <-time.After(test.Timeout):
|
||||
ctx.T.Fatalf("htlc confirmed not consumed")
|
||||
ctx.Context.T.Fatalf("htlc confirmed not consumed")
|
||||
}
|
||||
|
||||
return wire.OutPoint{
|
||||
|
|
@ -238,7 +238,7 @@ func (ctx *testContext) trackPayment(status lnrpc.Payment_PaymentStatus) {
|
|||
}:
|
||||
|
||||
case <-time.After(test.Timeout):
|
||||
ctx.T.Fatalf("could not send payment update")
|
||||
ctx.Context.T.Fatalf("could not send payment update")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +247,9 @@ func (ctx *testContext) trackPayment(status lnrpc.Payment_PaymentStatus) {
|
|||
func (ctx *testContext) assertPreimagePush(preimage lntypes.Preimage) {
|
||||
select {
|
||||
case pushedPreimage := <-ctx.serverMock.preimagePush:
|
||||
require.Equal(ctx.T, preimage, pushedPreimage)
|
||||
require.Equal(ctx.Context.T, preimage, pushedPreimage)
|
||||
|
||||
case <-time.After(test.Timeout):
|
||||
ctx.T.Fatalf("preimage not pushed")
|
||||
ctx.Context.T.Fatalf("preimage not pushed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue