lnwallet/btcwallet: add compile time check for BlockChainIO interface

This commit is contained in:
Johan T. Halseth 2018-08-24 15:30:23 +02:00
parent c4415f0400
commit beb5d14ed9
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
4 changed files with 9 additions and 1 deletions

@ -124,6 +124,8 @@ func (b *mockArbitratorLog) WipeHistory() error {
type mockChainIO struct{}
var _ lnwallet.BlockChainIO = (*mockChainIO)(nil)
func (*mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
return nil, 0, nil
}

@ -67,8 +67,9 @@ type BtcWallet struct {
}
// A compile time check to ensure that BtcWallet implements the
// WalletController interface.
// WalletController and BlockChainIO interfaces.
var _ lnwallet.WalletController = (*BtcWallet)(nil)
var _ lnwallet.BlockChainIO = (*BtcWallet)(nil)
// New returns a new fully initialized instance of BtcWallet given a valid
// configuration struct.

@ -205,6 +205,8 @@ type mockChainIO struct {
bestHeight int32
}
var _ lnwallet.BlockChainIO = (*mockChainIO)(nil)
func (m *mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
return activeNetParams.GenesisHash, m.bestHeight, nil
}

@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet"
)
var (
@ -237,6 +238,8 @@ func (m *MockNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
type mockChainIO struct{}
var _ lnwallet.BlockChainIO = (*mockChainIO)(nil)
func (m *mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
return nil, mockChainIOHeight, nil
}