Skip to content

Commit ce5b4bd

Browse files
rustyrussellcdecker
authored andcommitted
tests: fix to work with bitcoind master branch.
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]>
1 parent 91d62ad commit ce5b4bd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"regtest": 1,
1616
"rpcuser": "rpcuser",
1717
"rpcpassword": "rpcpass",
18-
"rpcport": 18332,
1918
}
2019

2120

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

4241

43-
def write_config(filename, opts):
42+
def write_config(filename, opts, regtest_opts=None):
4443
with open(filename, 'w') as f:
4544
for k, v in opts.items():
4645
f.write("{}={}\n".format(k, v))
46+
if regtest_opts:
47+
f.write("[regtest]\n")
48+
for k, v in regtest_opts.items():
49+
f.write("{}={}\n".format(k, v))
4750

4851

4952
class TailableProc(object):
@@ -240,9 +243,13 @@ def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=None):
240243
'-logtimestamps',
241244
'-nolisten',
242245
]
246+
# For up to and including 0.16.1, this needs to be in main section.
243247
BITCOIND_CONFIG['rpcport'] = rpcport
248+
# For after 0.16.1 (eg. 3f398d7a17f136cd4a67998406ca41a124ae2966), this
249+
# needs its own [regtest] section.
250+
BITCOIND_REGTEST = {'rpcport': rpcport}
244251
btc_conf_file = os.path.join(bitcoin_dir, 'bitcoin.conf')
245-
write_config(btc_conf_file, BITCOIND_CONFIG)
252+
write_config(btc_conf_file, BITCOIND_CONFIG, BITCOIND_REGTEST)
246253
self.rpc = SimpleBitcoinProxy(btc_conf_file=btc_conf_file)
247254

248255
def start(self):

0 commit comments

Comments
 (0)