Skip to content

Commit 8c20796

Browse files
committed
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.
1 parent 6c872d5 commit 8c20796

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/functional/interface_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def expect_http_status(expected_http_status, expected_rpc_code,
2525
def test_work_queue_getblock(node, got_exceeded_error):
2626
while not got_exceeded_error:
2727
try:
28-
node.cli('getrpcinfo').send_cli()
28+
node.cli("waitfornewblock", "500").send_cli()
2929
except subprocess.CalledProcessError as e:
3030
assert_equal(e.output, 'error: Server response: Work queue depth exceeded\n')
3131
got_exceeded_error.append(True)

0 commit comments

Comments
 (0)