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

Function test_createrune

tests/test_runes.py:13–199  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

11
12
13def test_createrune(node_factory):
14 l1 = node_factory.get_node(options={
15 'allow-deprecated-apis': True,
16 })
17
18 # l1's master rune secret is 4ac018131e70b044e17891e67960f59b9d602525d3aef9956e900189f456e595
19 rune1 = l1.rpc.createrune()
20 assert rune1['rune'] == 'I9TZsYEWiAwThQye-gYhpWIe1h15szWEN_qNyMSBOdE9MA=='
21 assert rune1['unique_id'] == '0'
22 rune2 = l1.rpc.createrune(restrictions="readonly")
23 assert rune2['rune'] == 's0IEnsikGDw76tdpAiMbqzigYhlkjqSVh0ZuvJ1Np1w9MSZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl'
24 assert rune2['unique_id'] == '1'
25 rune3 = l1.rpc.createrune(restrictions=[["time>1656675211"]])
26 assert rune3['rune'] == 'K0c0pWvBWb3y9HF1GMy33Zx2KRg1zcEvQLr2vtWwMew9MiZ0aW1lPjE2NTY2NzUyMTE='
27 assert rune3['unique_id'] == '2'
28 rune4 = l1.rpc.createrune(restrictions=[["id^022d223620a359a47ff7"], ["method=listpeers"]])
29 assert rune4['rune'] == 'ixuStVB4oewJtVNnim1P_qEL89ZU0G8Tnxg_JZgJTUk9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJz'
30 assert rune4['unique_id'] == '3'
31 rune5 = l1.rpc.createrune(rune4['rune'], [["pnamelevel!", "pnamelevel/io"]])
32 assert rune5['rune'] == 'NUPHrMs1TEdfWbRfO_KJ4rXhJSBjmSqbdcz-W0yH9J89MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJzJnBuYW1lbGV2ZWwhfHBuYW1lbGV2ZWwvaW8='
33 assert rune5['unique_id'] == '3'
34 rune6 = l1.rpc.createrune(rune5['rune'], [["parr1!", "parr1/io"]])
35 assert rune6['rune'] == 'sloBq0jn21v4LWhkswsHZgdtvQ0-jqgXXp_2jNNWLJA9MyZpZF4wMjJkMjIzNjIwYTM1OWE0N2ZmNyZtZXRob2Q9bGlzdHBlZXJzJnBuYW1lbGV2ZWwhfHBuYW1lbGV2ZWwvaW8mcGFycjEhfHBhcnIxL2lv'
36 assert rune6['unique_id'] == '3'
37 rune7 = l1.rpc.createrune(restrictions=[["pnum=0"]])
38 assert rune7['rune'] == 'k6kQt9dkGMaz75f51-PEkPk8Qovbiqz2HXconizqa-w9NCZwbnVtPTA='
39 assert rune7['unique_id'] == '4'
40 rune8 = l1.rpc.createrune(rune7['rune'], [["rate=3"]])
41 assert rune8['rune'] == 'jHidm2_terhiOytrn8xgEWR1pvFkKuoIvKgvcEeLLQQ9NCZwbnVtPTAmcmF0ZT0z'
42 assert rune8['unique_id'] == '4'
43 rune9 = l1.rpc.createrune(rune8['rune'], [["rate=1"]])
44 assert rune9['rune'] == 'AWO9sW94iv7Y99h0b6kyQO5yePUXQOSIpSuTRp8XFTM9NCZwbnVtPTAmcmF0ZT0zJnJhdGU9MQ=='
45 assert rune9['unique_id'] == '4'
46
47 # Test rune with \|.
48 weirdrune = l1.rpc.createrune(restrictions=[["method=invoice"],
49 ["pnamedescription=@tipjar|jb55@sendsats.lol"]])
50
51 with pytest.raises(RpcError, match='Not permitted:') as exc_info:
52 l1.rpc.checkrune(nodeid=l1.info['id'],
53 rune=weirdrune['rune'],
54 method='invoice',
55 params={"amount_msat": "any",
56 "label": "lbl",
57 "description": "@tipjar\\|jb55@sendsats.lol"})
58 assert exc_info.value.error['code'] == 0x5de
59
60 assert l1.rpc.checkrune(nodeid=l1.info['id'],
61 rune=weirdrune['rune'],
62 method='invoice',
63 params={"amount_msat": "any",
64 "label": "lbl",
65 "description": "@tipjar|jb55@sendsats.lol"})['valid'] is True
66
67 runedecodes = ((rune1, []),
68 (rune2, [{'alternatives': ['method^list', 'method^get', 'method=summary'],
69 'summary': "method (of command) starts with 'list' OR method (of command) starts with 'get' OR method (of command) equal to 'summary'"},
70 {'alternatives': ['method/listdatastore'],

Callers

nothing calls this directly

Calls 2

get_nodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected