def start_target_server(runner: CliRunner, options: List[str] = []) -> ServerConfig: conf = ServerConfig(host="0.0.0.0") conf.base_url = "http://127.0.0.1:%s" % conf.port def start_server(): runner.invoke( cli.start_server, [ "--jsonrpc", testnet.JSON_RPC_URL, "--faucet", testnet.FAUCET_URL, "--host", conf.host, "--port", conf.port, "--diem-account-base-url", conf.base_url, ] + options, ) threading.Thread(target=start_server, daemon=True).start() utils.wait_for_port(conf.port) return conf
def test( target: str, stub_bind_host: Optional[str], stub_bind_port: Optional[int], stub_diem_account_base_url: Optional[str], jsonrpc: str, match_keywords: str, faucet: str, pytest_args: str, logfile: Optional[str], verbose: bool, import_stub_diem_account_config_file: Optional[TextIO], stub_hrp: Optional[str], wait_for_target_timeout: int, ) -> None: configure_testnet(jsonrpc, faucet) # If stub_bind_host is provided, then stub_diem_account_base_url must be as well or the test won't work if stub_bind_host is not None and stub_bind_host != "localhost" and not stub_diem_account_base_url: raise click.ClickException( "--stub-diem-account-base-url is required when passing in a custom --stub-bind-host" ) url = urlsplit(target) target_port = url.port or 80 print("Waiting for %s:%s ready" % (url.hostname, target_port)) utils.wait_for_port(target_port, host=str(url.hostname), timeout=wait_for_target_timeout) print("Target wallet at %s:%s is ready for connection" % (url.hostname, target_port)) args = shlex.split(pytest_args) args = ["--pyargs", "diem.testing.suites"] + args if match_keywords: args.append("-k") args.append(match_keywords) if verbose: args.append("--log-level=INFO") args.append("-s") args.append("-v") if logfile: args.append("--log-file=%s" % logfile) code = pytest.main(args) sys.stdout.flush() raise SystemExit(code)
def start_target_server(runner: CliRunner, options: List[str] = []) -> ServerConfig: conf = ServerConfig() def start_server(): runner.invoke( cli.start_server, [ "--jsonrpc", testnet.JSON_RPC_URL, "--faucet", testnet.FAUCET_URL, "--port", conf.port, ] + options, ) threading.Thread(target=start_server, daemon=True).start() utils.wait_for_port(conf.port) return conf