Closed SimonVrouwe closed 4 years ago
Excellent find @SimonVrouwe, I had not considered this before. I found that
setting the $HOME
environment variable will stop bitcoin-cli
from
accessing the user config, instead only relying on command line options and
configs that we create as part of the tests.
I haven't tested it using strace
like you did, but causing a parser error in
bitcoin-cli
via an invalid config syntax had the same effect 😉
edit: please ignore below, I forgot to give CL the bitcoin-datadir
option, sorry
@darosior ~It looks like bitcoin-cli
is called without -datadir
option in~:
https://github.com/ElementsProject/lightning/blob/f637b88932d97ad640ba336b230052d2cd7749ba/plugins/bcli.c#L835-L839
~because bitcoind->datadir
is still null.~
~and then bitcoin-cli
tries to find the (default) $HOME/.bitcoin/bitcoin.conf
~
@cdecker Ok I was half right about the -bitcoin-datadir
option. That CL option is not set by default in (most of) the pytests, for example via a node_factory.get_node()
.
Adding the option manually, i.e.:
l1 = node_factory.get_node(options={'bitcoin-datadir': bitcoind.bitcoin_dir})
prevents bitcoin-cli
looking in $HOME/.bitcoin
for bitcoin.conf
(checked with strace
)
Maybe as an extra precaution the bitcoin-datadir
should be set by default in the pytests?
But I guess setting $HOME to an empty folder has the same effect.
Good point, I'll add the option in pyln-testing
. Belts and suspenders :+1:
Issue and Steps to Reproduce
Running
make full-check
on locally build rc2 10f47b41fa withBitcoin Core version v0.19.1
on keeps failing ontest_closing
(and probably other tests also). Changing test parameters like (SLOW_MACHINE=1, TIMEOUT=360 etc.), didn't solve it.But renaming my
~/.bitcoin/bitcoin.conf
file makes the test pass!When running the individual test with:
DEVELOPER=1 PYTHONPATH=contrib/pylightning:contrib/pyln-client:contrib/pyln-testing:contrib/pyln-proto py.test -v -s tests/test_closing.py::test_closing
with an ipdb break point just above https://github.com/ElementsProject/lightning/blob/10f47b41fa3192638442ef04d816380950cc32c9/tests/test_closing.py#L19 to get the PIDThen running
strace
to monitor file access to~/.bitcoin/bitcoin.conf
:strace -e trace=/stat -q -P /home/simon/.bitcoin/ -f -y -k -p 8471
(8471 is PID of above pytest) and hit continue from breakpoint, shows two calls:stat("/home/simon/.bitcoin"
,see:Besides failing the test, it doesn't sound good that the test looks for local
bitcoin.conf
with can contain password etc. Maybebitcoin-cli
is called somewhere without the-conf=<file>
option?A
stat
system call doesn't really read the file content, but failure/success of the test appears (checked manually) to depend on the presence of optionrpcconnect
in thebitcoin.conf
Will investigate further, perhaps I just messed up my setup, but thought I post this here already.
BTW here is the failing test log:
and after renaming
~/.bitcoin/bitcoin.conf
the test passes: