Exemplo n.º 1
0
def start_cluster(cmd: str, args: List[str]) -> clusterlib.ClusterLib:
    """Start cluster."""
    args_str = " ".join(args)
    args_str = f" {args_str}" if args_str else ""
    LOGGER.info(f"Starting cluster with `{cmd}{args_str}`.")
    helpers.run_in_bash(f"{cmd}{args_str}", workdir=get_cluster_env().work_dir)
    LOGGER.info("Cluster started.")
    return get_cluster_type().get_cluster_obj()
Exemplo n.º 2
0
def filtered_ledger_state(cluster_obj: clusterlib.ClusterLib, ) -> str:
    """Get filtered output of `query ledger-state`."""
    cardano_cmd = " ".join([
        "cardano-cli",
        "query",
        "ledger-state",
        *cluster_obj.magic_args,
        f"--{cluster_obj.protocol}-mode",
    ])
    # get rid of a huge amount of data we don't have any use for
    cmd = (
        f"{cardano_cmd} | jq -n --stream -c "
        "'fromstream(inputs|select((length == 2 and .[0][1] == \"esLState\")|not))'"
    )

    return helpers.run_in_bash(cmd).decode("utf-8").strip()
Exemplo n.º 3
0
def get_blocks_before(cluster_obj: clusterlib.ClusterLib, ) -> Dict[str, int]:
    """Get `blocksBefore` section of ledger state with bech32 encoded pool ids."""
    cardano_cmd = " ".join([
        "cardano-cli",
        "query",
        "ledger-state",
        *cluster_obj.magic_args,
        f"--{cluster_obj.protocol}-mode",
    ])
    # get rid of a huge amount of data we don't have any use for
    cmd = (
        f"{cardano_cmd} | jq -n --stream -c "
        "'fromstream(1|truncate_stream(inputs|select(.[0][0] == \"blocksBefore\")))'"
    )

    out_str = helpers.run_in_bash(cmd).decode("utf-8").strip()
    out_json: dict = json.loads(out_str)
    return {
        helpers.encode_bech32(prefix="pool", data=key): val
        for key, val in out_json.items()
    }
Exemplo n.º 4
0
def stop_cluster(cmd: str) -> None:
    """Stop cluster."""
    LOGGER.info(f"Stopping cluster with `{cmd}`.")
    helpers.run_in_bash(cmd, workdir=get_cluster_env().work_dir)
Exemplo n.º 5
0
    def test_testnet_whole_utxo(self, cluster: clusterlib.ClusterLib):
        """Check that it is possible to return the whole UTxO on testnets."""
        common.get_test_id(cluster)

        magic_args = " ".join(cluster.magic_args)
        helpers.run_in_bash(f"cardano-cli query utxo --whole-utxo {magic_args} > /dev/null")