When in non-developer mode, don't return the contents of invalid parameters, but refer to logs
(node_factory)
| 5135 | |
| 5136 | |
| 5137 | def 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") |