Skip to content

Commit

Permalink
tests: fix to work with bitcoind master branch.
Browse files Browse the repository at this point in the history
E               ConnectionRefusedError: [Errno 111] Connection refused

And in debug.log:

2018-05-17T04:06:35Z Warning: Config setting for -rpcport only applied on regtest network when in [regtest] section.

Unfortunately, current versions including 0.16.1 *ignore* the contents of
a '[regtest]' section, so we need it in *both* places.

Also remove the misleading 'rpcport' initialization which we always
override.

Note that we don't fix this message though:

	2018-05-17T04:06:35Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Jun 21, 2018
1 parent 91d62ad commit ce5b4bd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"regtest": 1,
"rpcuser": "rpcuser",
"rpcpassword": "rpcpass",
"rpcport": 18332,
}


Expand All @@ -40,10 +39,14 @@ def wait_for(success, timeout=TIMEOUT, interval=0.1):
raise ValueError("Error waiting for {}", success)


def write_config(filename, opts):
def write_config(filename, opts, regtest_opts=None):
with open(filename, 'w') as f:
for k, v in opts.items():
f.write("{}={}\n".format(k, v))
if regtest_opts:
f.write("[regtest]\n")
for k, v in regtest_opts.items():
f.write("{}={}\n".format(k, v))


class TailableProc(object):
Expand Down Expand Up @@ -240,9 +243,13 @@ def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=None):
'-logtimestamps',
'-nolisten',
]
# For up to and including 0.16.1, this needs to be in main section.
BITCOIND_CONFIG['rpcport'] = rpcport
# For after 0.16.1 (eg. 3f398d7a17f136cd4a67998406ca41a124ae2966), this
# needs its own [regtest] section.
BITCOIND_REGTEST = {'rpcport': rpcport}
btc_conf_file = os.path.join(bitcoin_dir, 'bitcoin.conf')
write_config(btc_conf_file, BITCOIND_CONFIG)
write_config(btc_conf_file, BITCOIND_CONFIG, BITCOIND_REGTEST)
self.rpc = SimpleBitcoinProxy(btc_conf_file=btc_conf_file)

def start(self):
Expand Down

0 comments on commit ce5b4bd

Please sign in to comment.