Esempio n. 1
0
def wait_for_block(network: ExonumNetwork, height: int = 1) -> None:
    """Wait for block at specific height"""
    for validator_id in range(network.validators_count()):
        host, public_port, private_port = network.api_address(validator_id)
        client = ExonumClient(host, public_port, private_port)
        for _ in range(RETRIES_AMOUNT):
            if client.public_api.get_block(height).status_code == 200:
                break
            time.sleep(0.5)
Esempio n. 2
0
def wait_api_to_start(network: ExonumNetwork) -> None:
    """Wait for api starting"""
    for validator_id in range(network.validators_count()):
        host, public_port, private_port = network.api_address(validator_id)
        client = ExonumClient(host, public_port, private_port)
        for _ in range(RETRIES_AMOUNT):
            try:
                client.public_api.health_info()
                break
            except ConnectionError:
                time.sleep(0.5)
Esempio n. 3
0
def launcher_networks(network: ExonumNetwork) -> List[Dict[str, Any]]:
    """Builds a network configuration for `exonum-launcher` from the
    `ExonumNetwork` object."""
    networks = []
    for validator_id in range(network.validators_count()):
        host, public_port, private_port = network.api_address(validator_id)
        node_network = {"host": host, "ssl": False, "public-api-port": public_port, "private-api-port": private_port}
        networks.append(node_network)

    # Temporary workaround: supervisor works in simple mode and we need only one node.
    return networks[:1]
Esempio n. 4
0
def launcher_networks(network: ExonumNetwork) -> List[Dict[str, Any]]:
    """Builds a network configuration for `exonum-launcher` from the
    `ExonumNetwork` object."""
    networks = []
    for validator_id in range(network.validators_count()):
        host, public_port, private_port = network.api_address(validator_id)
        node_network = {
            "host": host,
            "ssl": False,
            "public-api-port": public_port,
            "private-api-port": private_port
        }
        networks.append(node_network)

    return networks
Esempio n. 5
0
def wait_for_block(network: ExonumNetwork, height: int = 1) -> None:
    """Wait for block at specific height"""

    for validator_id in range(network.validators_count()):
        host, public_port, private_port = network.api_address(validator_id)
        client = ExonumClient(host, public_port, private_port)
        for _ in range(RETRIES_AMOUNT):
            try:
                block = client.public_api.get_block(height)
                if block.status_code == 200:
                    break
            except ConnectionError:
                pass
            time.sleep(0.5)
        else:
            raise Exception(f"Waiting for block {height} failed for validator {validator_id}")