mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
tests: add marker for v1/v2 channel opens
Tests that will only run when !EXPERIMENTAL_DUAL_FUND: @pytest.marker.openchannel('v1') def test_...() Tests that will only run when EXPERIMENTAL_DUAL_FUND: @pytest.marker.openchannel('v2') def test_...()
This commit is contained in:
parent
d0bbf07655
commit
3a2d602922
@ -665,6 +665,8 @@ class LightningNode(object):
|
||||
self.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1"
|
||||
if not may_reconnect:
|
||||
self.daemon.opts["dev-no-reconnect"] = None
|
||||
if EXPERIMENTAL_DUAL_FUND:
|
||||
self.daemon.opts["experimental-dual-fund"] = None
|
||||
|
||||
if options is not None:
|
||||
self.daemon.opts.update(options)
|
||||
@ -736,6 +738,10 @@ class LightningNode(object):
|
||||
# expected to contribute that same amount
|
||||
chan_capacity = total_capacity // 2
|
||||
total_capacity = chan_capacity * 2
|
||||
# Tell the node to equally dual-fund the channel
|
||||
remote_node.rpc.call('funderupdate', {'policy': 'match',
|
||||
'policy_mod': 100,
|
||||
'fuzz_percent': 0})
|
||||
else:
|
||||
chan_capacity = total_capacity
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from pyln.testing.utils import DEVELOPER
|
||||
from pyln.testing.utils import DEVELOPER, EXPERIMENTAL_DUAL_FUND
|
||||
|
||||
|
||||
# This function is based upon the example of how to
|
||||
@ -25,9 +25,21 @@ def pytest_configure(config):
|
||||
"slow_test: slow tests aren't run under Valgrind")
|
||||
config.addinivalue_line("markers",
|
||||
"developer: only run when developer is flagged on")
|
||||
config.addinivalue_line("markers",
|
||||
"openchannel: Limit this test to only run 'v1' or 'v2' openchannel protocol")
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
open_versions = [mark.args[0] for mark in item.iter_markers(name='openchannel')]
|
||||
if open_versions:
|
||||
if 'v1' not in open_versions and not EXPERIMENTAL_DUAL_FUND:
|
||||
pytest.skip('v2-only test, EXPERIMENTAL_DUAL_FUND=0')
|
||||
if 'v2' not in open_versions and EXPERIMENTAL_DUAL_FUND:
|
||||
pytest.skip('v1-only test, EXPERIMENTAL_DUAL_FUND=1')
|
||||
else: # If there's no openchannel marker, skip if EXP_DF
|
||||
if EXPERIMENTAL_DUAL_FUND:
|
||||
pytest.skip('v1-only test, EXPERIMENTAL_DUAL_FUND=1')
|
||||
|
||||
for mark in item.iter_markers(name='developer'):
|
||||
if not DEVELOPER:
|
||||
if len(mark.args):
|
||||
|
@ -341,6 +341,7 @@ def test_disconnect_fundee(node_factory):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_disconnect_fundee_v2(node_factory):
|
||||
# Now error on fundee side during channel open, with them funding
|
||||
disconnects = ['-WIRE_ACCEPT_CHANNEL2',
|
||||
@ -356,12 +357,11 @@ def test_disconnect_fundee_v2(node_factory):
|
||||
'@WIRE_TX_COMPLETE',
|
||||
'+WIRE_TX_COMPLETE']
|
||||
|
||||
l1 = node_factory.get_node(options={'experimental-dual-fund': None})
|
||||
l1 = node_factory.get_node()
|
||||
l2 = node_factory.get_node(disconnect=disconnects,
|
||||
options={'funder-policy': 'match',
|
||||
'funder-policy-mod': 100,
|
||||
'funder-fuzz-percent': 0,
|
||||
'experimental-dual-fund': None})
|
||||
'funder-fuzz-percent': 0})
|
||||
|
||||
l1.fundwallet(2000000)
|
||||
l2.fundwallet(2000000)
|
||||
@ -952,10 +952,9 @@ def test_funding_toolarge(node_factory, bitcoind):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_v2_open(node_factory, bitcoind, chainparams):
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None},
|
||||
{'experimental-dual-fund': None}])
|
||||
l1, l2 = node_factory.get_nodes(2)
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -1399,6 +1398,7 @@ def test_funding_external_wallet(node_factory, bitcoind):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v1') # We manually turn on dual-funding for select nodes
|
||||
def test_multifunding_v1_v2_mixed(node_factory, bitcoind):
|
||||
'''
|
||||
Simple test for multifundchannel, using v1 + v2
|
||||
@ -1439,21 +1439,20 @@ def test_multifunding_v1_v2_mixed(node_factory, bitcoind):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_multifunding_v2_exclusive(node_factory, bitcoind):
|
||||
'''
|
||||
Simple test for multifundchannel, using v2
|
||||
'''
|
||||
# Two of three will reply with inputs of their own
|
||||
options = [{'experimental-dual-fund': None},
|
||||
options = [{},
|
||||
{'funder-policy': 'match',
|
||||
'funder-policy-mod': 100,
|
||||
'funder-fuzz-percent': 0,
|
||||
'experimental-dual-fund': None},
|
||||
'funder-fuzz-percent': 0},
|
||||
{'funder-policy': 'match',
|
||||
'funder-policy-mod': 100,
|
||||
'funder-fuzz-percent': 0,
|
||||
'experimental-dual-fund': None},
|
||||
{'experimental-dual-fund': None}]
|
||||
'funder-fuzz-percent': 0},
|
||||
{}]
|
||||
l1, l2, l3, l4 = node_factory.get_nodes(4, opts=options)
|
||||
|
||||
l1.fundwallet(2000000)
|
||||
@ -2812,13 +2811,13 @@ def test_fail_unconfirmed(node_factory, bitcoind, executor):
|
||||
|
||||
@pytest.mark.developer("need dev-disconnect")
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_fail_unconfirmed_openchannel2(node_factory, bitcoind, executor):
|
||||
"""Test that if we crash with an unconfirmed connection to a known
|
||||
peer, we don't have a dangling peer in db"""
|
||||
# = is a NOOP disconnect, but sets up file.
|
||||
l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2'],
|
||||
options={'experimental-dual-fund': None})
|
||||
l2 = node_factory.get_node(options={'experimental-dual-fund': None})
|
||||
l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2'])
|
||||
l2 = node_factory.get_node()
|
||||
|
||||
# First one, we close by mutual agreement.
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
|
@ -17,6 +17,7 @@ def find_next_feerate(node, peer):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v1') # Mixed v1 + v2, v2 manually turned on
|
||||
def test_multifunding_v2_best_effort(node_factory, bitcoind):
|
||||
'''
|
||||
Check that best_effort flag works.
|
||||
@ -101,16 +102,15 @@ def test_multifunding_v2_best_effort(node_factory, bitcoind):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_v2_open_sigs_restart(node_factory, bitcoind):
|
||||
disconnects_1 = ['-WIRE_TX_SIGNATURES']
|
||||
disconnects_2 = ['+WIRE_TX_SIGNATURES']
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects_1,
|
||||
opts=[{'disconnect': disconnects_1,
|
||||
'may_reconnect': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects_2,
|
||||
{'disconnect': disconnects_2,
|
||||
'may_reconnect': True}])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
@ -147,6 +147,7 @@ def test_v2_open_sigs_restart(node_factory, bitcoind):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
|
||||
# Same thing as above, except the transaction mines
|
||||
# while we're asleep
|
||||
@ -154,12 +155,10 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
|
||||
disconnects_2 = ['+WIRE_TX_SIGNATURES']
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects_1,
|
||||
opts=[{'disconnect': disconnects_1,
|
||||
'may_reconnect': True,
|
||||
'may_fail': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects_2,
|
||||
{'disconnect': disconnects_2,
|
||||
'may_reconnect': True,
|
||||
'may_fail': True}])
|
||||
|
||||
@ -201,12 +200,9 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_v2_rbf(node_factory, bitcoind, chainparams):
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'wumbo': None},
|
||||
{'experimental-dual-fund': None,
|
||||
'wumbo': None}])
|
||||
l1, l2 = node_factory.get_nodes(2, opts={'wumbo': None})
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -280,10 +276,10 @@ def test_v2_rbf(node_factory, bitcoind, chainparams):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts={'experimental-dual-fund': None,
|
||||
'may_reconnect': True,
|
||||
opts={'may_reconnect': True,
|
||||
'allow_warning': True})
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
@ -361,17 +357,16 @@ def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
|
||||
disconnects = ['-WIRE_INIT_RBF',
|
||||
'@WIRE_INIT_RBF',
|
||||
'+WIRE_INIT_RBF']
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects,
|
||||
opts=[{'disconnect': disconnects,
|
||||
'may_reconnect': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'may_reconnect': True}])
|
||||
{'may_reconnect': True}])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -413,16 +408,15 @@ def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
|
||||
disconnects = ['-WIRE_ACK_RBF',
|
||||
'@WIRE_ACK_RBF',
|
||||
'+WIRE_ACK_RBF']
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'may_reconnect': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects,
|
||||
opts=[{'may_reconnect': True},
|
||||
{'disconnect': disconnects,
|
||||
'may_reconnect': True}])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
@ -465,6 +459,7 @@ def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
|
||||
disconnects = ['=WIRE_TX_ADD_INPUT', # Initial funding succeeds
|
||||
'-WIRE_TX_ADD_INPUT',
|
||||
@ -478,11 +473,9 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
|
||||
'+WIRE_TX_COMPLETE']
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects,
|
||||
opts=[{'disconnect': disconnects,
|
||||
'may_reconnect': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'may_reconnect': True}])
|
||||
{'may_reconnect': True}])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -533,6 +526,7 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.developer("uses dev-disconnect")
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
|
||||
disconnects = ['=WIRE_TX_SIGNATURES', # Initial funding succeeds
|
||||
'-WIRE_TX_SIGNATURES', # When we send tx-sigs, RBF
|
||||
@ -542,11 +536,9 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
|
||||
'+WIRE_TX_SIGNATURES'] # When we RBF again
|
||||
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts=[{'experimental-dual-fund': None,
|
||||
'disconnect': disconnects,
|
||||
opts=[{'disconnect': disconnects,
|
||||
'may_reconnect': True},
|
||||
{'experimental-dual-fund': None,
|
||||
'may_reconnect': True}])
|
||||
{'may_reconnect': True}])
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -666,10 +658,10 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_rbf_no_overlap(node_factory, bitcoind, chainparams):
|
||||
l1, l2 = node_factory.get_nodes(2,
|
||||
opts={'experimental-dual-fund': None,
|
||||
'allow_warning': True})
|
||||
opts={'allow_warning': True})
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
amount = 2**24
|
||||
@ -702,8 +694,9 @@ def test_rbf_no_overlap(node_factory, bitcoind, chainparams):
|
||||
|
||||
|
||||
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
|
||||
@pytest.mark.openchannel('v2')
|
||||
def test_funder_options(node_factory, bitcoind):
|
||||
l1, l2, l3 = node_factory.get_nodes(3, opts={'experimental-dual-fund': None})
|
||||
l1, l2, l3 = node_factory.get_nodes(3)
|
||||
l1.fundwallet(10**7)
|
||||
|
||||
# Check the default options
|
||||
|
@ -3560,13 +3560,6 @@ def test_mpp_interference_2(node_factory, bitcoind, executor):
|
||||
with more than sufficient capacity, as well.
|
||||
'''
|
||||
opts = {'feerates': (1000, 1000, 1000, 1000)}
|
||||
if EXPERIMENTAL_DUAL_FUND:
|
||||
# fundbalancedchannel doesn't work for opt_dual_fund
|
||||
# because we've removed push_msat
|
||||
opts['experimental-dual-fund'] = None
|
||||
opts['funder-policy'] = 'match'
|
||||
opts['funder-policy-mod'] = 100
|
||||
opts['funder-fuzz-percent'] = 0
|
||||
|
||||
l1, l2, l3, l4, l5, l6, l7 = node_factory.get_nodes(7, opts=opts)
|
||||
|
||||
@ -3691,13 +3684,6 @@ def test_mpp_overload_payee(node_factory, bitcoind):
|
||||
# default limit in the future, so explicitly put this value here, since
|
||||
# that is what our test assumes.
|
||||
opts = {'max-concurrent-htlcs': 30}
|
||||
if EXPERIMENTAL_DUAL_FUND:
|
||||
# fundbalancedchannel doesn't work for opt_dual_fund
|
||||
# because we've removed push_msat
|
||||
opts['experimental-dual-fund'] = None
|
||||
opts['funder-policy'] = 'match'
|
||||
opts['funder-policy-mod'] = 100
|
||||
opts['funder-fuzz-percent'] = 0
|
||||
|
||||
l1, l2, l3, l4, l5, l6 = node_factory.get_nodes(6, opts=opts)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user