multi: fix newly detected linter issues

This commit is contained in:
Oliver Gugger 2022-02-07 13:58:25 +01:00
parent 369627901f
commit ffee7d1bcf
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
30 changed files with 106 additions and 118 deletions

View File

@ -419,7 +419,7 @@ func testBlockEpochNotification(miner *rpctest.Harness,
// hash.
blockEpoch := <-epochClient.Epochs
if blockEpoch.BlockHeader == nil {
fmt.Println(i)
t.Logf("%d", i)
clientErrors <- fmt.Errorf("block " +
"header is nil")
return

View File

@ -22,77 +22,77 @@ const (
// fieldMismatchError returns a merge error for a named field when we get two
// channel acceptor responses which have different values set.
func fieldMismatchError(name string, current, new interface{}) error {
func fieldMismatchError(name string, current, newValue interface{}) error {
return fmt.Errorf("multiple values set for: %v, %v and %v",
name, current, new)
name, current, newValue)
}
// mergeInt64 merges two int64 values, failing if they have different non-zero
// values.
func mergeInt64(name string, current, new int64) (int64, error) {
func mergeInt64(name string, current, newValue int64) (int64, error) {
switch {
case current == 0:
return new, nil
return newValue, nil
case new == 0:
case newValue == 0:
return current, nil
case current != new:
return 0, fieldMismatchError(name, current, new)
case current != newValue:
return 0, fieldMismatchError(name, current, newValue)
default:
return new, nil
return newValue, nil
}
}
// mergeMillisatoshi merges two msat values, failing if they have different
// non-zero values.
func mergeMillisatoshi(name string, current,
new lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error) {
newValue lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error) {
switch {
case current == 0:
return new, nil
return newValue, nil
case new == 0:
case newValue == 0:
return current, nil
case current != new:
return 0, fieldMismatchError(name, current, new)
case current != newValue:
return 0, fieldMismatchError(name, current, newValue)
default:
return new, nil
return newValue, nil
}
}
// mergeDeliveryAddress merges two delivery address values, failing if they have
// different non-zero values.
func mergeDeliveryAddress(name string, current,
new lnwire.DeliveryAddress) (lnwire.DeliveryAddress, error) {
newValue lnwire.DeliveryAddress) (lnwire.DeliveryAddress, error) {
switch {
case current == nil:
return new, nil
return newValue, nil
case new == nil:
case newValue == nil:
return current, nil
case !bytes.Equal(current, new):
return nil, fieldMismatchError(name, current, new)
case !bytes.Equal(current, newValue):
return nil, fieldMismatchError(name, current, newValue)
default:
return new, nil
return newValue, nil
}
}
// mergeResponse takes two channel accept responses, and attempts to merge their
// fields, failing if any fields conflict (are non-zero and not equal). It
// returns a new response that has all the merged fields in it.
func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
error) {
func mergeResponse(current,
newValue ChannelAcceptResponse) (ChannelAcceptResponse, error) {
csv, err := mergeInt64(
fieldCSV, int64(current.CSVDelay), int64(new.CSVDelay),
fieldCSV, int64(current.CSVDelay), int64(newValue.CSVDelay),
)
if err != nil {
return current, err
@ -101,7 +101,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
htlcLimit, err := mergeInt64(
fieldHtlcLimit, int64(current.HtlcLimit),
int64(new.HtlcLimit),
int64(newValue.HtlcLimit),
)
if err != nil {
return current, err
@ -110,7 +110,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
minDepth, err := mergeInt64(
fieldMinDep, int64(current.MinAcceptDepth),
int64(new.MinAcceptDepth),
int64(newValue.MinAcceptDepth),
)
if err != nil {
return current, err
@ -118,7 +118,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
current.MinAcceptDepth = uint16(minDepth)
reserve, err := mergeInt64(
fieldReserve, int64(current.Reserve), int64(new.Reserve),
fieldReserve, int64(current.Reserve), int64(newValue.Reserve),
)
if err != nil {
return current, err
@ -126,7 +126,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
current.Reserve = btcutil.Amount(reserve)
current.MinHtlcIn, err = mergeMillisatoshi(
fieldMinIn, current.MinHtlcIn, new.MinHtlcIn,
fieldMinIn, current.MinHtlcIn, newValue.MinHtlcIn,
)
if err != nil {
return current, err
@ -134,7 +134,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
current.InFlightTotal, err = mergeMillisatoshi(
fieldInFlightTotal, current.InFlightTotal,
new.InFlightTotal,
newValue.InFlightTotal,
)
if err != nil {
return current, err
@ -142,7 +142,7 @@ func mergeResponse(current, new ChannelAcceptResponse) (ChannelAcceptResponse,
current.UpfrontShutdown, err = mergeDeliveryAddress(
fieldUpfrontShutdown, current.UpfrontShutdown,
new.UpfrontShutdown,
newValue.UpfrontShutdown,
)
if err != nil {
return current, err

View File

@ -495,7 +495,7 @@ func TestPaymentControlDeleteNonInFligt(t *testing.T) {
var s, i int
for _, p := range dbPayments {
fmt.Println("fetch payment has status", p.Status)
t.Log("fetch payment has status", p.Status)
switch p.Status {
case StatusSucceeded:
s++

View File

@ -389,7 +389,6 @@ func sendPayment(ctx *cli.Context) error {
if err != nil {
return err
}
args = args.Tail()
req.FinalCltvDelta = int32(delta)
}
@ -1288,7 +1287,6 @@ func forwardingHistory(ctx *cli.Context) error {
return fmt.Errorf("unable to decode max_events: %v", err)
}
maxEvents = uint32(m)
args = args.Tail()
}
req := &lnrpc.ForwardingHistoryRequest{

View File

@ -806,7 +806,7 @@ func askRecoveryWindow() (int32, error) {
return defaultRecoveryWindow, nil
}
lookAhead, err := strconv.Atoi(answer)
lookAhead, err := strconv.ParseInt(answer, 10, 32)
if err != nil {
fmt.Printf("Unable to parse recovery window: %v\n", err)
continue

View File

@ -29,7 +29,7 @@ type profileEntry struct {
LndDir string `json:"lnddir"`
Chain string `json:"chain"`
Network string `json:"network"`
NoMacaroons bool `json:"no-macaroons,omitempty"`
NoMacaroons bool `json:"no-macaroons,omitempty"` // nolint:tagliatelle
TLSCert string `json:"tlscert"`
Macaroons *macaroonJar `json:"macaroons"`
}

View File

@ -1908,7 +1908,7 @@ func extractBitcoindRPCParams(networkName string,
dataDir = string(dataDirSubmatches[1])
}
chainDir := ""
var chainDir string
switch networkName {
case "mainnet":
chainDir = ""

View File

@ -487,8 +487,8 @@ func (c *commitSweepResolver) report() *ContractReport {
c.reportLock.Lock()
defer c.reportLock.Unlock()
copy := c.currentReport
return &copy
cpy := c.currentReport
return &cpy
}
// initReport initializes the pending channels report for this resolver.

View File

@ -515,8 +515,8 @@ func (h *htlcSuccessResolver) report() *ContractReport {
h.reportLock.Lock()
defer h.reportLock.Unlock()
copy := h.currentReport
return &copy
cpy := h.currentReport
return &cpy
}
func (h *htlcSuccessResolver) initReport() {

View File

@ -529,7 +529,7 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
case h.htlcResolution.SignedTimeoutTx != nil:
log.Infof("%T(%v): waiting for nursery/sweeper to spend CSV "+
"delayed output", h, claimOutpoint)
sweep, err := waitForSpend(
sweepTx, err := waitForSpend(
&claimOutpoint,
h.htlcResolution.SweepSignDesc.Output.PkScript,
h.broadcastHeight, h.Notifier, h.quit,
@ -539,7 +539,7 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
}
// Update the spend txid to the hash of the sweep transaction.
spendTxID = sweep.SpenderTxHash
spendTxID = sweepTx.SpenderTxHash
// Once our sweep of the timeout tx has confirmed, we add a
// resolution for our timeoutTx tx first stage transaction.
@ -603,8 +603,8 @@ func (h *htlcTimeoutResolver) report() *ContractReport {
h.reportLock.Lock()
defer h.reportLock.Unlock()
copy := h.currentReport
return &copy
cpy := h.currentReport
return &cpy
}
func (h *htlcTimeoutResolver) initReport() {

View File

@ -1218,7 +1218,7 @@ func TestHtlcTimeoutSecondStageSweeperRemoteSpend(t *testing.T) {
// expect the resolver to re-subscribe to a
// spend, hence we must resend it.
if resumed {
fmt.Println("resumed")
t.Logf("resumed")
ctx.notifier.SpendChan <- &chainntnfs.SpendDetail{
SpendingTx: spendTx,
SpenderTxHash: &spendTxHash,

View File

@ -1058,18 +1058,18 @@ func (ns *NurseryStore) createHeightBucket(tx kvdb.RwTx,
// store, using the provided block height. If the bucket does not exist, or any
// bucket along its path does not exist, a nil value is returned.
func (ns *NurseryStore) getHeightBucketPath(tx kvdb.RTx,
height uint32) (kvdb.RBucket, kvdb.RBucket, kvdb.RBucket) {
height uint32) (kvdb.RBucket, kvdb.RBucket) {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadBucket(ns.pfxChainKey)
if chainBucket == nil {
return nil, nil, nil
return nil, nil
}
// Retrieve the existing channel index.
hghtIndex := chainBucket.NestedReadBucket(heightIndexKey)
if hghtIndex == nil {
return nil, nil, nil
return nil, nil
}
// Serialize the provided block height and return the bucket matching
@ -1077,25 +1077,25 @@ func (ns *NurseryStore) getHeightBucketPath(tx kvdb.RTx,
var heightBytes [4]byte
byteOrder.PutUint32(heightBytes[:], height)
return chainBucket, hghtIndex, hghtIndex.NestedReadBucket(heightBytes[:])
return chainBucket, hghtIndex.NestedReadBucket(heightBytes[:])
}
// getHeightBucketPathWrite retrieves an existing height bucket from the nursery
// store, using the provided block height. If the bucket does not exist, or any
// bucket along its path does not exist, a nil value is returned.
func (ns *NurseryStore) getHeightBucketPathWrite(tx kvdb.RwTx,
height uint32) (kvdb.RwBucket, kvdb.RwBucket, kvdb.RwBucket) {
height uint32) (kvdb.RwBucket, kvdb.RwBucket) {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadWriteBucket(ns.pfxChainKey)
if chainBucket == nil {
return nil, nil, nil
return nil, nil
}
// Retrieve the existing channel index.
hghtIndex := chainBucket.NestedReadWriteBucket(heightIndexKey)
if hghtIndex == nil {
return nil, nil, nil
return nil, nil
}
// Serialize the provided block height and return the bucket matching
@ -1103,7 +1103,7 @@ func (ns *NurseryStore) getHeightBucketPathWrite(tx kvdb.RwTx,
var heightBytes [4]byte
byteOrder.PutUint32(heightBytes[:], height)
return chainBucket, hghtIndex, hghtIndex.NestedReadWriteBucket(
return hghtIndex, hghtIndex.NestedReadWriteBucket(
heightBytes[:],
)
}
@ -1113,7 +1113,8 @@ func (ns *NurseryStore) getHeightBucketPathWrite(tx kvdb.RwTx,
// along its path does not exist, a nil value is returned.
func (ns *NurseryStore) getHeightBucket(tx kvdb.RTx,
height uint32) kvdb.RBucket {
_, _, hghtBucket := ns.getHeightBucketPath(tx, height)
_, hghtBucket := ns.getHeightBucketPath(tx, height)
return hghtBucket
}
@ -1124,7 +1125,7 @@ func (ns *NurseryStore) getHeightBucket(tx kvdb.RTx,
func (ns *NurseryStore) getHeightBucketWrite(tx kvdb.RwTx,
height uint32) kvdb.RwBucket {
_, _, hghtBucket := ns.getHeightBucketPathWrite(tx, height)
_, hghtBucket := ns.getHeightBucketPathWrite(tx, height)
return hghtBucket
}
@ -1190,7 +1191,7 @@ func (ns *NurseryStore) forEachHeightPrefix(tx kvdb.RTx, prefix []byte,
// Start by retrieving the height bucket corresponding to the provided
// block height.
chainBucket, _, hghtBucket := ns.getHeightBucketPath(tx, height)
chainBucket, hghtBucket := ns.getHeightBucketPath(tx, height)
if hghtBucket == nil {
return nil
}
@ -1345,7 +1346,7 @@ func (ns *NurseryStore) removeOutputFromHeight(tx kvdb.RwTx, height uint32,
// this invocation successfully pruned the height bucket.
func (ns *NurseryStore) pruneHeight(tx kvdb.RwTx, height uint32) (bool, error) {
// Fetch the existing height index and height bucket.
_, hghtIndex, hghtBucket := ns.getHeightBucketPathWrite(tx, height)
hghtIndex, hghtBucket := ns.getHeightBucketPathWrite(tx, height)
if hghtBucket == nil {
return false, nil
}

View File

@ -1130,7 +1130,7 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
// this htlc. The reason for randomization is to evenly
// distribute the htlc load without making assumptions about
// what the best channel is.
destination := destinations[rand.Intn(len(destinations))]
destination := destinations[rand.Intn(len(destinations))] // nolint:gosec
// Retrieve the incoming link by its ShortChannelID. Note that
// the incomingChanID is never set to hop.Source here.

View File

@ -2909,7 +2909,7 @@ func testHtcNotifier(t *testing.T, testOpts []serverOption, iterations int,
// Add the htlcNotifier option to any other options
// set in the test.
options := append(testOpts, notifierOption)
options := append(testOpts, notifierOption) // nolint:gocritic
n := newThreeHopNetwork(
t, channels.aliceToBob,

View File

@ -58,11 +58,11 @@ func assertEngineExecution(t *testing.T, testNum int, valid bool,
done, err = vm.Step()
if err != nil && valid {
fmt.Println(debugBuf.String())
t.Log(debugBuf.String())
t.Fatalf("spend test case #%v failed, spend "+
"should be valid: %v", testNum, err)
} else if err == nil && !valid && done {
fmt.Println(debugBuf.String())
t.Log(debugBuf.String())
t.Fatalf("spend test case #%v succeed, spend "+
"should be invalid: %v", testNum, err)
}
@ -79,7 +79,7 @@ func assertEngineExecution(t *testing.T, testNum int, valid bool,
validity = "valid"
}
fmt.Println(debugBuf.String())
t.Log(debugBuf.String())
t.Fatalf("%v spend test case #%v execution ended with: %v", validity, testNum, vmErr)
}

View File

@ -23,11 +23,11 @@ type WtClient struct {
func (c *WtClient) Validate() error {
// TODO(wilmer): remove in v0.9.0 release.
if len(c.PrivateTowerURIs) > 0 {
fmt.Println("The `wtclient.private-tower-uris` option has " +
"been deprecated as of v0.8.0-beta and will be " +
return fmt.Errorf("the `wtclient.private-tower-uris` option " +
"has been deprecated as of v0.8.0-beta and will be " +
"removed in v0.9.0-beta. To setup watchtowers for " +
"the client, set `wtclient.active` and run " +
"`lncli wtclient -h` for more information.")
"`lncli wtclient -h` for more information")
}
return nil

View File

@ -7,6 +7,7 @@ import (
"io"
"net/http"
"sync"
"testing"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)
@ -22,6 +23,8 @@ const (
type feeService struct {
feeEstimates
t *testing.T
srv *http.Server
wg sync.WaitGroup
@ -36,9 +39,10 @@ type feeEstimates struct {
}
// startFeeService spins up a go-routine to serve fee estimates.
func startFeeService() *feeService {
func startFeeService(t *testing.T) *feeService {
port := NextAvailablePort()
f := feeService{
t: t,
url: fmt.Sprintf("http://localhost:%v/fee-estimates.json", port),
}
@ -59,7 +63,7 @@ func startFeeService() *feeService {
defer f.wg.Done()
if err := f.srv.ListenAndServe(); err != http.ErrServerClosed {
fmt.Printf("error: cannot start fee api: %v", err)
f.t.Errorf("error: cannot start fee api: %v", err)
}
}()
@ -73,23 +77,21 @@ func (f *feeService) handleRequest(w http.ResponseWriter, r *http.Request) {
bytes, err := json.Marshal(f.feeEstimates)
if err != nil {
fmt.Printf("error: cannot serialize "+
"estimates: %v", err)
f.t.Errorf("error: cannot serialize estimates: %v", err)
return
}
_, err = io.WriteString(w, string(bytes))
if err != nil {
fmt.Printf("error: cannot send estimates: %v",
err)
f.t.Errorf("error: cannot send estimates: %v", err)
}
}
// stop stops the web server.
func (f *feeService) stop() {
if err := f.srv.Shutdown(context.Background()); err != nil {
fmt.Printf("error: cannot stop fee api: %v", err)
f.t.Errorf("error: cannot stop fee api: %v", err)
}
f.wg.Wait()

View File

@ -11,7 +11,7 @@ import (
// TestFeeService tests the itest fee estimating web service.
func TestFeeService(t *testing.T) {
service := startFeeService()
service := startFeeService(t)
defer service.stop()
service.setFee(5000)

View File

@ -96,8 +96,6 @@ type NetworkHarness struct {
func NewNetworkHarness(m *HarnessMiner, b BackendConfig, lndBinary string,
dbBackend DatabaseBackend) (*NetworkHarness, error) {
feeService := startFeeService()
ctxt, cancel := context.WithCancel(context.Background())
n := NetworkHarness{
@ -107,7 +105,6 @@ func NewNetworkHarness(m *HarnessMiner, b BackendConfig, lndBinary string,
netParams: m.ActiveNet,
Miner: m,
BackendCfg: b,
feeService: feeService,
runCtx: ctxt,
cancel: cancel,
lndBinary: lndBinary,
@ -150,6 +147,7 @@ func (n *NetworkHarness) SetUp(t *testing.T,
fakeLogger := grpclog.NewLoggerV2(io.Discard, io.Discard, io.Discard)
grpclog.SetLoggerV2(fakeLogger)
n.currentTestCase = testCase
n.feeService = startFeeService(t)
// Start the initial seeder nodes within the test network, then connect
// their respective RPC clients.

View File

@ -228,7 +228,7 @@ func (cfg *BaseNodeConfig) GenArgs() []string {
fmt.Sprintf("--invoicemacaroonpath=%v", cfg.InvoiceMacPath),
fmt.Sprintf("--trickledelay=%v", trickleDelay),
fmt.Sprintf("--profile=%d", cfg.ProfilePort),
fmt.Sprintf("--caches.rpc-graph-cache-duration=0"),
fmt.Sprintf("--caches.rpc-graph-cache-duration=%d", 0),
}
args = append(args, nodeArgs...)
@ -988,9 +988,9 @@ func (hn *HarnessNode) FetchNodeInfo() error {
return nil
}
// AddToLog adds a line of choice to the node's logfile. This is useful
// AddToLogf adds a line of choice to the node's logfile. This is useful
// to interleave test output with output from the node.
func (hn *HarnessNode) AddToLog(format string, a ...interface{}) {
func (hn *HarnessNode) AddToLogf(format string, a ...interface{}) {
// If this node was not set up with a log file, just return early.
if hn.logFile == nil {
return
@ -998,7 +998,7 @@ func (hn *HarnessNode) AddToLog(format string, a ...interface{}) {
desc := fmt.Sprintf("itest: %s\n", fmt.Sprintf(format, a...))
if _, err := hn.logFile.WriteString(desc); err != nil {
hn.PrintErr("write to log err: %v", err)
hn.PrintErrf("write to log err: %v", err)
}
}
@ -1281,7 +1281,7 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
err := hn.receiveTopologyClientStream(graphUpdates)
if err != nil {
hn.PrintErr("receive topology client stream "+
hn.PrintErrf("receive topology client stream "+
"got err:%v", err)
}
}()
@ -1505,9 +1505,9 @@ func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount,
return nil
}
// PrintErr prints an error to the console.
func (hn *HarnessNode) PrintErr(format string, a ...interface{}) {
fmt.Printf("itest error from [node:%s]: %s\n",
// PrintErrf prints an error to the console.
func (hn *HarnessNode) PrintErrf(format string, a ...interface{}) {
fmt.Printf("itest error from [node:%s]: %s\n", // nolint:forbidigo
hn.Cfg.Name, fmt.Sprintf(format, a...))
}
@ -1521,7 +1521,7 @@ func (hn *HarnessNode) handleChannelEdgeUpdates(
for _, newChan := range updates {
op, err := MakeOutpoint(newChan.ChanPoint)
if err != nil {
hn.PrintErr("failed to create outpoint for %v "+
hn.PrintErrf("failed to create outpoint for %v "+
"got err: %v", newChan.ChanPoint, err)
return
}
@ -1607,7 +1607,7 @@ func (hn *HarnessNode) handleClosedChannelUpdate(
for _, closedChan := range updates {
op, err := MakeOutpoint(closedChan.ChanPoint)
if err != nil {
hn.PrintErr("failed to create outpoint for %v "+
hn.PrintErrf("failed to create outpoint for %v "+
"got err: %v", closedChan.ChanPoint, err)
return
}
@ -1775,7 +1775,7 @@ func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
IncludeUnannounced: include,
})
if err != nil {
hn.PrintErr("DescribeGraph got err: %v", err)
hn.PrintErrf("DescribeGraph got err: %v", err)
return nil
}
@ -1813,7 +1813,7 @@ func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
func renameFile(fromFileName, toFileName string) {
err := os.Rename(fromFileName, toFileName)
if err != nil {
fmt.Printf("could not rename %s to %s: %v\n",
fmt.Printf("could not rename %s to %s: %v\n", // nolint:forbidigo
fromFileName, toFileName, err)
}
}

View File

@ -1626,9 +1626,7 @@ func getSpendingTxInMempool(t *harnessTest, miner *rpcclient.Client,
for _, txIn := range msgTx.TxIn {
input := txIn.PreviousOutPoint
if _, ok := inputSet[input]; ok {
delete(inputSet, input)
}
delete(inputSet, input)
}
if len(inputSet) > 0 {

View File

@ -69,6 +69,9 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
ctxb := context.Background()
tmpDir, err := ioutil.TempDir("", "etcd")
if err != nil {
ht.Fatalf("Failed to create temp dir: %v", err)
}
etcdCfg, cleanup, err := kvdb.StartEtcdTestBackend(
tmpDir, uint16(lntest.NextAvailablePort()),
uint16(lntest.NextAvailablePort()), "",
@ -100,6 +103,9 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
info1, err := carol1.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil {
ht.Fatalf("unable to get info: %v", err)
}
net.ConnectNodes(ht.t, carol1, net.Alice)
@ -172,6 +178,9 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
// Make sure Carol-1 and Carol-2 have the same identity.
info2, err := carol2.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil {
ht.Fatalf("unable to get info: %v", err)
}
if info1.IdentityPubkey != info2.IdentityPubkey {
ht.Fatalf("Carol-1 and Carol-2 must have the same identity: "+
"%v vs %v", info1.IdentityPubkey, info2.IdentityPubkey)

View File

@ -139,7 +139,7 @@ test:
"---- basic channel funding subtest %s ----\n",
testName,
)
net.Alice.AddToLog(logLine)
net.Alice.AddToLogf(logLine)
success := t.t.Run(testName, func(t *testing.T) {
testFunding(cc, dc)

View File

@ -99,7 +99,7 @@ func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
"%s/%s ----\n",
testName, subTest.name,
)
net.Alice.AddToLog(logLine)
net.Alice.AddToLogf(logLine)
success := ht.t.Run(subTest.name, func(t *testing.T) {
ht := newHarnessTest(t, net)

View File

@ -232,8 +232,8 @@ func TestLightningNetworkDaemon(t *testing.T) {
testCase.name,
)
lndHarness.Alice.AddToLog(logLine)
lndHarness.Bob.AddToLog(logLine)
lndHarness.Alice.AddToLogf(logLine)
lndHarness.Bob.AddToLogf(logLine)
// Start every test with the default static fee estimate.
lndHarness.SetFeeEstimate(12500)

View File

@ -18,7 +18,6 @@ import (
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet"
base "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/btcsuite/btcwallet/wallet/txrules"
@ -200,7 +199,7 @@ func LoaderWithExternalWalletDB(db kvdb.Backend) LoaderOption {
// NewWalletLoader constructs a wallet loader.
func NewWalletLoader(chainParams *chaincfg.Params, recoveryWindow uint32,
opts ...LoaderOption) (*wallet.Loader, error) {
opts ...LoaderOption) (*base.Loader, error) {
cfg := &loaderCfg{}

View File

@ -657,7 +657,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
if err != nil {
return nil, err
}
cltvs = append(cltvs, htlc.Timeout)
cltvs = append(cltvs, htlc.Timeout) // nolint:makezero
}
for _, htlc := range filteredHTLCView.theirUpdates {
if HtlcIsDust(
@ -674,7 +674,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
if err != nil {
return nil, err
}
cltvs = append(cltvs, htlc.Timeout)
cltvs = append(cltvs, htlc.Timeout) // nolint:makezero
}
// Set the state hint of the commitment transaction to facilitate

3
log.go
View File

@ -39,7 +39,6 @@ import (
"github.com/lightningnetwork/lnd/peer"
"github.com/lightningnetwork/lnd/peernotifier"
"github.com/lightningnetwork/lnd/routing"
"github.com/lightningnetwork/lnd/routing/localchans"
"github.com/lightningnetwork/lnd/rpcperms"
"github.com/lightningnetwork/lnd/signal"
"github.com/lightningnetwork/lnd/sweep"
@ -156,7 +155,7 @@ func SetupLoggers(root *build.RotatingLogWriter, interceptor signal.Interceptor)
AddSubLogger(root, "PEER", interceptor, peer.UseLogger)
AddSubLogger(root, "CHCL", interceptor, chancloser.UseLogger)
AddSubLogger(root, routing.Subsystem, interceptor, routing.UseLogger, localchans.UseLogger)
AddSubLogger(root, routing.Subsystem, interceptor, routing.UseLogger)
AddSubLogger(root, routerrpc.Subsystem, interceptor, routerrpc.UseLogger)
AddSubLogger(root, chanfitness.Subsystem, interceptor, chanfitness.UseLogger)
AddSubLogger(root, verrpc.Subsystem, interceptor, verrpc.UseLogger)

View File

@ -1,16 +0,0 @@
package localchans
import (
"github.com/btcsuite/btclog"
)
// log is a logger that is initialized with no output filters. This
// means the package will not perform any logging by default until the caller
// requests it.
var log btclog.Logger
// UseLogger uses a specified Logger to output package logging info. This
// function is called from the parent package htlcswitch logger initialization.
func UseLogger(logger btclog.Logger) {
log = logger
}

View File

@ -185,7 +185,7 @@ func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint,
// Retrieve negotiated channel htlc amt limits.
amtMin, amtMax, err := r.getHtlcAmtLimits(tx, chanPoint)
if err != nil {
return nil
return err
}
// We now update the edge max htlc value.