From f7cdf1dd989e2a03f97e791f5ec713a8785a414a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 9 Dec 2020 10:57:37 +0100 Subject: [PATCH] pytest: Debug test_lockup_drain --- contrib/pyln-testing/pyln/testing/utils.py | 7 +++++-- tests/test_pay.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index 2b88857ce..9ab4e1743 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -919,13 +919,16 @@ class LightningNode(object): # This helper sends all money to a peer until even 1 msat can't get through. def drain(self, peer): total = 0 - msat = 16**9 + msat = 4294967295 # Max payment size in some configs while msat != 0: try: + logging.debug("Drain step with size={}".format(msat)) self.pay(peer, msat) total += msat - except RpcError: + except RpcError as e: + logging.debug("Got an exception while draining channel: {}".format(e)) msat //= 2 + logging.debug("Draining complete after sending a total of {}msats".format(total)) return total # Note: this feeds through the smoother in update_feerate, so changing diff --git a/tests/test_pay.py b/tests/test_pay.py index 944266f03..4f9b81bb8 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2374,6 +2374,7 @@ def test_lockup_drain(node_factory, bitcoind): # But if feerate increase just a little more, l2 should not be able to send # non-fust HTLC to l1 l1.force_feerates(30002) # TODO: Why does 30001 fail? off by one in C code? + wait_for(lambda: l1.rpc.listpeers()['peers'][0]['connected']) with pytest.raises(RpcError, match=r".*Capacity exceeded.*"): l2.pay(l1, total // 2)