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 start_server( name: str, host: str, port: int, jsonrpc: str, faucet: str, disable_events_api: bool, import_diem_account_config_file: Optional[TextIO], logfile: Optional[str], ) -> None: logging.basicConfig(level=logging.INFO, format=log_format, filename=logfile) configure_testnet(jsonrpc, faucet) conf = AppConfig(name=name, server_conf=ServerConfig(host=host, port=port), disable_events_api=disable_events_api) if import_diem_account_config_file: conf.account_config = json.load(import_diem_account_config_file) print("Server Config: %s" % conf) client = testnet.create_client() print("Diem chain id: %s" % client.get_metadata().chain_id) conf.start(client).join()
def start_server( name: str, host: str, port: int, jsonrpc: str, faucet: str, enable_debug_api: bool, logfile: Optional[str] = None ) -> None: logging.basicConfig(level=logging.INFO, format=log_format, filename=logfile) configure_testnet(jsonrpc, faucet) conf = AppConfig(name=name, server_conf=ServerConfig(host=host, port=port), enable_debug_api=enable_debug_api) print("Server Config: %s" % conf) client = testnet.create_client() print("Diem chain id: %s" % client.get_metadata().chain_id) conf.start(client).join()
def test_wait_timeout_for_target_ready(runner: CliRunner) -> None: start = time.time() result = start_test( runner, ServerConfig(), [ "--wait-for-target-timeout", 1, "-k", "test_create_a_blank_account", ], ) assert result.exit_code == 1, result.output duration = time.time() - start assert duration < 2
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
async def start_stub_wallet( diem_client: AsyncClient ) -> AsyncGenerator[Tuple[AppConfig, App], None]: domain = generate_vasp_domain("stub") conf = AppConfig(name="stub-wallet", server_conf=ServerConfig(**dmw_stub_server()), vasp_domain=domain) account_conf = dmw_stub_diem_account_config() if account_conf: print("loads stub account config: %s" % account_conf) conf.account_config = json.loads(account_conf) hrp = dmw_stub_diem_account_hrp() if hrp: conf.account_config["hrp"] = hrp print("Start stub app with config %s" % conf) app, runner = await conf.start(diem_client) try: yield (conf, app) finally: await runner.cleanup()
def start_test(runner: CliRunner, conf: ServerConfig, options: List[str] = []) -> Result: stub_conf = ServerConfig() return runner.invoke( cli.test, [ "--target", conf.base_url, "--jsonrpc", testnet.JSON_RPC_URL, "--faucet", testnet.FAUCET_URL, "--stub-bind-host", "0.0.0.0", "--stub-bind-port", stub_conf.port, "--stub-diem-account-base-url", stub_conf.base_url, ] + options, )
def start_test(runner: CliRunner, conf: ServerConfig, options: List[str] = []) -> Result: stub_conf = ServerConfig() return runner.invoke( cli.test, [ "--target", conf.base_url, "--jsonrpc", testnet.JSON_RPC_URL, "--faucet", testnet.FAUCET_URL, "--pytest-args", "-k test_receive_payment_with_general_metadata_and_valid_from_and_to_subaddresses", "--stub-bind-host", "0.0.0.0", "--stub-bind-port", stub_conf.port, "--stub-diem-account-base-url", stub_conf.base_url, ] + options, )
async def start_server( name: str, host: str, port: int, diem_account_base_url: Optional[str], jsonrpc: str, faucet: str, disable_events_api: bool, import_diem_account_config_file: Optional[TextIO], logfile: Optional[str], hrp: str, ) -> None: logging.basicConfig(level=logging.INFO, format=log_format, filename=logfile) conf = AppConfig( name=name, server_conf=ServerConfig(host=host, port=port, base_url=diem_account_base_url or ""), disable_events_api=disable_events_api, ) if import_diem_account_config_file: conf.account_config = json.load(import_diem_account_config_file) if hrp: conf.account_config["hrp"] = hrp print("Server Config: %s" % conf) client = create_client() metadata = await client.get_metadata() print("Diem chain id: %s" % metadata.chain_id) _, runner = await conf.start(client) try: while True: await asyncio.sleep(3600) finally: await runner.cleanup()