diff --git a/chainntnfs/test/bitcoind/bitcoind_test.go b/chainntnfs/test/bitcoind/bitcoind_test.go new file mode 100644 index 00000000..df9d3853 --- /dev/null +++ b/chainntnfs/test/bitcoind/bitcoind_test.go @@ -0,0 +1,15 @@ +// +build dev + +package bitcoind_test + +import ( + "testing" + + chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" +) + +// TestInterfaces executes the generic notifier test suite against a bitcoind +// powered chain notifier. +func TestInterfaces(t *testing.T) { + chainntnfstest.TestInterfaces(t, "bitcoind") +} diff --git a/chainntnfs/test/btcd/btcd_test.go b/chainntnfs/test/btcd/btcd_test.go new file mode 100644 index 00000000..320d6d8a --- /dev/null +++ b/chainntnfs/test/btcd/btcd_test.go @@ -0,0 +1,15 @@ +// +build dev + +package btcd_test + +import ( + "testing" + + chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" +) + +// TestInterfaces executes the generic notifier test suite against a btcd +// powered chain notifier. +func TestInterfaces(t *testing.T) { + chainntnfstest.TestInterfaces(t, "btcd") +} diff --git a/chainntnfs/test/neutrino/neutrino_test.go b/chainntnfs/test/neutrino/neutrino_test.go new file mode 100644 index 00000000..ac6a09cf --- /dev/null +++ b/chainntnfs/test/neutrino/neutrino_test.go @@ -0,0 +1,15 @@ +// +build dev + +package neutrino_test + +import ( + "testing" + + chainntnfstest "github.com/lightningnetwork/lnd/chainntnfs/test" +) + +// TestInterfaces executes the generic notifier test suite against a neutrino +// powered chain notifier. +func TestInterfaces(t *testing.T) { + chainntnfstest.TestInterfaces(t, "neutrino") +} diff --git a/chainntnfs/interface_test.go b/chainntnfs/test/test_interface.go similarity index 99% rename from chainntnfs/interface_test.go rename to chainntnfs/test/test_interface.go index 70c4432e..c38ac65e 100644 --- a/chainntnfs/interface_test.go +++ b/chainntnfs/test/test_interface.go @@ -1,6 +1,6 @@ // +build dev -package chainntnfs_test +package chainntnfstest import ( "bytes" @@ -1893,7 +1893,7 @@ var blockCatchupTests = []blockCatchupTestCase{ // import should trigger an init() method within the package which registers // the interface. Second, an additional case in the switch within the main loop // below needs to be added which properly initializes the interface. -func TestInterfaces(t *testing.T) { +func TestInterfaces(t *testing.T, targetBackEnd string) { // Initialize the harness around a btcd node which will serve as our // dedicated miner to generate blocks, cause re-orgs, etc. We'll set up // this node with a chain length of 125, so we have plenty of BTC to @@ -1908,6 +1908,11 @@ func TestInterfaces(t *testing.T) { 2*len(txNtfnTests)+len(blockNtfnTests)+len(blockCatchupTests)) for _, notifierDriver := range chainntnfs.RegisteredNotifiers() { + notifierType := notifierDriver.NotifierType + if notifierType != targetBackEnd { + continue + } + // Initialize a height hint cache for each notifier. tempDir, err := ioutil.TempDir("", "channeldb") if err != nil { @@ -1926,9 +1931,8 @@ func TestInterfaces(t *testing.T) { } var ( - cleanUp func() - newNotifier func() (chainntnfs.TestChainNotifier, error) - notifierType = notifierDriver.NotifierType + cleanUp func() + newNotifier func() (chainntnfs.TestChainNotifier, error) ) switch notifierType {