pytest: Allow switching chaind depending on a config option

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-04-10 23:37:15 +02:00 committed by Rusty Russell
parent 13ba5b3d20
commit 9025a3cd39
3 changed files with 13 additions and 3 deletions

2
configure vendored
View File

@ -112,6 +112,7 @@ set_defaults()
COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEVELOPER")} COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEVELOPER")}
CONFIGURATOR_CC=${CONFIGURATOR_CC-$CC} CONFIGURATOR_CC=${CONFIGURATOR_CC-$CC}
VALGRIND=${VALGRIND:-$(default_valgrind_setting)} VALGRIND=${VALGRIND:-$(default_valgrind_setting)}
TEST_NETWORK=${TEST_NETWORK:-regtest}
} }
usage() usage()
@ -352,6 +353,7 @@ add_var COMPAT "$COMPAT" $CONFIG_HEADER
add_var PYTEST "$PYTEST" add_var PYTEST "$PYTEST"
add_var STATIC "$STATIC" add_var STATIC "$STATIC"
add_var ASAN "$ASAN" add_var ASAN "$ASAN"
add_var TEST_NETWORK "$TEST_NETWORK"
# Hack to avoid sha256 name clash with libwally: will be fixed when that # Hack to avoid sha256 name clash with libwally: will be fixed when that
# becomes a standalone shared lib. # becomes a standalone shared lib.

View File

@ -1,6 +1,6 @@
from concurrent import futures from concurrent import futures
from db import SqliteDbProvider, PostgresDbProvider from db import SqliteDbProvider, PostgresDbProvider
from utils import NodeFactory, BitcoinD from utils import NodeFactory, BitcoinD, ElementsD
import logging import logging
import os import os
@ -74,9 +74,17 @@ def test_name(request):
yield request.function.__name__ yield request.function.__name__
network_daemons = {
'regtest': BitcoinD,
'liquid-regtest': ElementsD,
}
@pytest.fixture @pytest.fixture
def bitcoind(directory, teardown_checks): def bitcoind(directory, teardown_checks):
bitcoind = BitcoinD(bitcoin_dir=directory) chaind = network_daemons[config.get('TEST_NETWORK', 'regtest')]
bitcoind = chaind(bitcoin_dir=directory)
try: try:
bitcoind.start() bitcoind.start()
except Exception: except Exception:

View File

@ -440,7 +440,7 @@ class LightningD(TailableProc):
'lightning-dir': lightning_dir, 'lightning-dir': lightning_dir,
'addr': '127.0.0.1:{}'.format(port), 'addr': '127.0.0.1:{}'.format(port),
'allow-deprecated-apis': 'false', 'allow-deprecated-apis': 'false',
'network': 'regtest', 'network': config.get('TEST_NETWORK', 'regtest'),
'ignore-fee-limits': 'false', 'ignore-fee-limits': 'false',
'bitcoin-rpcuser': BITCOIND_CONFIG['rpcuser'], 'bitcoin-rpcuser': BITCOIND_CONFIG['rpcuser'],
'bitcoin-rpcpassword': BITCOIND_CONFIG['rpcpassword'], 'bitcoin-rpcpassword': BITCOIND_CONFIG['rpcpassword'],