pyln: Allow users to override the LightningNode class

Quite a few of the things in the LightningNode class are tailored to their use
in the c-lightning tests, so I decided to split those customizations out into
a sub-class, and adding one more fixture that just serves the class. This
allows us to override the LightningNode implementation in our own tests, while
still having sane defaults for other users.
This commit is contained in:
Christian Decker
2019-10-30 11:50:16 +01:00
parent bc9b1c405e
commit 9378be72a9
3 changed files with 29 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
from concurrent import futures
from pyln.testing.db import SqliteDbProvider, PostgresDbProvider
from pyln.testing.utils import NodeFactory, BitcoinD, ElementsD, env, DEVELOPER
from pyln.testing.utils import NodeFactory, BitcoinD, ElementsD, env, DEVELOPER, LightningNode
import logging
import os
@@ -67,6 +67,11 @@ network_daemons = {
}
@pytest.fixture
def node_cls():
return LightningNode
@pytest.fixture
def bitcoind(directory, teardown_checks):
chaind = network_daemons[env('TEST_NETWORK', 'regtest')]
@@ -145,13 +150,14 @@ def teardown_checks(request):
@pytest.fixture
def node_factory(request, directory, test_name, bitcoind, executor, db_provider, teardown_checks):
def node_factory(request, directory, test_name, bitcoind, executor, db_provider, teardown_checks, node_cls):
nf = NodeFactory(
test_name,
bitcoind,
executor,
directory=directory,
db_provider=db_provider,
node_cls=node_cls
)
yield nf