mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: fix most obvious linter errors
This commit is contained in:
parent
1cdb233a00
commit
36838cf7f4
21 changed files with 41 additions and 50 deletions
|
|
@ -384,7 +384,7 @@ func (s *Client) LoopOutQuote(ctx context.Context,
|
|||
return &LoopOutQuote{
|
||||
SwapFee: swapFee,
|
||||
MinerFee: minerFee,
|
||||
PrepayAmount: btcutil.Amount(quote.PrepayAmount),
|
||||
PrepayAmount: quote.PrepayAmount,
|
||||
SwapPaymentDest: quote.SwapPaymentDest,
|
||||
CltvDelta: quote.CltvDelta,
|
||||
}, nil
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ func loopIn(ctx *cli.Context) error {
|
|||
args = args.Tail()
|
||||
default:
|
||||
// Show command help if no arguments and flags were provided.
|
||||
cli.ShowCommandHelp(ctx, "in")
|
||||
return nil
|
||||
return cli.ShowCommandHelp(ctx, "in")
|
||||
}
|
||||
|
||||
amt, err := parseAmt(amtStr)
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ func loopOut(ctx *cli.Context) error {
|
|||
args = args.Tail()
|
||||
default:
|
||||
// Show command help if no arguments and flags were provided.
|
||||
cli.ShowCommandHelp(ctx, "out")
|
||||
return nil
|
||||
return cli.ShowCommandHelp(ctx, "out")
|
||||
}
|
||||
|
||||
amt, err := parseAmt(amtStr)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ type limits struct {
|
|||
}
|
||||
|
||||
func getLimits(amt btcutil.Amount, quote *looprpc.QuoteResponse) *limits {
|
||||
maxSwapRoutingFee := getMaxRoutingFee(btcutil.Amount(amt))
|
||||
maxSwapRoutingFee := getMaxRoutingFee(amt)
|
||||
maxPrepayRoutingFee := getMaxRoutingFee(btcutil.Amount(
|
||||
quote.PrepayAmt,
|
||||
))
|
||||
|
|
@ -126,7 +126,7 @@ func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits,
|
|||
if l.maxPrepayRoutingFee != nil {
|
||||
totalSuccessMax += *l.maxPrepayRoutingFee
|
||||
}
|
||||
|
||||
|
||||
if swapType == loop.TypeIn && externalHtlc {
|
||||
fmt.Printf("On-chain fee for external loop in is not " +
|
||||
"included.\nSufficient fees will need to be paid " +
|
||||
|
|
@ -135,7 +135,7 @@ func displayLimits(swapType loop.Type, amt btcutil.Amount, l *limits,
|
|||
}
|
||||
|
||||
fmt.Printf("Max swap fees for %d Loop %v: %d\n",
|
||||
btcutil.Amount(amt), swapType, totalSuccessMax,
|
||||
amt, swapType, totalSuccessMax,
|
||||
)
|
||||
|
||||
fmt.Printf("CONTINUE SWAP? (y/n), expand fee detail (x): ")
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ func quote(ctx *cli.Context) error {
|
|||
// Show command help if the incorrect number arguments and/or flags were
|
||||
// provided.
|
||||
if ctx.NArg() != 1 || ctx.NumFlags() > 1 {
|
||||
cli.ShowCommandHelp(ctx, "quote")
|
||||
return nil
|
||||
return cli.ShowCommandHelp(ctx, "quote")
|
||||
}
|
||||
|
||||
args := ctx.Args()
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ func (s *executor) run(mainCtx context.Context,
|
|||
|
||||
select {
|
||||
case h := <-blockEpochChan:
|
||||
setHeight(int32(h))
|
||||
setHeight(h)
|
||||
case err := <-blockErrorChan:
|
||||
return err
|
||||
case <-mainCtx.Done():
|
||||
|
|
@ -134,10 +134,10 @@ func (s *executor) run(mainCtx context.Context,
|
|||
delete(blockEpochQueues, doneID)
|
||||
|
||||
case h := <-blockEpochChan:
|
||||
setHeight(int32(h))
|
||||
setHeight(h)
|
||||
for _, queue := range blockEpochQueues {
|
||||
select {
|
||||
case queue.ChanIn() <- int32(h):
|
||||
case queue.ChanIn() <- h:
|
||||
case <-mainCtx.Done():
|
||||
return mainCtx.Err()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ func (s *invoicesClient) WaitForFinished() {
|
|||
func (s *invoicesClient) SettleInvoice(ctx context.Context,
|
||||
preimage lntypes.Preimage) error {
|
||||
|
||||
rpcCtx, cancel := context.WithTimeout(ctx, rpcTimeout)
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, rpcTimeout)
|
||||
defer cancel()
|
||||
|
||||
rpcCtx = s.invoiceMac.WithMacaroonAuth(ctx)
|
||||
rpcCtx := s.invoiceMac.WithMacaroonAuth(timeoutCtx)
|
||||
_, err := s.client.SettleInvoice(rpcCtx, &invoicesrpc.SettleInvoiceMsg{
|
||||
Preimage: preimage[:],
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package lndclient
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
)
|
||||
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import (
|
|||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
|
|
|||
5
log.go
5
log.go
|
|
@ -12,9 +12,8 @@ import (
|
|||
// means the package will not perform any logging by default until the caller
|
||||
// requests it.
|
||||
var (
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
logger = backendLog.Logger("CLIENT")
|
||||
servicesLogger = backendLog.Logger("SERVICES")
|
||||
backendLog = btclog.NewBackend(logWriter{})
|
||||
logger = backendLog.Logger("CLIENT")
|
||||
)
|
||||
|
||||
// logWriter implements an io.Writer that outputs to both standard output and
|
||||
|
|
|
|||
|
|
@ -127,7 +127,10 @@ func deserializeLoopInContract(value []byte) (*LoopInContract, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
binary.Read(r, byteOrder, &contract.AmountRequested)
|
||||
err = binary.Read(r, byteOrder, &contract.AmountRequested)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
n, err := r.Read(contract.SenderKey[:])
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,10 @@ func deserializeLoopOutContract(value []byte, chainParams *chaincfg.Params) (
|
|||
return nil, err
|
||||
}
|
||||
|
||||
binary.Read(r, byteOrder, &contract.AmountRequested)
|
||||
err = binary.Read(r, byteOrder, &contract.AmountRequested)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
contract.PrepayInvoice, err = wire.ReadVarString(r, 0)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
|
|||
case err := <-swapInvoiceErr:
|
||||
return err
|
||||
|
||||
// An update to the swap invoice occured. Check the new state
|
||||
// An update to the swap invoice occurred. Check the new state
|
||||
// and update the swap state accordingly.
|
||||
case update := <-swapInvoiceChan:
|
||||
s.log.Infof("Received swap invoice update: %v",
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
|||
// Notify the confirmation notification for the HTLC.
|
||||
ctx.AssertRegisterConf()
|
||||
|
||||
blockEpochChan <- int32(ctx.Lnd.Height + 1)
|
||||
blockEpochChan <- ctx.Lnd.Height + 1
|
||||
|
||||
htlcTx := wire.NewMsgTx(2)
|
||||
htlcTx.AddTxOut(&wire.TxOut{
|
||||
|
|
@ -238,7 +238,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
|||
|
||||
// The sweep should have a fee that corresponds to the custom
|
||||
// confirmation target.
|
||||
sweepTx := assertSweepTx(testRequest.SweepConfTarget)
|
||||
_ = assertSweepTx(testRequest.SweepConfTarget)
|
||||
|
||||
// We'll then notify the height at which we begin using the default
|
||||
// confirmation target.
|
||||
|
|
@ -249,7 +249,7 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
|||
|
||||
// We should expect to see another sweep using the higher fee since the
|
||||
// spend hasn't been confirmed yet.
|
||||
sweepTx = assertSweepTx(DefaultSweepConfTarget)
|
||||
sweepTx := assertSweepTx(DefaultSweepConfTarget)
|
||||
|
||||
// Notify the spend so that the swap reaches its final state.
|
||||
ctx.NotifySpend(sweepTx, 0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
|
|
@ -20,20 +19,14 @@ var (
|
|||
|
||||
testLoopOutOnChainCltvDelta = int32(30)
|
||||
testChargeOnChainCltvDelta = int32(100)
|
||||
testCltvDelta = 50
|
||||
testSwapFee = btcutil.Amount(210)
|
||||
testInvoiceExpiry = 180 * time.Second
|
||||
testFixedPrepayAmount = btcutil.Amount(100)
|
||||
testMinSwapAmount = btcutil.Amount(10000)
|
||||
testMaxSwapAmount = btcutil.Amount(1000000)
|
||||
testTxConfTarget = 2
|
||||
testRepublishDelay = 10 * time.Second
|
||||
)
|
||||
|
||||
// serverMock is used in client unit tests to simulate swap server behaviour.
|
||||
type serverMock struct {
|
||||
t *testing.T
|
||||
|
||||
expectedSwapAmt btcutil.Amount
|
||||
swapInvoiceAmt btcutil.Amount
|
||||
prepayInvoiceAmt btcutil.Amount
|
||||
|
|
|
|||
|
|
@ -25,11 +25,6 @@ type storeMock struct {
|
|||
t *testing.T
|
||||
}
|
||||
|
||||
type finishData struct {
|
||||
preimage lntypes.Hash
|
||||
result loopdb.SwapState
|
||||
}
|
||||
|
||||
// NewStoreMock instantiates a new mock store.
|
||||
func newStoreMock(t *testing.T) *storeMock {
|
||||
return &storeMock{
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ func (s *Sweeper) GetSweepFee(ctx context.Context,
|
|||
case *btcutil.AddressPubKeyHash:
|
||||
weightEstimate.AddP2PKHOutput()
|
||||
default:
|
||||
return 0, fmt.Errorf("unknown adress type %T", destAddr)
|
||||
return 0, fmt.Errorf("unknown address type %T", destAddr)
|
||||
}
|
||||
|
||||
addInputEstimate(&weightEstimate)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btclog"
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog"
|
||||
)
|
||||
|
||||
// log is a logger that is initialized with no output filters. This
|
||||
|
|
|
|||
|
|
@ -91,5 +91,8 @@ func GetInvoice(hash lntypes.Hash, amt btcutil.Amount, memo string) (
|
|||
|
||||
// DumpGoroutines dumps all currently running goroutines.
|
||||
func DumpGoroutines() {
|
||||
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
err := pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ func Guard(t *testing.T) func() {
|
|||
go func() {
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
err := pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
panic("test timeout")
|
||||
case <-done:
|
||||
|
|
|
|||
|
|
@ -21,14 +21,6 @@ var (
|
|||
1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4,
|
||||
})
|
||||
testPrepayPreimage = lntypes.Preimage([32]byte{
|
||||
1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4,
|
||||
1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 5,
|
||||
})
|
||||
|
||||
testStartingHeight = uint32(600)
|
||||
)
|
||||
|
||||
// testContext contains functionality to support client unit tests.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue