diff --git a/tests/test_gossip.py b/tests/test_gossip.py index 37ffb42f6..1cc3a5443 100644 --- a/tests/test_gossip.py +++ b/tests/test_gossip.py @@ -939,6 +939,85 @@ def test_gossip_addresses(node_factory, bitcoind): ] +@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') +@pytest.mark.developer("needs dev-fast-gossip") +@pytest.mark.openchannel('v2') +def test_gossip_lease_rates(node_factory, bitcoind): + lease_opts = {'lease-fee-basis': 50, + 'lease-fee-base-msat': '2000msat', + 'channel-fee-max-base-msat': '500sat', + 'channel-fee-max-proportional-thousandths': 200} + l1, l2 = node_factory.get_nodes(2, opts=[lease_opts, {}]) + + # These logs happen during startup, start looking from the beginning + l1.daemon.logsearch_start = 0 + l2.daemon.logsearch_start = 0 + + rates = l1.rpc.call('funderupdate') + assert rates['channel_fee_max_base_msat'] == Millisatoshi('500000msat') + assert rates['channel_fee_max_proportional_thousandths'] == 200 + assert rates['funding_weight'] == 666 # Default on regtest + assert rates['lease_fee_base_msat'] == Millisatoshi('2000msat') + assert rates['lease_fee_basis'] == 50 + + rates = l2.rpc.call('funderupdate') + assert 'channel_fee_max_base_msat' not in rates + assert 'channel_fee_max_proportional_thousandths' not in rates + assert 'funding_weight' not in rates + assert 'lease_fee_base_msat' not in rates + assert 'lease_fee_basis' not in rates + + # Open a channel, check that the node_announcements + # include offer details, as expected + l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + l1.fundchannel(l2, 10**6) + + # Announce depth is ALWAYS 6 blocks + bitcoind.generate_block(5) + + l2.daemon.wait_for_log('Received node_announcement for node {}' + .format(l1.info['id'])) + l1.daemon.wait_for_log('Received node_announcement for node {}' + .format(l2.info['id'])) + + l2_nodeinfo = only_one(l1.rpc.listnodes(l2.info['id'])['nodes']) + l1_nodeinfo = only_one(l2.rpc.listnodes(l1.info['id'])['nodes']) + + assert 'option_will_fund' not in l2_nodeinfo + rates = l1_nodeinfo['option_will_fund'] + assert rates['channel_fee_max_base_msat'] == Millisatoshi('500000msat') + assert rates['channel_fee_max_proportional_thousandths'] == 200 + assert rates['funding_weight'] == 666 # Default on regtest + assert rates['lease_fee_base_msat'] == Millisatoshi('2000msat') + assert rates['lease_fee_basis'] == 50 + + # Update the node announce (set new on l2, turn off l1) + # (Turn off by setting everything to zero) + l1.rpc.call('funderupdate', {'channel_fee_max_base_msat': '0msat', + 'channel_fee_max_proportional_thousandths': 0, + 'funding_weight': 0, + 'lease_fee_base_msat': '0msat', + 'lease_fee_basis': 0}) + l2.rpc.call('funderupdate', {'channel_fee_max_base_msat': '30000msat', + 'channel_fee_max_proportional_thousandths': 100, + 'lease_fee_base_msat': '400000msat', + 'lease_fee_basis': 20}) + + 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'])) + + l2_nodeinfo = only_one(l1.rpc.listnodes(l2.info['id'])['nodes']) + l1_nodeinfo = only_one(l2.rpc.listnodes(l1.info['id'])['nodes']) + + assert 'option_will_fund' not in l1_nodeinfo + rates = l2_nodeinfo['option_will_fund'] + assert rates['channel_fee_max_base_msat'] == Millisatoshi('30000msat') + assert rates['channel_fee_max_proportional_thousandths'] == 100 + assert rates['funding_weight'] == 666 # Default on regtest + assert rates['lease_fee_base_msat'] == Millisatoshi('400000msat') + assert rates['lease_fee_basis'] == 20 + + def test_gossip_store_load(node_factory): """Make sure we can read canned gossip store""" l1 = node_factory.get_node(start=False)