Skip to content

Commit d6d26dd

Browse files
committed
features: split expected feature bits into node/peer sets
The new `keysend` plugin modifies the node features that we send to peers. This commit breaks out the 'expected_features' we use for tests to encompass this differentiation.
1 parent 9f29833 commit d6d26dd

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

tests/test_connection.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyln.client import RpcError, Millisatoshi
77
from utils import (
88
DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT,
9-
SLOW_MACHINE, expected_features
9+
SLOW_MACHINE, expected_peer_features, expected_node_features
1010
)
1111
from bitcoin.core import CMutableTransaction, CMutableTxOut
1212

@@ -1558,7 +1558,8 @@ def test_forget_channel(node_factory):
15581558

15591559
def test_peerinfo(node_factory, bitcoind):
15601560
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'may_reconnect': True})
1561-
lfeatures = expected_features()
1561+
lfeatures = expected_peer_features()
1562+
nfeatures = expected_node_features()
15621563
# Gossiping but no node announcement yet
15631564
assert l1.rpc.getpeer(l2.info['id'])['connected']
15641565
assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0
@@ -1576,11 +1577,11 @@ def test_peerinfo(node_factory, bitcoind):
15761577
nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes']
15771578
peer1 = l1.rpc.getpeer(l2.info['id'])
15781579
peer2 = l2.rpc.getpeer(l1.info['id'])
1579-
assert only_one(nodes1)['features'] == peer1['features']
1580-
assert only_one(nodes2)['features'] == peer2['features']
1581-
1582-
assert l1.rpc.getpeer(l2.info['id'])['features'] == lfeatures
1583-
assert l2.rpc.getpeer(l1.info['id'])['features'] == lfeatures
1580+
# peer features != to node features now because of keysend, which adds a node feature
1581+
assert only_one(nodes1)['features'] == nfeatures
1582+
assert only_one(nodes2)['features'] == nfeatures
1583+
assert peer1['features'] == lfeatures
1584+
assert peer2['features'] == lfeatures
15841585

15851586
# If it reconnects after db load, it should know features.
15861587
l1.restart()
@@ -1813,7 +1814,7 @@ def test_dataloss_protection(node_factory, bitcoind):
18131814
l2 = node_factory.get_node(may_reconnect=True, options={'log-level': 'io'},
18141815
feerates=(7500, 7500, 7500, 7500), allow_broken_log=True)
18151816

1816-
lf = expected_features()
1817+
lf = expected_peer_features()
18171818

18181819
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
18191820
# l1 should send out WIRE_INIT (0010)
@@ -2236,7 +2237,7 @@ def test_pay_disconnect_stress(node_factory, executor):
22362237

22372238

22382239
def test_wumbo_channels(node_factory, bitcoind):
2239-
f = bytes.fromhex(expected_features())
2240+
f = bytes.fromhex(expected_peer_features())
22402241

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

tests/test_gossip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from fixtures import TEST_NETWORK
55
from pyln.client import RpcError
66
from utils import (
7-
wait_for, TIMEOUT, only_one, sync_blockheight, expected_features
7+
wait_for, TIMEOUT, only_one, sync_blockheight, expected_node_features
88
)
99

1010
import json
@@ -1029,7 +1029,7 @@ def test_node_reannounce(node_factory, bitcoind):
10291029
wait_for(lambda: 'alias' in only_one(l2.rpc.listnodes(l1.info['id'])['nodes']))
10301030
assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['alias'].startswith('JUNIORBEAM')
10311031

1032-
lfeatures = expected_features()
1032+
lfeatures = expected_node_features()
10331033

10341034
# Make sure it gets features correct.
10351035
assert only_one(l2.rpc.listnodes(l1.info['id'])['nodes'])['features'] == lfeatures

tests/test_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pyln.proto import Invoice
77
from utils import (
88
DEVELOPER, only_one, sync_blockheight, TIMEOUT, wait_for, TEST_NETWORK,
9-
DEPRECATED_APIS, expected_features
9+
DEPRECATED_APIS, expected_peer_features, expected_node_features
1010
)
1111

1212
import json
@@ -946,7 +946,7 @@ def test_plugin_feature_announce(node_factory):
946946
# Check the featurebits we've set in the `init` message from
947947
# feature-test.py. (1 << 101) results in 13 bytes featutebits (000d) and
948948
# has a leading 0x20.
949-
assert l1.daemon.is_in_log(r'\[OUT\] 001000.*000d20{:0>24}'.format(expected_features()))
949+
assert l1.daemon.is_in_log(r'\[OUT\] 001000.*000d20{:0>24}'.format(expected_peer_features()))
950950

951951
# Check the invoice featurebit we set in feature-test.py
952952
inv = l1.rpc.invoice(123, 'lbl', 'desc')['bolt11']
@@ -1176,8 +1176,8 @@ def test_feature_set(node_factory):
11761176
l1 = node_factory.get_node(options={"plugin": plugin})
11771177

11781178
fs = l1.rpc.call('getfeatureset')
1179-
assert fs['init'] == expected_features()
1180-
assert fs['node'] == expected_features()
1179+
assert fs['init'] == expected_peer_features()
1180+
assert fs['node'] == expected_node_features()
11811181
assert fs['channel'] == ''
11821182
assert 'invoice' in fs
11831183

tests/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
COMPAT = env("COMPAT", "1") == "1"
77

88

9-
def expected_features():
10-
"""Return the expected features hexstring for this configuration"""
9+
def expected_peer_features():
10+
"""Return the expected peer features hexstring for this configuration"""
1111
# features 1, 3, 7, 9, 11, 13, 15 and 17 (0x02aaa2).
1212
return "02aaa2"
13+
14+
15+
# With the addition of the keysend plugin, we now send a different set of
16+
# features for the 'node' and the 'peer' feature sets
17+
def expected_node_features():
18+
"""Return the expected node features hexstring for this configuration"""
19+
# features 1, 3, 7, 9, 11, 13, 15, 17 and 55 (0x8000000002aaa2).
20+
return "8000000002aaa2"

0 commit comments

Comments
 (0)