MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_even_sendcustommsg

Function test_even_sendcustommsg

tests/test_misc.py:4937–4973  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

4935
4936
4937def test_even_sendcustommsg(node_factory):
4938 l1, l2 = node_factory.get_nodes(2, opts={'log-level': 'io',
4939 'allow_warning': True})
4940 l1.connect(l2)
4941
4942 # Even-numbered message
4943 msg = hex(43690)[2:] + ('ff' * 30) + 'bb'
4944
4945 # l2 will hang up when it gets this.
4946 l1.rpc.sendcustommsg(l2.info['id'], msg)
4947 l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
4948 l1.daemon.wait_for_log('Invalid unknown even msg')
4949 wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [])
4950
4951 # Now with a plugin which allows it
4952 l1.connect(l2)
4953 l2.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/allow_even_msgs.py"))
4954 l2.daemon.wait_for_log("connectd.*Now allowing 1 custom message types")
4955
4956 l1.rpc.sendcustommsg(l2.info['id'], msg)
4957 l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
4958 l2.daemon.wait_for_log(r'allow_even_msgs.*Got message 43690')
4959 # Make sure it *processes* before we remove plugin.
4960 l2.daemon.wait_for_log(f"{l1.info['id']}-connectd: custommsg processing finished")
4961
4962 # And nobody gets upset
4963 assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']
4964
4965 # It does if we remove the plugin though!
4966 l2.rpc.plugin_stop("allow_even_msgs.py")
4967 # Make sure connectd has processed the update!
4968 l2.daemon.wait_for_log("connectd: Now allowing 0 custom message types")
4969
4970 l1.rpc.sendcustommsg(l2.info['id'], msg)
4971 l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
4972 l1.daemon.wait_for_log('Invalid unknown even msg')
4973 wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [])
4974
4975
4976def test_set_feerate_offset(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
only_oneFunction · 0.90
get_nodesMethod · 0.80
sendcustommsgMethod · 0.80
wait_for_logMethod · 0.80
plugin_startMethod · 0.80
joinMethod · 0.80
plugin_stopMethod · 0.80
connectMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected