aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2022-12-07 17:04:15 -0500
committerAndrew Chow <github@achow101.com>2022-12-09 13:57:01 -0500
commit8c20796aacbbf5261e1922d45fc8afe75f54fefb (patch)
tree89a832737af00c16b2231532c84c8ff62ba051f3 /test
parent6c872d5e656a7117bbdf19a0220572b93de16f31 (diff)
downloadbitcoin-8c20796aacbbf5261e1922d45fc8afe75f54fefb.tar.xz
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/interface_rpc.py2
1 files changed, 1 insertions, 1 deletions
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)