mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
pytest: fix feature mask for EXPERIMENTAL_FEATURES, add wumbo support.
There are various places where our tests failed with --enable-expimental-features. And our plugin test overlapped an existing feature. We make our expected_feature functions more generic, and use them everywhere. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
0b89664076
commit
f4f8a363dd
@@ -6,9 +6,9 @@ from pyln.client import Plugin
|
|||||||
# later check that they are being passed correctly.
|
# later check that they are being passed correctly.
|
||||||
plugin = Plugin(
|
plugin = Plugin(
|
||||||
dynamic=False,
|
dynamic=False,
|
||||||
init_features=1 << 101,
|
init_features=1 << 201,
|
||||||
node_features=1 << 103,
|
node_features=1 << 203,
|
||||||
invoice_features=1 << 105,
|
invoice_features=1 << 205,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1880,6 +1880,8 @@ def test_list_features_only(node_factory):
|
|||||||
'option_payment_secret/odd',
|
'option_payment_secret/odd',
|
||||||
'option_basic_mpp/odd',
|
'option_basic_mpp/odd',
|
||||||
]
|
]
|
||||||
|
if EXPERIMENTAL_FEATURES:
|
||||||
|
expected += ['option_unknown_102/odd']
|
||||||
assert features == expected
|
assert features == expected
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ from pyln.client import RpcError, Millisatoshi
|
|||||||
from pyln.proto import Invoice
|
from pyln.proto import Invoice
|
||||||
from utils import (
|
from utils import (
|
||||||
DEVELOPER, only_one, sync_blockheight, TIMEOUT, wait_for, TEST_NETWORK,
|
DEVELOPER, only_one, sync_blockheight, TIMEOUT, wait_for, TEST_NETWORK,
|
||||||
DEPRECATED_APIS, expected_peer_features, expected_node_features, account_balance,
|
DEPRECATED_APIS, expected_peer_features, expected_node_features,
|
||||||
|
expected_channel_features, account_balance,
|
||||||
check_coin_moves, first_channel_id, check_coin_moves_idx
|
check_coin_moves, first_channel_id, check_coin_moves_idx
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1001,9 +1002,9 @@ def test_plugin_feature_announce(node_factory):
|
|||||||
registers an individual featurebit for each of the locations we can stash
|
registers an individual featurebit for each of the locations we can stash
|
||||||
feature bits in:
|
feature bits in:
|
||||||
|
|
||||||
- 1 << 101 for `init` messages
|
- 1 << 201 for `init` messages
|
||||||
- 1 << 103 for `node_announcement`
|
- 1 << 203 for `node_announcement`
|
||||||
- 1 << 105 for bolt11 invoices
|
- 1 << 205 for bolt11 invoices
|
||||||
|
|
||||||
"""
|
"""
|
||||||
plugin = os.path.join(os.path.dirname(__file__), 'plugins/feature-test.py')
|
plugin = os.path.join(os.path.dirname(__file__), 'plugins/feature-test.py')
|
||||||
@@ -1013,18 +1014,18 @@ def test_plugin_feature_announce(node_factory):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Check the featurebits we've set in the `init` message from
|
# Check the featurebits we've set in the `init` message from
|
||||||
# feature-test.py. (1 << 101) results in 13 bytes featutebits (000d) and
|
# feature-test.py.
|
||||||
# has a leading 0x20.
|
assert l1.daemon.is_in_log(r'\[OUT\] 001000022200....{}'
|
||||||
assert l1.daemon.is_in_log(r'\[OUT\] 001000.*000d20{:0>24}'.format(expected_peer_features()))
|
.format(expected_peer_features(extra=[201])))
|
||||||
|
|
||||||
# Check the invoice featurebit we set in feature-test.py
|
# Check the invoice featurebit we set in feature-test.py
|
||||||
inv = l1.rpc.invoice(123, 'lbl', 'desc')['bolt11']
|
inv = l1.rpc.invoice(123, 'lbl', 'desc')['bolt11']
|
||||||
details = Invoice.decode(inv)
|
details = Invoice.decode(inv)
|
||||||
assert(details.featurebits.int & (1 << 105) != 0)
|
assert(details.featurebits.int & (1 << 205) != 0)
|
||||||
|
|
||||||
# Check the featurebit set in the `node_announcement`
|
# Check the featurebit set in the `node_announcement`
|
||||||
node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
|
node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
|
||||||
assert(int(node['features'], 16) & (1 << 103) != 0)
|
assert node['features'] == expected_node_features(extra=[203])
|
||||||
|
|
||||||
|
|
||||||
def test_hook_chaining(node_factory):
|
def test_hook_chaining(node_factory):
|
||||||
@@ -1247,7 +1248,7 @@ def test_feature_set(node_factory):
|
|||||||
fs = l1.rpc.call('getfeatureset')
|
fs = l1.rpc.call('getfeatureset')
|
||||||
assert fs['init'] == expected_peer_features()
|
assert fs['init'] == expected_peer_features()
|
||||||
assert fs['node'] == expected_node_features()
|
assert fs['node'] == expected_node_features()
|
||||||
assert fs['channel'] == ''
|
assert fs['channel'] == expected_channel_features()
|
||||||
assert 'invoice' in fs
|
assert 'invoice' in fs
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,54 @@
|
|||||||
from pyln.testing.utils import TEST_NETWORK, SLOW_MACHINE, TIMEOUT, VALGRIND, DEVELOPER, DEPRECATED_APIS # noqa: F401
|
from pyln.testing.utils import TEST_NETWORK, SLOW_MACHINE, TIMEOUT, VALGRIND, DEVELOPER, DEPRECATED_APIS # noqa: F401
|
||||||
from pyln.testing.utils import env, only_one, wait_for, write_config, TailableProc, sync_blockheight, wait_channel_quiescent, get_tx_p2wsh_outnum # noqa: F401
|
from pyln.testing.utils import env, only_one, wait_for, write_config, TailableProc, sync_blockheight, wait_channel_quiescent, get_tx_p2wsh_outnum # noqa: F401
|
||||||
|
import bitstring
|
||||||
|
|
||||||
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
||||||
COMPAT = env("COMPAT", "1") == "1"
|
COMPAT = env("COMPAT", "1") == "1"
|
||||||
|
|
||||||
|
|
||||||
def expected_peer_features():
|
def hex_bits(features):
|
||||||
|
# We always to full bytes
|
||||||
|
flen = (max(features + [0]) + 7) // 8 * 8
|
||||||
|
res = bitstring.BitArray(length=flen)
|
||||||
|
# Big endian sucketh.
|
||||||
|
for f in features:
|
||||||
|
res[flen - 1 - f] = 1
|
||||||
|
return res.hex
|
||||||
|
|
||||||
|
|
||||||
|
def expected_peer_features(wumbo_channels=False, extra=[]):
|
||||||
"""Return the expected peer features hexstring for this configuration"""
|
"""Return the expected peer features hexstring for this configuration"""
|
||||||
# features 1, 3, 7, 9, 11, 13, 15 and 17 (0x02aaa2).
|
features = [1, 5, 7, 9, 11, 13, 15, 17]
|
||||||
return "02aaa2"
|
if EXPERIMENTAL_FEATURES:
|
||||||
|
# OPT_ONION_MESSAGES
|
||||||
|
features += [103]
|
||||||
|
if wumbo_channels:
|
||||||
|
features += [19]
|
||||||
|
return hex_bits(features + extra)
|
||||||
|
|
||||||
|
|
||||||
# With the addition of the keysend plugin, we now send a different set of
|
# With the addition of the keysend plugin, we now send a different set of
|
||||||
# features for the 'node' and the 'peer' feature sets
|
# features for the 'node' and the 'peer' feature sets
|
||||||
def expected_node_features():
|
def expected_node_features(wumbo_channels=False, extra=[]):
|
||||||
"""Return the expected node features hexstring for this configuration"""
|
"""Return the expected node features hexstring for this configuration"""
|
||||||
# features 1, 3, 7, 9, 11, 13, 15, 17 and 55 (0x8000000002aaa2).
|
features = [1, 5, 7, 9, 11, 13, 15, 17, 55]
|
||||||
return "8000000002aaa2"
|
|
||||||
|
|
||||||
|
|
||||||
def expected_channel_features():
|
|
||||||
"""Return the expected channel features hexstring for this configuration"""
|
|
||||||
# experimental OPT_ONION_MESSAGES
|
|
||||||
if EXPERIMENTAL_FEATURES:
|
if EXPERIMENTAL_FEATURES:
|
||||||
return '80000000000000000000000000'
|
# OPT_ONION_MESSAGES
|
||||||
else:
|
features += [103]
|
||||||
return ''
|
if wumbo_channels:
|
||||||
|
features += [19]
|
||||||
|
return hex_bits(features + extra)
|
||||||
|
|
||||||
|
|
||||||
|
def expected_channel_features(wumbo_channels=False, extra=[]):
|
||||||
|
"""Return the expected channel features hexstring for this configuration"""
|
||||||
|
features = []
|
||||||
|
if EXPERIMENTAL_FEATURES:
|
||||||
|
# OPT_ONION_MESSAGES
|
||||||
|
features += [103]
|
||||||
|
if wumbo_channels:
|
||||||
|
features += [19]
|
||||||
|
return hex_bits(features + extra)
|
||||||
|
|
||||||
|
|
||||||
def check_coin_moves(n, account_id, expected_moves):
|
def check_coin_moves(n, account_id, expected_moves):
|
||||||
|
|||||||
Reference in New Issue
Block a user