From 8c20796aacbbf5261e1922d45fc8afe75f54fefb Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 7 Dec 2022 17:04:15 -0500 Subject: tests: Use waitfornewblock for work queue test in interface_rpc The work queue exceeded test in interface_rpc.py would repeatedly call an RPC until the error was achieved. However hitting this error is dependent on the processing speed of the computer and the optimization level of the binary. Configurations that result in slower processing would result in the RPC used being processed before the error could be hit, resulting the test's runtime having a high variance. Switching the RPC to waitfornewblock allows it to run in a much more consistent time that is still fairly fast. waitfornewblock forces the RPC server to allocate a thread and wait, occupying a spot in the work queue. This is perfect for this test because the slower the RPC, the more likely we will achieve the race condition necessary to pass the test. Using a timeout of 500 ms appears to work reliably without causing the test to take too long. --- test/functional/interface_rpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/interface_rpc.py b/test/functional/interface_rpc.py index 48082f3a17..3389746635 100755 --- a/test/functional/interface_rpc.py +++ b/test/functional/interface_rpc.py @@ -25,7 +25,7 @@ def expect_http_status(expected_http_status, expected_rpc_code, def test_work_queue_getblock(node, got_exceeded_error): while not got_exceeded_error: try: - node.cli('getrpcinfo').send_cli() + node.cli("waitfornewblock", "500").send_cli() except subprocess.CalledProcessError as e: assert_equal(e.output, 'error: Server response: Work queue depth exceeded\n') got_exceeded_error.append(True) -- cgit v1.2.3