From bdda62e1a44ce4be0cc6a3ec9507d21cef291b91 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 24 Jun 2022 12:42:45 +0200 Subject: [PATCH] pytest: Add test for mixed zeroreserve funding Tests that we can have zeroreserve nodes accept and open new channels with non-zeroreserve nodes, without throwing errors --- tests/test_opening.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/test_opening.py b/tests/test_opening.py index ebc41f4c2..987151517 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -1807,4 +1807,35 @@ def test_zeroreserve(node_factory, bitcoind): # dropped below dust again. c = l2.rpc.close(l1.info['id']) decoded = bitcoind.rpc.decoderawtransaction(c['tx']) - assert len(decoded['vout']) == 1 + # Elements has a change output always + assert len(decoded['vout']) == 1 if TEST_NETWORK == 'regtest' else 2 + + +def test_zeroreserve_mixed(node_factory, bitcoind): + """l1 runs with zeroreserve, l2 and l3 without, should still work + + Basically tests that l1 doesn't get upset when l2 allows us to + drop below dust. + + """ + plugin_path = Path(__file__).parent / "plugins" / "zeroreserve.py" + opts = [ + { + 'plugin': str(plugin_path), + 'reserve': '0sat', + 'dev-allowdustreserve': True, + }, { + 'dev-allowdustreserve': False, + }, { + 'dev-allowdustreserve': False, + } + ] + l1, l2, l3 = node_factory.get_nodes(3, opts=opts) + l1.fundwallet(10**7) + l3.fundwallet(10**7) + + l1.connect(l2) + l3.connect(l1) + + l1.rpc.fundchannel(l2.info['id'], 10**6, reserve='0sat') + l3.rpc.fundchannel(l1.info['id'], 10**6)