Skip to content

Commit

Permalink
pytest: add test for channel_announcement feature bits.
Browse files Browse the repository at this point in the history
And neaten current feature mangling code now we have a wumbo flag for
expected_peer_features().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed May 8, 2020
1 parent 5aa4f9a commit ea4b1e6
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyln.client import RpcError, Millisatoshi
from utils import (
DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT,
SLOW_MACHINE, expected_peer_features, expected_node_features
SLOW_MACHINE, expected_peer_features, expected_node_features, expected_channel_features
)
from bitcoin.core import CMutableTransaction, CMutableTxOut

Expand Down Expand Up @@ -2239,18 +2239,13 @@ def test_pay_disconnect_stress(node_factory, executor):


def test_wumbo_channels(node_factory, bitcoind):
f = bytes.fromhex(expected_peer_features())

# OPT_LARGE_CHANNELS = 18 (19 for us). 0x080000
f = (f[:-3] + bytes([f[-3] | 0x08]) + f[-2:]).hex()

l1, l2, l3 = node_factory.get_nodes(3,
opts=[{'large-channels': None},
{'large-channels': None},
{}])
conn = l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
assert conn['features'] == f
assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['features'] == f
assert conn['features'] == expected_peer_features(wumbo_channels=True)
assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['features'] == expected_peer_features(wumbo_channels=True)

# Now, can we open a giant channel?
l1.fundwallet(1 << 26)
Expand All @@ -2268,6 +2263,10 @@ def test_wumbo_channels(node_factory, bitcoind):
assert ([c['amount_msat'] for c in l3.rpc.listchannels()['channels']]
== [Millisatoshi(str(1 << 24) + "sat")] * 2)

# Make sure channel features are right from channel_announcement
assert ([c['features'] for c in l3.rpc.listchannels()['channels']]
== [expected_channel_features(wumbo_channels=True)] * 2)

# Make sure we can't open a wumbo channel if we don't agree.
with pytest.raises(RpcError, match='Amount exceeded'):
l1.rpc.fundchannel(l3.info['id'], 1 << 24)
Expand Down

0 comments on commit ea4b1e6

Please sign in to comment.