Merge pull request #7508 from positiveblue/fix-linter

multi: make linter happy
This commit is contained in:
Oliver Gugger 2023-03-13 10:04:26 +01:00 committed by GitHub
commit fe24f195b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 22 deletions

View File

@ -47,7 +47,7 @@ const (
// AppPreRelease MUST only contain characters from semanticAlphabet // AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec. // per the semantic versioning spec.
AppPreRelease = "beta.rc2" AppPreRelease = "beta.rc3"
) )
func init() { func init() {

View File

@ -652,7 +652,9 @@ type walletReBroadcaster struct {
} }
// newWalletReBroadcaster creates a new instance of the walletReBroadcaster. // newWalletReBroadcaster creates a new instance of the walletReBroadcaster.
func newWalletReBroadcaster(broadcaster *pushtx.Broadcaster) *walletReBroadcaster { func newWalletReBroadcaster(
broadcaster *pushtx.Broadcaster) *walletReBroadcaster {
return &walletReBroadcaster{ return &walletReBroadcaster{
Broadcaster: broadcaster, Broadcaster: broadcaster,
} }

View File

@ -6,7 +6,7 @@ import (
) )
// RecvOrTimeout attempts to recv over chan c, returning the value. If the // RecvOrTimeout attempts to recv over chan c, returning the value. If the
// timeout passes before the recv succeeds, an error is returned // timeout passes before the recv succeeds, an error is returned.
func RecvOrTimeout[T any](c <-chan T, timeout time.Duration) (*T, error) { func RecvOrTimeout[T any](c <-chan T, timeout time.Duration) (*T, error) {
select { select {
case m := <-c: case m := <-c:

View File

@ -21,7 +21,9 @@ import (
) )
var ( var (
CoinPkScript, _ = hex.DecodeString("001431df1bde03c074d0cf21ea2529427e1499b8f1de") CoinPkScript, _ = hex.DecodeString(
"001431df1bde03c074d0cf21ea2529427e1499b8f1de",
)
) )
// mockWalletController is a mock implementation of the WalletController // mockWalletController is a mock implementation of the WalletController
@ -50,6 +52,7 @@ func (w *mockWalletController) FetchInputInfo(
Confirmations: 1, Confirmations: 1,
OutPoint: *prevOut, OutPoint: *prevOut,
} }
return utxo, nil return utxo, nil
} }
@ -74,8 +77,10 @@ func (w *mockWalletController) NewAddress(AddressType, bool,
string) (btcutil.Address, error) { string) (btcutil.Address, error) {
addr, _ := btcutil.NewAddressPubKey( addr, _ := btcutil.NewAddressPubKey(
w.RootKey.PubKey().SerializeCompressed(), &chaincfg.MainNetParams, w.RootKey.PubKey().SerializeCompressed(),
&chaincfg.MainNetParams,
) )
return addr, nil return addr, nil
} }
@ -176,6 +181,7 @@ func (w *mockWalletController) ListUnspentWitness(int32, int32,
atomic.AddUint32(&w.index, 1) atomic.AddUint32(&w.index, 1)
var ret []*Utxo var ret []*Utxo
ret = append(ret, utxo) ret = append(ret, utxo)
return ret, nil return ret, nil
} }
@ -200,19 +206,21 @@ func (w *mockWalletController) LeaseOutput(wtxmgr.LockID, wire.OutPoint,
} }
// ReleaseOutput currently does nothing. // ReleaseOutput currently does nothing.
func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID, wire.OutPoint) error { func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID,
wire.OutPoint) error {
return nil return nil
} }
func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult, func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult, //nolint:lll
error) { error) {
return nil, nil return nil, nil
} }
// FundPsbt currently does nothing. // FundPsbt currently does nothing.
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32, chainfee.SatPerKWeight, func (w *mockWalletController) FundPsbt(*psbt.Packet, int32,
string, *waddrmgr.KeyScope) (int32, error) { chainfee.SatPerKWeight, string, *waddrmgr.KeyScope) (int32, error) {
return 0, nil return 0, nil
} }
@ -228,7 +236,9 @@ func (w *mockWalletController) FinalizePsbt(_ *psbt.Packet, _ string) error {
} }
// PublishTransaction sends a transaction to the PublishedTransactions chan. // PublishTransaction sends a transaction to the PublishedTransactions chan.
func (w *mockWalletController) PublishTransaction(tx *wire.MsgTx, _ string) error { func (w *mockWalletController) PublishTransaction(tx *wire.MsgTx,
_ string) error {
w.PublishedTransactions <- tx w.PublishedTransactions <- tx
return nil return nil
} }
@ -286,7 +296,8 @@ type mockChainNotifier struct {
// that the tx confirmation will go over. // that the tx confirmation will go over.
func (c *mockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, func (c *mockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
pkScript []byte, numConfs, heightHint uint32, pkScript []byte, numConfs, heightHint uint32,
opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) { opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent,
error) {
return &chainntnfs.ConfirmationEvent{ return &chainntnfs.ConfirmationEvent{
Confirmed: c.ConfChan, Confirmed: c.ConfChan,
@ -307,8 +318,9 @@ func (c *mockChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
// RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that // RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that
// block epochs will go over. // block epochs will go over.
func (c *mockChainNotifier) RegisterBlockEpochNtfn(blockEpoch *chainntnfs.BlockEpoch) ( func (c *mockChainNotifier) RegisterBlockEpochNtfn(
*chainntnfs.BlockEpochEvent, error) { blockEpoch *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent,
error) {
return &chainntnfs.BlockEpochEvent{ return &chainntnfs.BlockEpochEvent{
Epochs: c.EpochChan, Epochs: c.EpochChan,
@ -339,6 +351,7 @@ func (*mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte, func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) { heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {
return nil, nil return nil, nil
} }
@ -346,6 +359,8 @@ func (*mockChainIO) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
return nil, nil return nil, nil
} }
func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) { func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock,
error) {
return nil, nil return nil, nil
} }

View File

@ -7,7 +7,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -132,7 +131,7 @@ func TestWalletRebroadcaster(t *testing.T) {
ChainIO: chainIO, ChainIO: chainIO,
} }
t.Run("rebroadcast bypass", func(t *testing.T) { t.Run("rebroadcast bypass", func(t *testing.T) { //nolint:paralleltest
// We'll make a copy of the config, but without the // We'll make a copy of the config, but without the
// broadcaster. // broadcaster.
testCfg := *cfg testCfg := *cfg
@ -148,7 +147,8 @@ func TestWalletRebroadcaster(t *testing.T) {
t, wallet, rebroadcaster, walletController, t, wallet, rebroadcaster, walletController,
) )
wallet.Shutdown() err = wallet.Shutdown()
require.NoError(t, err)
// If we make a new wallet, that has the broadcaster, but // If we make a new wallet, that has the broadcaster, but
// hasn't started yet, we should see the same behavior. // hasn't started yet, we should see the same behavior.
@ -162,15 +162,19 @@ func TestWalletRebroadcaster(t *testing.T) {
t, wallet, rebroadcaster, walletController, t, wallet, rebroadcaster, walletController,
) )
wallet.Shutdown() err = wallet.Shutdown()
require.NoError(t, err)
}) })
t.Run("rebroadcast normal", func(t *testing.T) { t.Run("rebroadcast normal", func(t *testing.T) { //nolint:paralleltest
wallet, err := NewLightningWallet(*cfg) wallet, err := NewLightningWallet(*cfg)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, wallet.Startup()) require.NoError(t, wallet.Startup())
defer wallet.Shutdown() defer func() {
err = wallet.Shutdown()
require.NoError(t, err)
}()
// Wait for the broadcaster to start. // Wait for the broadcaster to start.
_, err = lnutils.RecvOrTimeout( _, err = lnutils.RecvOrTimeout(
@ -192,6 +196,5 @@ func TestWalletRebroadcaster(t *testing.T) {
rebroadcaster.confSignal, time.Second, rebroadcaster.confSignal, time.Second,
) )
require.NoError(t, err) require.NoError(t, err)
}) })
} }

View File

@ -482,7 +482,8 @@ func (l *LightningWallet) PublishTransaction(tx *wire.MsgTx,
const numConfs = 6 const numConfs = 6
txConf, err := l.Cfg.Notifier.RegisterConfirmationsNtfn( txConf, err := l.Cfg.Notifier.RegisterConfirmationsNtfn(
&txHash, tx.TxOut[0].PkScript, numConfs, uint32(bestHeight), &txHash, tx.TxOut[0].PkScript, numConfs,
uint32(bestHeight),
) )
if err != nil { if err != nil {
return return