mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: update linter, fix issues
This commit is contained in:
parent
722ad8839d
commit
65251e8821
36 changed files with 617 additions and 1200 deletions
|
|
@ -1,15 +1,13 @@
|
|||
run:
|
||||
# timeout for analysis
|
||||
deadline: 4m
|
||||
timeout: 4m
|
||||
|
||||
skip-files:
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
go: "1.23"
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
# Don't report about shadowed variables
|
||||
check-shadowing: false
|
||||
shadowing: false
|
||||
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
|
|
@ -28,10 +26,10 @@ linters-settings:
|
|||
excludes:
|
||||
- G402 # Look for bad TLS connection settings.
|
||||
- G306 # Poor file permissions used when writing to a new file.
|
||||
- G115 # Integer overflow conversion.
|
||||
|
||||
staticcheck:
|
||||
go: "1.18"
|
||||
checks: ["-SA1019"]
|
||||
checks: [ "-SA1019" ]
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
|
|
@ -71,15 +69,6 @@ linters:
|
|||
# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
|
||||
- errorlint
|
||||
|
||||
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
|
||||
- interfacer
|
||||
- golint
|
||||
- maligned
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- deadcode
|
||||
|
||||
# New linters that need a code adjustment first.
|
||||
- wrapcheck
|
||||
- nolintlint
|
||||
|
|
@ -96,10 +85,8 @@ linters:
|
|||
- containedctx
|
||||
- contextcheck
|
||||
- errname
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- gomnd
|
||||
- ifshort
|
||||
- err113
|
||||
- mnd
|
||||
- noctx
|
||||
- nestif
|
||||
- wsl
|
||||
|
|
@ -112,8 +99,12 @@ linters:
|
|||
- revive
|
||||
- tagalign
|
||||
- depguard
|
||||
- nosnakecase
|
||||
- interfacebloat
|
||||
- inamedparam
|
||||
- intrange
|
||||
- perfsprint
|
||||
- protogetter
|
||||
- testifylint
|
||||
|
||||
# Additions compared to LND
|
||||
- exhaustruct
|
||||
|
|
@ -122,8 +113,11 @@ issues:
|
|||
# Only show newly introduced problems.
|
||||
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250
|
||||
|
||||
exclude-rules:
|
||||
exclude-files:
|
||||
- "\\.pb\\.go$"
|
||||
- "\\.pb\\.gw\\.go$"
|
||||
|
||||
exclude-rules:
|
||||
# Allow fmt.Printf() in test files
|
||||
- path: _test\.go
|
||||
linters:
|
||||
|
|
@ -138,6 +132,7 @@ issues:
|
|||
- path: cmd/loopd/*
|
||||
linters:
|
||||
- forbidigo
|
||||
- errcheck
|
||||
- path: loopd/*
|
||||
linters:
|
||||
- forbidigo
|
||||
|
|
@ -146,6 +141,7 @@ issues:
|
|||
- path: cmd/loop/*
|
||||
linters:
|
||||
- forbidigo
|
||||
- errcheck
|
||||
|
||||
# Allow fmt.Printf() in stateparser
|
||||
- path: fsm/stateparser/*
|
||||
|
|
|
|||
|
|
@ -321,8 +321,6 @@ func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
|
|||
swaps := make([]*SwapInfo, 0, len(loopInSwaps)+len(loopOutSwaps))
|
||||
|
||||
for _, swp := range loopOutSwaps {
|
||||
swp := swp
|
||||
|
||||
swapInfo := &SwapInfo{
|
||||
SwapType: swap.TypeOut,
|
||||
SwapContract: swp.Contract.SwapContract,
|
||||
|
|
@ -358,8 +356,6 @@ func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
|
|||
}
|
||||
|
||||
for _, swp := range loopInSwaps {
|
||||
swp := swp
|
||||
|
||||
swapInfo := &SwapInfo{
|
||||
SwapType: swap.TypeIn,
|
||||
SwapContract: swp.Contract.SwapContract,
|
||||
|
|
|
|||
|
|
@ -175,8 +175,6 @@ func TestLoopOutResume(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, version := range storedVersion {
|
||||
version := version
|
||||
|
||||
t.Run(version.String(), func(t *testing.T) {
|
||||
t.Run("not expired", func(t *testing.T) {
|
||||
testLoopOutResume(
|
||||
|
|
@ -443,8 +441,6 @@ func TestWrapGrpcError(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := wrapGrpcError("", testCase.original)
|
||||
require.Error(t, err, "test only expects errors")
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ func terms(ctx *cli.Context) error {
|
|||
}
|
||||
defer cleanup()
|
||||
|
||||
printAmountRange := func(min, max int64) {
|
||||
printAmountRange := func(minAmt, maxAmt int64) {
|
||||
fmt.Printf("Amount: %d - %d\n",
|
||||
btcutil.Amount(min), btcutil.Amount(max),
|
||||
btcutil.Amount(minAmt), btcutil.Amount(maxAmt),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,8 +76,6 @@ func TestExampleFSM(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctxb := context.Background()
|
||||
respondChan := make(chan string, 1)
|
||||
|
|
@ -192,8 +190,6 @@ func TestExampleFSMFlow(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
exampleContext, cachedObserver := getTestContext()
|
||||
ctxb := context.Background()
|
||||
|
|
@ -268,8 +264,6 @@ func TestObserverAsyncWait(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
service := &mockService{
|
||||
respondChan: make(chan bool),
|
||||
|
|
|
|||
|
|
@ -463,7 +463,6 @@ func pubkeyTo33ByteSlice(pubkey *btcec.PublicKey) [33]byte {
|
|||
func toNonces(nonces [][]byte) ([][66]byte, error) {
|
||||
res := make([][66]byte, 0, len(nonces))
|
||||
for _, n := range nonces {
|
||||
n := n
|
||||
nonce, err := byteSliceTo66ByteSlice(n)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ func TestInitReservationAction(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
ctxb := context.Background()
|
||||
mockLnd := test.NewMockLnd()
|
||||
mockReservationClient := new(mockReservationClient)
|
||||
|
|
@ -232,7 +231,6 @@ func TestSubscribeToConfirmationAction(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
chainNotifier := new(MockChainNotifier)
|
||||
ctxb := context.Background()
|
||||
|
|
@ -340,7 +338,6 @@ func TestAsyncWaitForExpiredOrSweptAction(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) { // Create a mock ChainNotifier and Reservation
|
||||
chainNotifier := new(MockChainNotifier)
|
||||
ctxb := context.Background()
|
||||
|
|
@ -418,7 +415,6 @@ func TestHandleSubcriptions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
chainNotifier := new(MockChainNotifier)
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func TestSqlStore(t *testing.T) {
|
|||
|
||||
reservations, err := store.ListReservations(ctxb)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(reservations))
|
||||
require.Len(t, reservations, 2)
|
||||
}
|
||||
|
||||
// getRandomReservationID generates a random reservation ID.
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ func TestValidate(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.Equal(t, test.err, Validate(test.label))
|
||||
|
|
|
|||
|
|
@ -446,9 +446,6 @@ func (m *Manager) autoloop(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
// Create a copy of our range var so that we can reference it.
|
||||
swap := swap
|
||||
|
||||
// Check if the parameter for custom address is defined for loop
|
||||
// outs.
|
||||
if m.params.DestAddr != nil {
|
||||
|
|
@ -472,7 +469,6 @@ func (m *Manager) autoloop(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
in := in
|
||||
loopIn, err := m.cfg.LoopIn(ctx, &in)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -910,8 +906,6 @@ func (m *Manager) SuggestSwaps(ctx context.Context) (
|
|||
}
|
||||
|
||||
for _, swap := range suggestions {
|
||||
swap := swap
|
||||
|
||||
// If we do not have enough funds available, or we hit our
|
||||
// in flight limit, we record this value for the rest of the
|
||||
// swaps.
|
||||
|
|
|
|||
|
|
@ -563,8 +563,6 @@ func TestRestrictedSuggestions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
// Create a manager config which will return the test
|
||||
// case's set of existing swaps.
|
||||
|
|
@ -638,8 +636,6 @@ func TestSweepFeeLimit(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
@ -820,8 +816,6 @@ func TestSuggestSwaps(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
@ -919,8 +913,6 @@ func TestFeeLimits(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
cfg.LoopOutQuote = func(context.Context,
|
||||
|
|
@ -1085,8 +1077,6 @@ func TestFeeBudget(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
@ -1293,8 +1283,6 @@ func TestInFlightLimit(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
cfg.ListLoopOut = func(context.Context) ([]*loopdb.LoopOut, error) {
|
||||
|
|
@ -1462,8 +1450,6 @@ func TestSizeRestrictions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
@ -1605,8 +1591,6 @@ func TestFeePercentage(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
@ -1771,8 +1755,6 @@ func TestBudgetWithLoopin(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
cfg, lnd := newTestConfig()
|
||||
|
||||
|
|
|
|||
|
|
@ -582,7 +582,6 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
|
|||
}
|
||||
|
||||
for peer, rule := range cfg.PeerRules {
|
||||
peer := peer
|
||||
rpcRule := newRPCRule(0, peer[:], rule)
|
||||
rpcCfg.Rules = append(rpcCfg.Rules, rpcRule)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ func TestValidateRestrictions(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
err := validateRestrictions(
|
||||
testCase.server, testCase.client,
|
||||
|
|
|
|||
|
|
@ -83,8 +83,6 @@ func TestValidateThreshold(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range tests {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
@ -162,8 +160,6 @@ func TestCalculateAmount(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
@ -245,8 +241,6 @@ func TestSuggestSwap(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
swap := test.rule.swapAmount(
|
||||
test.channel, test.outRestrictions,
|
||||
|
|
|
|||
|
|
@ -575,8 +575,6 @@ func (s *swapClientServer) ListSwaps(ctx context.Context,
|
|||
// persisted to disk. The swaps field is a map, that's why we need an
|
||||
// additional index.
|
||||
for _, swp := range s.swaps {
|
||||
swp := swp
|
||||
|
||||
// Filter the swap based on the provided filter.
|
||||
if !filterSwap(&swp, req.ListSwapFilter) {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package loopd
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
|
@ -125,8 +124,6 @@ func TestValidateConfTarget(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
target, err := validateConfTarget(
|
||||
test.confTarget, defaultConf,
|
||||
|
|
@ -476,8 +473,6 @@ func TestValidateLoopOutRequest(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
|
@ -501,7 +496,7 @@ func TestValidateLoopOutRequest(t *testing.T) {
|
|||
ctx, lnd.Client, &test.chain, req,
|
||||
test.destAddr, test.maxParts,
|
||||
)
|
||||
require.True(t, errors.Is(err, test.err))
|
||||
require.ErrorIs(t, err, test.err)
|
||||
require.Equal(t, test.expectedTarget, conf)
|
||||
})
|
||||
}
|
||||
|
|
@ -590,7 +585,6 @@ func TestHasBandwidth(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
res, shards := hasBandwidth(test.channels, test.amt,
|
||||
|
|
|
|||
|
|
@ -72,8 +72,6 @@ func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
|
|||
}
|
||||
|
||||
for _, s := range swaps {
|
||||
s := s
|
||||
|
||||
htlc, err := utils.GetHtlc(
|
||||
s.Hash, &s.Contract.SwapContract, chainParams,
|
||||
)
|
||||
|
|
@ -123,8 +121,6 @@ func viewIn(swapClient *loop.Client, chainParams *chaincfg.Params) error {
|
|||
}
|
||||
|
||||
for _, s := range swaps {
|
||||
s := s
|
||||
|
||||
htlc, err := utils.GetHtlc(
|
||||
s.Hash, &s.Contract.SwapContract, chainParams,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -86,8 +86,6 @@ func TestKeyLocatorMarshalUnMarshal(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
buf, err := MarshalKeyLocator(test.keyLoc)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
|||
|
|
@ -167,8 +167,6 @@ func (db *BaseDB) BatchCreateLoopOut(ctx context.Context,
|
|||
writeOpts := NewSqlWriteOpts()
|
||||
return db.ExecTx(ctx, writeOpts, func(tx *sqlc.Queries) error {
|
||||
for swapHash, swap := range swaps {
|
||||
swap := swap
|
||||
|
||||
insertArgs := loopToInsertArgs(
|
||||
swapHash, &swap.SwapContract,
|
||||
)
|
||||
|
|
@ -293,8 +291,6 @@ func (db *BaseDB) BatchCreateLoopIn(ctx context.Context,
|
|||
writeOpts := NewSqlWriteOpts()
|
||||
return db.ExecTx(ctx, writeOpts, func(tx *sqlc.Queries) error {
|
||||
for swapHash, swap := range swaps {
|
||||
swap := swap
|
||||
|
||||
insertArgs := loopToInsertArgs(
|
||||
swapHash, &swap.SwapContract,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -171,11 +171,7 @@ func TestLoopInTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, next := range []bool{false, true} {
|
||||
next := next
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
name := testCase.name
|
||||
if next {
|
||||
name += " experimental protocol"
|
||||
|
|
@ -384,10 +380,7 @@ func TestLoopInResume(t *testing.T) {
|
|||
|
||||
for _, next := range []bool{false, true} {
|
||||
for _, version := range storedVersion {
|
||||
version := version
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
name := fmt.Sprintf(
|
||||
"%v %v", testCase, version.String(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ func TestLoopOutSweepFeerateProvider(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
store := loopdb.NewStoreMock(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -634,9 +634,7 @@ func testPreimagePush(t *testing.T) {
|
|||
loopdb.StatePreimageRevealed,
|
||||
)
|
||||
status := <-statusChan
|
||||
require.Equal(
|
||||
t, status.State, loopdb.StatePreimageRevealed,
|
||||
)
|
||||
require.Equal(t, loopdb.StatePreimageRevealed, status.State)
|
||||
|
||||
preimage := <-server.preimagePush
|
||||
require.Equal(t, swap.Preimage, preimage)
|
||||
|
|
@ -682,9 +680,7 @@ func testPreimagePush(t *testing.T) {
|
|||
loopdb.StatePreimageRevealed,
|
||||
)
|
||||
status := <-statusChan
|
||||
require.Equal(
|
||||
t, status.State, loopdb.StatePreimageRevealed,
|
||||
)
|
||||
require.Equal(t, loopdb.StatePreimageRevealed, status.State)
|
||||
}
|
||||
|
||||
// We expect the sweep tx to have been published.
|
||||
|
|
@ -753,9 +749,7 @@ func testPreimagePush(t *testing.T) {
|
|||
|
||||
cfg.store.(*loopdb.StoreMock).AssertLoopOutState(loopdb.StateSuccess)
|
||||
status := <-statusChan
|
||||
require.Equal(
|
||||
t, status.State, loopdb.StateSuccess,
|
||||
)
|
||||
require.Equal(t, loopdb.StateSuccess, status.State)
|
||||
|
||||
require.NoError(t, <-errChan)
|
||||
}
|
||||
|
|
@ -1059,9 +1053,7 @@ func TestLoopOutMuSig2Sweep(t *testing.T) {
|
|||
loopdb.StatePreimageRevealed,
|
||||
)
|
||||
status := <-statusChan
|
||||
require.Equal(
|
||||
t, status.State, loopdb.StatePreimageRevealed,
|
||||
)
|
||||
require.Equal(t, loopdb.StatePreimageRevealed, status.State)
|
||||
|
||||
preimage := <-server.preimagePush
|
||||
require.Equal(t, swap.Preimage, preimage)
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ func TestManager_Backoff_Pending_Token(t *testing.T) {
|
|||
wg.Wait()
|
||||
|
||||
// Expect exactly 3 token calls.
|
||||
require.Equal(t, 3, len(tokenCalls))
|
||||
require.Len(t, tokenCalls, 3)
|
||||
|
||||
require.InDeltaf(
|
||||
t, 3*time.Second, tokenCalls[2].Sub(tokenCalls[0]),
|
||||
|
|
|
|||
|
|
@ -538,8 +538,6 @@ func TestLowHighRoutingPlugin(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
mockLnd := test.NewMockLnd()
|
||||
|
||||
|
|
|
|||
|
|
@ -171,8 +171,6 @@ func TestStaticAddressScript(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
tx.TxIn[0].Witness = testCase.witness(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -598,7 +598,6 @@ func withdrawalValue(prevOuts map[wire.OutPoint]*wire.TxOut) btcutil.Amount {
|
|||
func toNonces(nonces [][]byte) ([][musig2.PubNonceSize]byte, error) {
|
||||
res := make([][musig2.PubNonceSize]byte, 0, len(nonces))
|
||||
for _, n := range nonces {
|
||||
n := n
|
||||
nonce, err := byteSliceTo66ByteSlice(n)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -315,8 +315,6 @@ func TestHtlcV2(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
sweepTx.TxIn[0].Witness = testCase.witness(t)
|
||||
|
||||
|
|
@ -594,8 +592,6 @@ func testHtlcV3(t *testing.T, muSig2Version input.MuSig2Version) {
|
|||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
tx.TxIn[0].Witness = testCase.witness(t)
|
||||
|
||||
|
|
|
|||
|
|
@ -792,8 +792,6 @@ func (s *grpcSwapServerClient) MultiMuSig2SignSweep(ctx context.Context,
|
|||
prevOutInfo := make([]*swapserverrpc.PrevoutInfo, 0, len(prevoutMap))
|
||||
for prevOut, txOut := range prevoutMap {
|
||||
txOut := *txOut
|
||||
prevOut := prevOut
|
||||
|
||||
prevOutInfo = append(prevOutInfo,
|
||||
&swapserverrpc.PrevoutInfo{
|
||||
TxidBytes: prevOut.Hash[:],
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@ func TestEstimateSweepFeeIncrement(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
gotSweepFeeDetails, gotNewBatchFeeDetails, err :=
|
||||
estimateSweepFeeIncrement(tc.sweep)
|
||||
|
|
@ -402,7 +401,6 @@ func TestEstimateBatchWeight(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
gotBatchFeeDetails, err := estimateBatchWeight(tc.batch)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -730,7 +728,6 @@ func TestSelectBatches(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
gotBestBatchesIds, err := selectBatches(
|
||||
tc.batches, tc.sweep, tc.oneSweepBatch,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ func (s *StoreMock) FetchUnconfirmedSweepBatches(ctx context.Context) (
|
|||
|
||||
result := []*dbBatch{}
|
||||
for _, batch := range s.batches {
|
||||
batch := batch
|
||||
if batch.State != "confirmed" {
|
||||
result = append(result, &batch)
|
||||
}
|
||||
|
|
@ -106,7 +105,6 @@ func (s *StoreMock) FetchBatchSweeps(ctx context.Context,
|
|||
|
||||
result := []*dbSweep{}
|
||||
for _, sweep := range s.sweeps {
|
||||
sweep := sweep
|
||||
if sweep.BatchID == id {
|
||||
result = append(result, &sweep)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1704,7 +1704,6 @@ func (b *batch) handleSpend(ctx context.Context, spendTx *wire.MsgTx) error {
|
|||
)
|
||||
|
||||
for _, sweep := range notifyList {
|
||||
sweep := sweep
|
||||
// Save the sweep as completed.
|
||||
err := b.persistSweep(ctx, sweep, true)
|
||||
if err != nil {
|
||||
|
|
@ -1741,8 +1740,6 @@ func (b *batch) handleSpend(ctx context.Context, spendTx *wire.MsgTx) error {
|
|||
// Iterate over the purge list and feed the sweeps back to the
|
||||
// batcher.
|
||||
for _, sweep := range purgeList {
|
||||
sweep := sweep
|
||||
|
||||
err := b.purger(&sweep)
|
||||
if err != nil {
|
||||
b.Errorf("unable to purge sweep %x: %v",
|
||||
|
|
|
|||
|
|
@ -875,8 +875,6 @@ func (b *Batcher) FetchUnconfirmedBatches(ctx context.Context) ([]*batch,
|
|||
|
||||
batches := make([]*batch, 0, len(dbBatches))
|
||||
for _, bch := range dbBatches {
|
||||
bch := bch
|
||||
|
||||
batch := batch{}
|
||||
batch.id = bch.ID
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.22.6
|
||||
FROM golang:1.23.6
|
||||
|
||||
RUN apt-get update && apt-get install -y git
|
||||
ENV GOCACHE=/tmp/build/.cache
|
||||
|
|
|
|||
194
tools/go.mod
194
tools/go.mod
|
|
@ -1,8 +1,198 @@
|
|||
module github.com/lightninglabs/loop/tools
|
||||
|
||||
go 1.16
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.23.7
|
||||
|
||||
require (
|
||||
github.com/golangci/golangci-lint v1.54.2
|
||||
github.com/golangci/golangci-lint v1.64.6
|
||||
github.com/rinchsan/gosimports v0.1.5
|
||||
)
|
||||
|
||||
require (
|
||||
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
|
||||
4d63.com/gochecknoglobals v0.2.2 // indirect
|
||||
github.com/4meepo/tagalign v1.4.2 // indirect
|
||||
github.com/Abirdcfly/dupword v0.1.3 // indirect
|
||||
github.com/Antonboom/errname v1.0.0 // indirect
|
||||
github.com/Antonboom/nilnil v1.0.1 // indirect
|
||||
github.com/Antonboom/testifylint v1.5.2 // indirect
|
||||
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
|
||||
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
|
||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
|
||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.3.0 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
|
||||
github.com/alexkohler/prealloc v1.0.0 // indirect
|
||||
github.com/alingse/asasalint v0.0.11 // indirect
|
||||
github.com/alingse/nilnesserr v0.1.2 // indirect
|
||||
github.com/ashanbrown/forbidigo v1.6.0 // indirect
|
||||
github.com/ashanbrown/makezero v1.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bkielbasa/cyclop v1.2.3 // indirect
|
||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
||||
github.com/bombsimon/wsl/v4 v4.5.0 // indirect
|
||||
github.com/breml/bidichk v0.3.2 // indirect
|
||||
github.com/breml/errchkjson v0.4.0 // indirect
|
||||
github.com/butuzov/ireturn v0.3.1 // indirect
|
||||
github.com/butuzov/mirror v1.3.0 // indirect
|
||||
github.com/catenacyber/perfsprint v0.8.2 // indirect
|
||||
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/charithe/durationcheck v0.0.10 // indirect
|
||||
github.com/chavacava/garif v0.1.0 // indirect
|
||||
github.com/ckaznocha/intrange v0.3.0 // indirect
|
||||
github.com/curioswitch/go-reassign v0.3.0 // indirect
|
||||
github.com/daixiang0/gci v0.13.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/firefart/nonamedreturns v1.0.5 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
||||
github.com/ghostiam/protogetter v0.3.9 // indirect
|
||||
github.com/go-critic/go-critic v0.12.0 // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astequal v1.2.0 // indirect
|
||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gofrs/flock v0.12.1 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
|
||||
github.com/golangci/go-printf-func-name v0.1.0 // indirect
|
||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
||||
github.com/golangci/misspell v0.6.0 // indirect
|
||||
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
||||
github.com/golangci/revgrep v0.8.0 // indirect
|
||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/gordonklaus/ineffassign v0.1.0 // indirect
|
||||
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
|
||||
github.com/gostaticanalysis/comment v1.5.0 // indirect
|
||||
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
|
||||
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
|
||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
|
||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jgautheron/goconst v1.7.1 // indirect
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
||||
github.com/jjti/go-spancheck v0.6.4 // indirect
|
||||
github.com/julz/importas v0.2.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
|
||||
github.com/kisielk/errcheck v1.9.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
|
||||
github.com/kulti/thelper v0.6.3 // indirect
|
||||
github.com/kunwardeep/paralleltest v1.0.10 // indirect
|
||||
github.com/lasiar/canonicalheader v1.1.2 // indirect
|
||||
github.com/ldez/exptostd v0.4.2 // indirect
|
||||
github.com/ldez/gomoddirectives v0.6.1 // indirect
|
||||
github.com/ldez/grignotin v0.9.0 // indirect
|
||||
github.com/ldez/tagliatelle v0.7.1 // indirect
|
||||
github.com/ldez/usetesting v0.4.2 // indirect
|
||||
github.com/leonklingele/grouper v1.1.2 // indirect
|
||||
github.com/macabu/inamedparam v0.1.3 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/maratori/testableexamples v1.0.0 // indirect
|
||||
github.com/maratori/testpackage v1.1.1 // indirect
|
||||
github.com/matoous/godox v1.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgechev/revive v1.7.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/moricho/tparallel v0.3.2 // indirect
|
||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/polyfloyd/go-errorlint v1.7.1 // indirect
|
||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect
|
||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
|
||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
||||
github.com/raeperd/recvcheck v0.2.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/ryancurrah/gomodguard v1.3.5 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
|
||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
||||
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
|
||||
github.com/securego/gosec/v2 v2.22.1 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
||||
github.com/sivchari/tenv v1.12.1 // indirect
|
||||
github.com/sonatard/noctx v0.1.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/cobra v1.9.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/spf13/viper v1.12.0 // indirect
|
||||
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
|
||||
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
github.com/tdakkota/asciicheck v0.4.1 // indirect
|
||||
github.com/tetafro/godot v1.5.0 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect
|
||||
github.com/timonwong/loggercheck v0.10.1 // indirect
|
||||
github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
||||
github.com/ultraware/funlen v0.2.0 // indirect
|
||||
github.com/ultraware/whitespace v0.2.0 // indirect
|
||||
github.com/uudashr/gocognit v1.2.0 // indirect
|
||||
github.com/uudashr/iface v1.3.1 // indirect
|
||||
github.com/xen0n/gosmopolitan v1.2.2 // indirect
|
||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
||||
github.com/yeya24/promlinter v0.3.0 // indirect
|
||||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
||||
gitlab.com/bosi/decorder v0.4.2 // indirect
|
||||
go-simpler.org/musttag v0.13.0 // indirect
|
||||
go-simpler.org/sloglint v0.9.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/goleak v1.3.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
google.golang.org/protobuf v1.36.4 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
honnef.co/go/tools v0.6.0 // indirect
|
||||
mvdan.cc/gofumpt v0.7.0 // indirect
|
||||
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
|
||||
)
|
||||
|
|
|
|||
1260
tools/go.sum
1260
tools/go.sum
File diff suppressed because it is too large
Load diff
2
utils.go
2
utils.go
|
|
@ -386,8 +386,6 @@ func invoicesrpcSelectHopHints(amtMSat lnwire.MilliSatoshi, cfg *SelectHopHintsC
|
|||
hopHintChans := make(map[wire.OutPoint]struct{})
|
||||
hopHints := make([][]zpay32.HopHint, 0, numMaxHophints)
|
||||
for _, channel := range openChannels {
|
||||
channel := channel
|
||||
|
||||
enoughHopHints := sufficientHints(
|
||||
len(hopHints), numMaxHophints, hopHintFactor, amtMSat,
|
||||
totalHintBandwidth,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue