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

Function test_missing_method_or_nodeid

tests/test_runes.py:559–599  ·  view source on GitHub ↗

For v23.11 we realized that nodeid should not be required for checkrune, which means method (which followed it) could not be require either

(node_factory)

Source from the content-addressed store, hash-verified

557
558
559def test_missing_method_or_nodeid(node_factory):
560 """For v23.11 we realized that nodeid should not be required for checkrune, which means method (which followed it) could not be require either"""
561 l1 = node_factory.get_node()
562 rune1 = l1.rpc.createrune(restrictions=[["method=getinfo"]])['rune']
563 rune2 = l1.rpc.createrune(restrictions=[["id={}".format(l1.info['id'])]])['rune']
564 rune3 = l1.rpc.createrune(restrictions=[["method!"]])['rune']
565 rune4 = l1.rpc.createrune(restrictions=[["id!"]])['rune']
566
567 # Simple cases with nodeid and method
568 assert l1.rpc.checkrune(rune=rune1,
569 nodeid=l1.info['id'],
570 method='getinfo')['valid'] is True
571 assert l1.rpc.checkrune(rune=rune2,
572 nodeid=l1.info['id'],
573 method='getinfo')['valid'] is True
574 # No nodeid works for rune1
575 assert l1.rpc.checkrune(rune=rune1,
576 method='getinfo')['valid'] is True
577 # No method works for rune2
578 assert l1.rpc.checkrune(rune=rune2,
579 nodeid=l1.info['id'])['valid'] is True
580
581 # No method works for rune3
582 assert l1.rpc.checkrune(rune=rune3,
583 nodeid=l1.info['id'])['valid'] is True
584 # No id works for rune4
585 assert l1.rpc.checkrune(rune=rune4,
586 method='getinfo')['valid'] is True
587
588 # This fails, as method is missing
589 with pytest.raises(RpcError, match='Not permitted: method not present'):
590 l1.rpc.checkrune(rune=rune1)
591 # This fails, as id is missing
592 with pytest.raises(RpcError, match='Not permitted: id not present'):
593 l1.rpc.checkrune(rune=rune2)
594 # This fails, as method is present
595 with pytest.raises(RpcError, match='Not permitted: method is present'):
596 l1.rpc.checkrune(rune=rune3, method='getinfo')
597 # This fails, as id is present
598 with pytest.raises(RpcError, match='Not permitted: id is present'):
599 l1.rpc.checkrune(rune=rune4, nodeid=l1.info['id'])
600
601
602def test_rune_method_missing(node_factory):

Callers

nothing calls this directly

Calls 1

get_nodeMethod · 0.45

Tested by

no test coverage detected