mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 01:04:43 +02:00
util: Abort on failing CHECK_NONFATAL in debug builds
This requires adjusting some tests to force exceptions over aborts, or accept either exceptions or aborts. Also, remove a fuzz test in integer.cpp that is mostly redundant with the unit test added in the prior commit.
This commit is contained in:
@@ -15,6 +15,9 @@ from test_framework.util import (
|
||||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
import http
|
||||
import subprocess
|
||||
|
||||
|
||||
class RpcMiscTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
@@ -24,11 +27,22 @@ class RpcMiscTest(BitcoinTestFramework):
|
||||
node = self.nodes[0]
|
||||
|
||||
self.log.info("test CHECK_NONFATAL")
|
||||
assert_raises_rpc_error(
|
||||
-1,
|
||||
'Internal bug detected: request.params[9].get_str() != "trigger_internal_bug"',
|
||||
lambda: node.echo(arg9='trigger_internal_bug'),
|
||||
)
|
||||
msg_internal_bug = 'request.params[9].get_str() != "trigger_internal_bug"'
|
||||
self.restart_node(0) # Required to flush the chainstate
|
||||
try:
|
||||
node.echo(arg9="trigger_internal_bug")
|
||||
assert False # Must hit one of the exceptions below
|
||||
except (
|
||||
subprocess.CalledProcessError,
|
||||
http.client.CannotSendRequest,
|
||||
http.client.RemoteDisconnected,
|
||||
):
|
||||
self.log.info("Restart node after crash")
|
||||
assert_equal(-6, node.process.wait(timeout=10))
|
||||
self.start_node(0)
|
||||
except JSONRPCException as e:
|
||||
assert_equal(e.error["code"], -1)
|
||||
assert f"Internal bug detected: {msg_internal_bug}" in e.error["message"]
|
||||
|
||||
self.log.info("test getmemoryinfo")
|
||||
memory = node.getmemoryinfo()['locked']
|
||||
|
||||
Reference in New Issue
Block a user