mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pytest: Test that upon reconnect the channel gets re-enabled
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
aeeb0b7011
commit
4d8ad4e17d
@ -253,6 +253,20 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
decoded2=bitcoind.rpc.decoderawtransaction(tx)
|
decoded2=bitcoind.rpc.decoderawtransaction(tx)
|
||||||
raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2))
|
raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2))
|
||||||
|
|
||||||
|
def line_graph(self, n=2):
|
||||||
|
"""Build a line graph of the specified length and fund it.
|
||||||
|
"""
|
||||||
|
nodes = [self.node_factory.get_node() for _ in range(n)]
|
||||||
|
|
||||||
|
for i in range(len(nodes)-1):
|
||||||
|
nodes[i].rpc.connect(
|
||||||
|
nodes[i+1].info['id'],
|
||||||
|
'localhost:{}'.format(nodes[i+1].info['port'])
|
||||||
|
)
|
||||||
|
self.fund_channel(nodes[i], nodes[i+1], 10**6)
|
||||||
|
|
||||||
|
return nodes
|
||||||
|
|
||||||
def pay(self, lsrc, ldst, amt, label=None, async=False):
|
def pay(self, lsrc, ldst, amt, label=None, async=False):
|
||||||
if not label:
|
if not label:
|
||||||
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
||||||
@ -2181,5 +2195,25 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
|
|
||||||
self.assertRaises(ValueError, l2.rpc.waitanyinvoice, 'doesntexist')
|
self.assertRaises(ValueError, l2.rpc.waitanyinvoice, 'doesntexist')
|
||||||
|
|
||||||
|
|
||||||
|
def test_channel_reenable(self):
|
||||||
|
l1, l2 = self.line_graph(n=2)
|
||||||
|
|
||||||
|
l1.bitcoin.rpc.generate(6)
|
||||||
|
l1.daemon.wait_for_log('Received node_announcement for node {}'.format(l2.info['id']))
|
||||||
|
l2.daemon.wait_for_log('Received node_announcement for node {}'.format(l1.info['id']))
|
||||||
|
|
||||||
|
# Both directions should be active before the restart
|
||||||
|
assert [c['active'] for c in l1.rpc.getchannels()['channels']] == [True, True]
|
||||||
|
|
||||||
|
# Restart l2, will cause l1 to reconnect
|
||||||
|
l2.stop()
|
||||||
|
l2.daemon.start()
|
||||||
|
|
||||||
|
# Now they should sync and re-establish again
|
||||||
|
l1.daemon.wait_for_log('Received node_announcement for node {}'.format(l2.info['id']))
|
||||||
|
l2.daemon.wait_for_log('Received node_announcement for node {}'.format(l1.info['id']))
|
||||||
|
assert [c['active'] for c in l1.rpc.getchannels()['channels']] == [True, True]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(verbosity=2)
|
unittest.main(verbosity=2)
|
||||||
|
Loading…
Reference in New Issue
Block a user