mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
test_addfunds_from_block: fix test flakiness.
If you run locally, it fails occasionally; presumably because it sees previous funds. Use a random HSM key for that teste. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
02411b04e4
commit
70cebb8653
@ -91,7 +91,7 @@ class NodeFactory(object):
|
||||
self.executor = executor
|
||||
self.bitcoind = bitcoind
|
||||
|
||||
def get_node(self, disconnect=None, options=None, may_fail=False):
|
||||
def get_node(self, disconnect=None, options=None, may_fail=False, random_hsm=False):
|
||||
node_id = self.next_id
|
||||
self.next_id += 1
|
||||
|
||||
@ -100,7 +100,7 @@ class NodeFactory(object):
|
||||
|
||||
socket_path = os.path.join(lightning_dir, "lightning-rpc").format(node_id)
|
||||
port = 16330+node_id
|
||||
daemon = utils.LightningD(lightning_dir, self.bitcoind.bitcoin_dir, port=port)
|
||||
daemon = utils.LightningD(lightning_dir, self.bitcoind.bitcoin_dir, port=port, random_hsm=random_hsm)
|
||||
# If we have a disconnect string, dump it to a file for daemon.
|
||||
if disconnect:
|
||||
with open(os.path.join(lightning_dir, "dev_disconnect"), "w") as f:
|
||||
@ -2097,7 +2097,9 @@ class LightningDTests(BaseLightningDTests):
|
||||
def test_addfunds_from_block(self):
|
||||
"""Send funds to the daemon without telling it explicitly
|
||||
"""
|
||||
l1 = self.node_factory.get_node()
|
||||
# Previous runs with same bitcoind can leave funds!
|
||||
l1 = self.node_factory.get_node(random_hsm=True)
|
||||
|
||||
addr = l1.rpc.newaddr()['address']
|
||||
txid = l1.bitcoin.rpc.sendtoaddress(addr, 0.1)
|
||||
l1.bitcoin.rpc.generate(1)
|
||||
|
@ -231,7 +231,7 @@ class BitcoinD(TailableProc):
|
||||
# lightning-5 => 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e aka SOMBERFIRE #032cf1
|
||||
|
||||
class LightningD(TailableProc):
|
||||
def __init__(self, lightning_dir, bitcoin_dir, port=9735):
|
||||
def __init__(self, lightning_dir, bitcoin_dir, port=9735, random_hsm=False):
|
||||
TailableProc.__init__(self, lightning_dir)
|
||||
self.lightning_dir = lightning_dir
|
||||
self.port = port
|
||||
@ -246,8 +246,9 @@ class LightningD(TailableProc):
|
||||
'--network=regtest'
|
||||
]
|
||||
if DEVELOPER:
|
||||
self.cmd_line += ['--dev-broadcast-interval=1000',
|
||||
'--dev-hsm-seed={}'.format(seed.hex())]
|
||||
self.cmd_line += ['--dev-broadcast-interval=1000']
|
||||
if not random_hsm:
|
||||
self.cmd_line += ['--dev-hsm-seed={}'.format(seed.hex())]
|
||||
self.cmd_line += ["--{}={}".format(k, v) for k, v in LIGHTNINGD_CONFIG.items()]
|
||||
self.prefix = 'lightningd(%d)' % (port)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user