Skip to content

Commit

Permalink
Merge pull request #7508 from positiveblue/fix-linter
Browse files Browse the repository at this point in the history
multi: make linter happy
  • Loading branch information
guggero authored Mar 13, 2023
2 parents 75ee557 + 4a0a155 commit fe24f19
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (

// AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec.
AppPreRelease = "beta.rc2"
AppPreRelease = "beta.rc3"
)

func init() {
Expand Down
4 changes: 3 additions & 1 deletion config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ type walletReBroadcaster struct {
}

// newWalletReBroadcaster creates a new instance of the walletReBroadcaster.
func newWalletReBroadcaster(broadcaster *pushtx.Broadcaster) *walletReBroadcaster {
func newWalletReBroadcaster(
broadcaster *pushtx.Broadcaster) *walletReBroadcaster {

return &walletReBroadcaster{
Broadcaster: broadcaster,
}
Expand Down
2 changes: 1 addition & 1 deletion lnutils/chan.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// 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) {
select {
case m := <-c:
Expand Down
37 changes: 26 additions & 11 deletions lnwallet/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
)

var (
CoinPkScript, _ = hex.DecodeString("001431df1bde03c074d0cf21ea2529427e1499b8f1de")
CoinPkScript, _ = hex.DecodeString(
"001431df1bde03c074d0cf21ea2529427e1499b8f1de",
)
)

// mockWalletController is a mock implementation of the WalletController
Expand Down Expand Up @@ -50,6 +52,7 @@ func (w *mockWalletController) FetchInputInfo(
Confirmations: 1,
OutPoint: *prevOut,
}

return utxo, nil
}

Expand All @@ -74,8 +77,10 @@ func (w *mockWalletController) NewAddress(AddressType, bool,
string) (btcutil.Address, error) {

addr, _ := btcutil.NewAddressPubKey(
w.RootKey.PubKey().SerializeCompressed(), &chaincfg.MainNetParams,
w.RootKey.PubKey().SerializeCompressed(),
&chaincfg.MainNetParams,
)

return addr, nil
}

Expand Down Expand Up @@ -176,6 +181,7 @@ func (w *mockWalletController) ListUnspentWitness(int32, int32,
atomic.AddUint32(&w.index, 1)
var ret []*Utxo
ret = append(ret, utxo)

return ret, nil
}

Expand All @@ -200,19 +206,21 @@ func (w *mockWalletController) LeaseOutput(wtxmgr.LockID, wire.OutPoint,
}

// ReleaseOutput currently does nothing.
func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID, wire.OutPoint) error {
func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID,
wire.OutPoint) error {

return nil
}

func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult,
func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult, //nolint:lll
error) {

return nil, nil
}

// FundPsbt currently does nothing.
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32, chainfee.SatPerKWeight,
string, *waddrmgr.KeyScope) (int32, error) {
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32,
chainfee.SatPerKWeight, string, *waddrmgr.KeyScope) (int32, error) {

return 0, nil
}
Expand All @@ -228,7 +236,9 @@ func (w *mockWalletController) FinalizePsbt(_ *psbt.Packet, _ string) error {
}

// 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
return nil
}
Expand Down Expand Up @@ -286,7 +296,8 @@ type mockChainNotifier struct {
// that the tx confirmation will go over.
func (c *mockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
pkScript []byte, numConfs, heightHint uint32,
opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent,
error) {

return &chainntnfs.ConfirmationEvent{
Confirmed: c.ConfChan,
Expand All @@ -307,8 +318,9 @@ func (c *mockChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,

// RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that
// block epochs will go over.
func (c *mockChainNotifier) RegisterBlockEpochNtfn(blockEpoch *chainntnfs.BlockEpoch) (
*chainntnfs.BlockEpochEvent, error) {
func (c *mockChainNotifier) RegisterBlockEpochNtfn(
blockEpoch *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent,
error) {

return &chainntnfs.BlockEpochEvent{
Epochs: c.EpochChan,
Expand Down Expand Up @@ -339,13 +351,16 @@ func (*mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {

func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {

return nil, nil
}

func (*mockChainIO) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
return nil, nil
}

func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock,
error) {

return nil, nil
}
17 changes: 10 additions & 7 deletions lnwallet/rebroadcaster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"

"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -132,7 +131,7 @@ func TestWalletRebroadcaster(t *testing.T) {
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
// broadcaster.
testCfg := *cfg
Expand All @@ -148,7 +147,8 @@ func TestWalletRebroadcaster(t *testing.T) {
t, wallet, rebroadcaster, walletController,
)

wallet.Shutdown()
err = wallet.Shutdown()
require.NoError(t, err)

// If we make a new wallet, that has the broadcaster, but
// hasn't started yet, we should see the same behavior.
Expand All @@ -162,15 +162,19 @@ func TestWalletRebroadcaster(t *testing.T) {
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)
require.NoError(t, err)
require.NoError(t, wallet.Startup())

defer wallet.Shutdown()
defer func() {
err = wallet.Shutdown()
require.NoError(t, err)
}()

// Wait for the broadcaster to start.
_, err = lnutils.RecvOrTimeout(
Expand All @@ -192,6 +196,5 @@ func TestWalletRebroadcaster(t *testing.T) {
rebroadcaster.confSignal, time.Second,
)
require.NoError(t, err)

})
}
3 changes: 2 additions & 1 deletion lnwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ func (l *LightningWallet) PublishTransaction(tx *wire.MsgTx,
const numConfs = 6

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 {
return
Expand Down

0 comments on commit fe24f19

Please sign in to comment.