Browse Source

pytest: Check that we disable on closing and permfail.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
dafd000c2a
  1. 17
      tests/test_lightningd.py
  2. 5
      tests/utils.py

17
tests/test_lightningd.py

@ -848,6 +848,15 @@ class LightningDTests(BaseLightningDTests):
assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 0
l1.bitcoin.rpc.generate(5)
# Only wait for the channels to activate with DEVELOPER=1,
# otherwise it's going to take too long because of the missing
# --dev-broadcast-interval
if DEVELOPER:
wait_for(lambda: len(l1.getactivechannels()) == 2)
wait_for(lambda: len(l2.getactivechannels()) == 2)
# This should return, then close.
l1.rpc.close(l2.info['id'])
l1.daemon.wait_for_log('-> CHANNELD_SHUTTING_DOWN')
@ -860,6 +869,10 @@ class LightningDTests(BaseLightningDTests):
l1.daemon.wait_for_log('sendrawtx exit 0')
l2.daemon.wait_for_log('sendrawtx exit 0')
# Both nodes should have disabled the channel in their view
wait_for(lambda: len(l1.getactivechannels()) == 0)
wait_for(lambda: len(l2.getactivechannels()) == 0)
assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1
# Now grab the close transaction
@ -1180,6 +1193,9 @@ class LightningDTests(BaseLightningDTests):
# Now, this will get stuck due to l1 commit being disabled..
t = self.pay(l1,l2,100000000,async=True)
assert len(l1.getactivechannels()) == 1
assert len(l2.getactivechannels()) == 1
# They should both have commitments blocked now.
l1.daemon.wait_for_log('=WIRE_COMMITMENT_SIGNED-nocommit')
l2.daemon.wait_for_log('=WIRE_COMMITMENT_SIGNED-nocommit')
@ -1210,6 +1226,7 @@ class LightningDTests(BaseLightningDTests):
l2.daemon.wait_for_log('-> ONCHAIND_CHEATED')
# FIXME: l1 should try to stumble along!
wait_for(lambda: len(l2.getactivechannels()) == 0)
# l2 should spend all of the outputs (except to-us).
# Could happen in any order, depending on commitment tx.

5
tests/utils.py

@ -90,7 +90,7 @@ class TailableProc(object):
self.proc.kill()
self.proc.wait()
self.thread.join()
def tail(self):
"""Tail the stdout of the process and remember it.
@ -334,6 +334,9 @@ class LightningNode(object):
self.bitcoin.generate_block(6)
self.daemon.wait_for_log('-> CHANNELD_NORMAL|STATE_NORMAL')
def getactivechannels(self):
return [c for c in self.rpc.listchannels()['channels'] if c['active']]
def db_query(self, query):
db = sqlite3.connect(os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3"))
db.row_factory = sqlite3.Row

Loading…
Cancel
Save