From beb5d14ed99cd61e634abde12b8e4a04a8f42cd8 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 24 Aug 2018 15:30:23 +0200 Subject: [PATCH] lnwallet/btcwallet: add compile time check for BlockChainIO interface --- contractcourt/channel_arbitrator_test.go | 2 ++ lnwallet/btcwallet/btcwallet.go | 3 ++- mock.go | 2 ++ sweep/test_utils.go | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index 758fd4cd..e829754f 100644 --- a/contractcourt/channel_arbitrator_test.go +++ b/contractcourt/channel_arbitrator_test.go @@ -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 } diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index f0cc4049..22baf110 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -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. diff --git a/mock.go b/mock.go index 10e077c5..00292c8b 100644 --- a/mock.go +++ b/mock.go @@ -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 } diff --git a/sweep/test_utils.go b/sweep/test_utils.go index bf71d602..0362741a 100644 --- a/sweep/test_utils.go +++ b/sweep/test_utils.go @@ -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 }