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

View File

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

View File

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