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

Function test_commando_rune

tests/test_plugin.py:2676–2907  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

2674
2675
2676def test_commando_rune(node_factory):
2677 l1, l2 = node_factory.get_nodes(2)
2678
2679 # Force l1's commando secret
2680 l1.rpc.datastore(key=['commando', 'secret'], hex='1241faef85297127c2ac9bde95421b2c51e5218498ae4901dc670c974af4284b')
2681 l1.restart()
2682 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2683
2684 # I put that into a test node's commando.py to generate these runes (modified readonly to match ours):
2685 # $ l1-cli commando-rune
2686 # "rune": "zKc2W88jopslgUBl0UE77aEe5PNCLn5WwqSusU_Ov3A9MA=="
2687 # $ l1-cli commando-rune restrictions=readonly
2688 # "rune": "1PJnoR9a7u4Bhglj2s7rVOWqRQnswIwUoZrDVMKcLTY9MSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl"
2689 # $ l1-cli commando-rune restrictions='[[time>1656675211]]'
2690 # "rune": "RnlWC4lwBULFaObo6ZP8jfqYRyTbfWPqcMT3qW-Wmso9MiZ0aW1lPjE2NTY2NzUyMTE="
2691 # $ l1-cli commando-rune restrictions='[["id^022d223620a359a47ff7"],["method=listpeers"]]'
2692 # "rune": "lXFWzb51HjWxKV5TmfdiBgd74w0moeyChj3zbLoxmws9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJz"
2693 # $ l1-cli commando-rune lXFWzb51HjWxKV5TmfdiBgd74w0moeyChj3zbLoxmws9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJz '[pnamelevel!,pnamelevel/io]'
2694 # "rune": "Dw2tzGCoUojAyT0JUw7fkYJYqExpEpaDRNTkyvWKoJY9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJzJnBuYW1lbGV2ZWwhfHBuYW1lbGV2ZWwvaW8="
2695
2696 rune1 = l1.rpc.commando_rune()
2697 assert rune1['rune'] == 'zKc2W88jopslgUBl0UE77aEe5PNCLn5WwqSusU_Ov3A9MA=='
2698 assert rune1['unique_id'] == '0'
2699 rune2 = l1.rpc.commando_rune(restrictions="readonly")
2700 assert rune2['rune'] == '1PJnoR9a7u4Bhglj2s7rVOWqRQnswIwUoZrDVMKcLTY9MSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl'
2701 assert rune2['unique_id'] == '1'
2702 rune3 = l1.rpc.commando_rune(restrictions=[["time>1656675211"]])
2703 assert rune3['rune'] == 'RnlWC4lwBULFaObo6ZP8jfqYRyTbfWPqcMT3qW-Wmso9MiZ0aW1lPjE2NTY2NzUyMTE='
2704 assert rune3['unique_id'] == '2'
2705 rune4 = l1.rpc.commando_rune(restrictions=[["id^022d223620a359a47ff7"], ["method=listpeers"]])
2706 assert rune4['rune'] == 'lXFWzb51HjWxKV5TmfdiBgd74w0moeyChj3zbLoxmws9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJz'
2707 assert rune4['unique_id'] == '3'
2708 rune5 = l1.rpc.commando_rune(rune4['rune'], [["pnamelevel!", "pnamelevel/io"]])
2709 assert rune5['rune'] == 'Dw2tzGCoUojAyT0JUw7fkYJYqExpEpaDRNTkyvWKoJY9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJzJnBuYW1lbGV2ZWwhfHBuYW1lbGV2ZWwvaW8='
2710 assert rune5['unique_id'] == '3'
2711 rune6 = l1.rpc.commando_rune(rune5['rune'], [["parr1!", "parr1/io"]])
2712 assert rune6['rune'] == '2Wh6F4R51D3esZzp-7WWG51OhzhfcYKaaI8qiIonaHE9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJzJnBuYW1lbGV2ZWwhfHBuYW1lbGV2ZWwvaW8mcGFycjEhfHBhcnIxL2lv'
2713 assert rune6['unique_id'] == '3'
2714 rune7 = l1.rpc.commando_rune(restrictions=[["pnum=0"]])
2715 assert rune7['rune'] == 'QJonN6ySDFw-P5VnilZxlOGRs_tST1ejtd-bAYuZfjk9NCZwbnVtPTA='
2716 assert rune7['unique_id'] == '4'
2717 rune8 = l1.rpc.commando_rune(rune7['rune'], [["rate=3"]])
2718 assert rune8['rune'] == 'kSYFx6ON9hr_ExcQLwVkm1ABnvc1TcMFBwLrAVee0EA9NCZwbnVtPTAmcmF0ZT0z'
2719 assert rune8['unique_id'] == '4'
2720 rune9 = l1.rpc.commando_rune(rune8['rune'], [["rate=1"]])
2721 assert rune9['rune'] == 'O8Zr-ULTBKO3_pKYz0QKE9xYl1vQ4Xx9PtlHuist9Rk9NCZwbnVtPTAmcmF0ZT0zJnJhdGU9MQ=='
2722 assert rune9['unique_id'] == '4'
2723
2724 # Test rune with \|.
2725 weirdrune = l1.rpc.commando_rune(restrictions=[["method=invoice"],
2726 ["pnamedescription=@tipjar|jb55@sendsats.lol"]])
2727 with pytest.raises(RpcError, match='Not authorized:'):
2728 l2.rpc.call(method='commando',
2729 payload={'peer_id': l1.info['id'],
2730 'rune': weirdrune['rune'],
2731 'method': 'invoice',
2732 'params': {"amount_msat": "any",
2733 "label": "lbl",

Callers

nothing calls this directly

Calls 7

get_nodesMethod · 0.80
datastoreMethod · 0.80
restartMethod · 0.80
connectMethod · 0.45
callMethod · 0.45
decodeMethod · 0.45
get_nodeMethod · 0.45

Tested by

no test coverage detected