Skip to content

Commit b9e76f1

Browse files
committed
rpc: Add test for -rpcwaittimeout
Suggested-by: Jon Atack <@jonatack>
1 parent f76cb10 commit b9e76f1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/functional/interface_bitcoin_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
from test_framework.test_framework import BitcoinTestFramework
1111
from test_framework.util import (
1212
assert_equal,
13+
assert_greater_than_or_equal,
1314
assert_raises_process_error,
1415
assert_raises_rpc_error,
1516
get_auth_cookie,
1617
)
18+
import time
1719

1820
# The block reward of coinbaseoutput.nValue (50) BTC/block matures after
1921
# COINBASE_MATURITY (100) blocks. Therefore, after mining 101 blocks we expect
@@ -248,6 +250,12 @@ def run_test(self):
248250
self.nodes[0].wait_for_rpc_connection()
249251
assert_equal(blocks, BLOCKS + 25)
250252

253+
self.log.info("Test -rpcwait option waits at most -rpcwaittimeout seconds for startup")
254+
self.stop_node(0) # stop the node so we time out
255+
start_time = time.time()
256+
assert_raises_process_error(1, "Could not connect to the server", self.nodes[0].cli('-rpcwait', '-rpcwaittimeout=5').echo)
257+
assert_greater_than_or_equal(time.time(), start_time + 5)
258+
251259

252260
if __name__ == '__main__':
253261
TestBitcoinCli().main()

0 commit comments

Comments
 (0)