From ebee48ca8cd8bd509baf1c998bf18c874252a60b Mon Sep 17 00:00:00 2001 From: Tony Aldon Date: Tue, 10 Oct 2023 18:29:43 +0200 Subject: [PATCH] pytest: test `checkrune` when `method` parameter is the empty string. Add test `test_rune_method_not_equal_and_method_empty` that reproduces issue #6725. This fails currently, so next commit fix it up. Error: ``` > with pytest.raises(RpcError, match='Not permitted: method not present'): E Failed: DID NOT RAISE tests/test_runes.py:605: Failed ``` --- tests/test_runes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_runes.py b/tests/test_runes.py index 687f57c97..0f3c1e0c0 100644 --- a/tests/test_runes.py +++ b/tests/test_runes.py @@ -594,6 +594,18 @@ def test_missing_method_or_nodeid(node_factory): l1.rpc.checkrune(rune=rune4, nodeid=l1.info['id']) +def test_rune_method_not_equal_and_method_empty(node_factory): + """Test `checkrune` when `method` parameter is the empty string and a `method` is negated in the rune.""" + l1 = node_factory.get_node() + rune = l1.rpc.createrune(restrictions=[["method/getinfo"]])['rune'] + + with pytest.raises(RpcError, match='Not permitted: method is equal to getinfo'): + l1.rpc.checkrune(rune=rune, method='getinfo') + assert l1.rpc.checkrune(rune=rune, method='invoice')['valid'] is True + with pytest.raises(RpcError, match='Not permitted: method not present'): + l1.rpc.checkrune(rune=rune, method='') + + def test_invalid_restrictions(node_factory): # I meant "method!" not "!method"! l1 = node_factory.get_node()