chainntnfs/test: parallelize iface tests by backend

This commit is contained in:
Conner Fromknecht 2020-12-10 20:56:10 -08:00
parent 0d57ff2432
commit ea8d02eb68
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
4 changed files with 54 additions and 5 deletions

@ -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")
}

@ -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")
}

@ -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")
}

@ -1,6 +1,6 @@
// +build dev // +build dev
package chainntnfs_test package chainntnfstest
import ( import (
"bytes" "bytes"
@ -1893,7 +1893,7 @@ var blockCatchupTests = []blockCatchupTestCase{
// import should trigger an init() method within the package which registers // import should trigger an init() method within the package which registers
// the interface. Second, an additional case in the switch within the main loop // the interface. Second, an additional case in the switch within the main loop
// below needs to be added which properly initializes the interface. // 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 // 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 // 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 // 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)) 2*len(txNtfnTests)+len(blockNtfnTests)+len(blockCatchupTests))
for _, notifierDriver := range chainntnfs.RegisteredNotifiers() { for _, notifierDriver := range chainntnfs.RegisteredNotifiers() {
notifierType := notifierDriver.NotifierType
if notifierType != targetBackEnd {
continue
}
// Initialize a height hint cache for each notifier. // Initialize a height hint cache for each notifier.
tempDir, err := ioutil.TempDir("", "channeldb") tempDir, err := ioutil.TempDir("", "channeldb")
if err != nil { if err != nil {
@ -1926,9 +1931,8 @@ func TestInterfaces(t *testing.T) {
} }
var ( var (
cleanUp func() cleanUp func()
newNotifier func() (chainntnfs.TestChainNotifier, error) newNotifier func() (chainntnfs.TestChainNotifier, error)
notifierType = notifierDriver.NotifierType
) )
switch notifierType { switch notifierType {