mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
pytest: Use the bitcoind config file to read RPC params from
With python-bitcoinlib==0.9.0 it appears that the URL based auth information is no longer used, so we fall back to reading the config file for the bitcoind daemon instead. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
047a2ea043
commit
2a7ba010c3
@@ -162,6 +162,7 @@ class TailableProc(object):
|
||||
"""
|
||||
return self.wait_for_logs([regex], timeout)
|
||||
|
||||
|
||||
class SimpleBitcoinProxy:
|
||||
"""Wrapper for BitcoinProxy to reconnect.
|
||||
|
||||
@@ -170,8 +171,8 @@ class SimpleBitcoinProxy:
|
||||
throwaway connections. This is easier than to reach into the RPC
|
||||
library to close, reopen and reauth upon failure.
|
||||
"""
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
def __init__(self, btc_conf_file, *args, **kwargs):
|
||||
self.__btc_conf_file__= btc_conf_file
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name.startswith('__') and name.endswith('__'):
|
||||
@@ -179,7 +180,9 @@ class SimpleBitcoinProxy:
|
||||
raise AttributeError
|
||||
|
||||
# Create a callable to do the actual call
|
||||
f = lambda *args: BitcoinProxy(self.url)._call(name, *args)
|
||||
proxy = BitcoinProxy(btc_conf_file=self.__btc_conf_file__)
|
||||
|
||||
f = lambda *args: proxy._call(name, *args)
|
||||
|
||||
# Make debuggers show <function bitcoin.rpc.name> rather than <function
|
||||
# bitcoin.rpc.<lambda>>
|
||||
@@ -210,10 +213,10 @@ class BitcoinD(TailableProc):
|
||||
'-nolisten',
|
||||
]
|
||||
BITCOIND_CONFIG['rpcport'] = rpcport
|
||||
btc_conf_file = os.path.join(regtestdir, 'bitcoin.conf')
|
||||
write_config(os.path.join(bitcoin_dir, 'bitcoin.conf'), BITCOIND_CONFIG)
|
||||
write_config(os.path.join(regtestdir, 'bitcoin.conf'), BITCOIND_CONFIG)
|
||||
self.rpc = SimpleBitcoinProxy(
|
||||
"http://rpcuser:rpcpass@127.0.0.1:{}".format(self.rpcport))
|
||||
write_config(btc_conf_file, BITCOIND_CONFIG)
|
||||
self.rpc = SimpleBitcoinProxy(btc_conf_file=btc_conf_file)
|
||||
|
||||
def start(self):
|
||||
TailableProc.start(self)
|
||||
|
||||
Reference in New Issue
Block a user