Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Improve functional_tests_rpc startup #9763

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions tests/functional_tests/functional_tests_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import socket
import string
import os
import time

USAGE = 'usage: functional_tests_rpc.py <python> <srcdir> <builddir> [<tests-to-run> | all]'
DEFAULT_TESTS = [
Expand Down Expand Up @@ -120,23 +121,26 @@ def kill():
except: pass

# wait for error/startup
for i in range(10):
time.sleep(1)
all_open = True
for port in ports:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
if s.connect_ex(('127.0.0.1', port)) != 0:
all_open = False
break
startup_timeout = 10
deadline = time.monotonic() + startup_timeout
for port in ports:
addr = ('127.0.0.1', port)
delay = 0
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
while True:
timeout = deadline - time.monotonic() - delay
if timeout <= 0:
print('Failed to start wallet or daemon')
kill()
sys.exit(1)
time.sleep(delay)
s.settimeout(timeout)
if s.connect_ex(addr) == 0:
break
delay = .1
finally:
s.close()
if all_open:
break

if not all_open:
print('Failed to start wallet or daemon')
kill()
sys.exit(1)

# online daemons need some time to connect to peers to be ready
time.sleep(2)
Expand Down
Loading