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

Function test_badparam_discretion

tests/test_misc.py:5137–5168  ·  view source on GitHub ↗

When in non-developer mode, don't return the contents of invalid parameters, but refer to logs

(node_factory)

Source from the content-addressed store, hash-verified

5135
5136
5137def test_badparam_discretion(node_factory):
5138 """When in non-developer mode, don't return the contents of invalid parameters, but refer to logs"""
5139 l1 = node_factory.get_node()
5140
5141 with pytest.raises(RpcError, match='rune: should be base64 string: invalid token') as err:
5142 l1.rpc.checkrune(rune='THIS IS NOT ACTUALLY A RUNE')
5143
5144 assert err.value.error['message'] == "rune: should be base64 string: invalid token '\"THIS IS NOT ACTUALLY A RUNE\"'"
5145
5146 # We don't bother logging since we returned all the details
5147 assert not l1.daemon.is_in_log('Invalid parameter')
5148
5149 # Now try non-developer mode (needs some other option removal, too)
5150 l1.stop()
5151 assert l1.daemon.early_opts == ['--developer']
5152 l1.daemon.early_opts = []
5153 opts = copy.copy(l1.daemon.opts)
5154 for k in opts.keys():
5155 if k.startswith('dev'):
5156 del l1.daemon.opts[k]
5157 l1.start()
5158
5159 with pytest.raises(RpcError, match=r'rune: should be base64 string: invalid token \(see logs for details\)'):
5160 l1.rpc.checkrune(rune='THIS IS NOT ACTUALLY A RUNE')
5161
5162 l1.daemon.wait_for_log(r"checkrune: Invalid parameter rune \(should be base64 string\): token '\"THIS IS NOT ACTUALLY A RUNE\"'")
5163
5164 # But: check command *SHOULD* give as much info as we can.
5165 with pytest.raises(RpcError, match='rune: should be base64 string: invalid token') as err:
5166 l1.rpc.check('checkrune', rune='THIS IS NOT ACTUALLY A RUNE')
5167
5168 assert err.value.error['message'] == "rune: should be base64 string: invalid token '\"THIS IS NOT ACTUALLY A RUNE\"'"
5169
5170
5171@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "P2TR not yet supported on Elements")

Callers

nothing calls this directly

Calls 6

is_in_logMethod · 0.80
wait_for_logMethod · 0.80
get_nodeMethod · 0.45
stopMethod · 0.45
startMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected