Skip to content

Commit 8dd5946

Browse files
committed
add functional test
1 parent b5a80fa commit 8dd5946

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/functional/interface_rpc.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from test_framework.authproxy import JSONRPCException
99
from test_framework.test_framework import BitcoinTestFramework
1010
from test_framework.util import assert_equal, assert_greater_than_or_equal
11+
from threading import Thread
12+
import subprocess
13+
1114

1215
def expect_http_status(expected_http_status, expected_rpc_code,
1316
fcn, *args):
@@ -18,6 +21,16 @@ def expect_http_status(expected_http_status, expected_rpc_code,
1821
assert_equal(exc.error["code"], expected_rpc_code)
1922
assert_equal(exc.http_status, expected_http_status)
2023

24+
25+
def test_work_queue_getblock(node, got_exceeded_error):
26+
while not got_exceeded_error:
27+
try:
28+
node.cli('getrpcinfo').send_cli()
29+
except subprocess.CalledProcessError as e:
30+
assert_equal(e.output, 'error: Server response: Work queue depth exceeded\n')
31+
got_exceeded_error.append(True)
32+
33+
2134
class RPCInterfaceTest(BitcoinTestFramework):
2235
def set_test_params(self):
2336
self.num_nodes = 1
@@ -67,10 +80,23 @@ def test_http_status_codes(self):
6780
expect_http_status(404, -32601, self.nodes[0].invalidmethod)
6881
expect_http_status(500, -8, self.nodes[0].getblockhash, 42)
6982

83+
def test_work_queue_exceeded(self):
84+
self.log.info("Testing work queue exceeded...")
85+
self.restart_node(0, ['-rpcworkqueue=1', '-rpcthreads=1'])
86+
got_exceeded_error = []
87+
threads = []
88+
for _ in range(3):
89+
t = Thread(target=test_work_queue_getblock, args=(self.nodes[0], got_exceeded_error))
90+
t.start()
91+
threads.append(t)
92+
for t in threads:
93+
t.join()
94+
7095
def run_test(self):
7196
self.test_getrpcinfo()
7297
self.test_batch_request()
7398
self.test_http_status_codes()
99+
self.test_work_queue_exceeded()
74100

75101

76102
if __name__ == '__main__':

0 commit comments

Comments
 (0)