Exemplo n.º 1
0
def test_feature_set(node_factory):
    plugin = os.path.join(os.path.dirname(__file__), 'plugins/show_feature_set.py')
    l1 = node_factory.get_node(options={"plugin": plugin})

    fs = l1.rpc.call('getfeatureset')
    assert fs['init'] == expected_features()
    assert fs['node'] == expected_features()
    assert fs['channel'] == ''
    assert 'invoice' in fs
Exemplo n.º 2
0
def test_plugin_feature_announce(node_factory):
    """Check that features registered by plugins show up in messages.

    l1 is the node under test, l2 only serves as the counterparty for a
    channel to check the featurebits in the `channel_announcement`. The plugin
    registers an individual featurebit for each of the locations we can stash
    feature bits in:

     - 1 << 101 for `init` messages
     - 1 << 103 for `node_announcement`
     - 1 << 105 for bolt11 invoices

    """
    plugin = os.path.join(os.path.dirname(__file__), 'plugins/feature-test.py')
    l1, l2 = node_factory.line_graph(2,
                                     opts=[{
                                         'plugin': plugin,
                                         'log-level': 'io'
                                     }, {}],
                                     wait_for_announce=True)

    # Check the featurebits we've set in the `init` message from
    # feature-test.py. (1 << 101) results in 13 bytes featutebits (000d) and
    # has a leading 0x20.
    assert l1.daemon.is_in_log(r'\[OUT\] 001000.*000d20{:0>24}'.format(
        expected_features()))

    # Check the invoice featurebit we set in feature-test.py
    inv = l1.rpc.invoice(123, 'lbl', 'desc')['bolt11']
    details = Invoice.decode(inv)
    assert (details.featurebits.int & (1 << 105) != 0)

    # Check the featurebit set in the `node_announcement`
    node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
    assert (int(node['features'], 16) & (1 << 103) != 0)