Exemplo n.º 1
0
def started_bootstrap(config, bootstrap):
    wait_for(
        string_contains(
            node_logs(bootstrap),
            "coop.rchain.node.NodeRuntime - Listening for traffic on rnode"),
        config.node_startup_timeout, "Bootstrap node didn't start correctly")
    yield bootstrap
Exemplo n.º 2
0
def started_star_network(config, star_network):
    for peer in star_network.peers:
        wait_for( string_contains(node_logs(peer),
                                  "coop.rchain.node.NodeRuntime - Listening for traffic on rnode"),
                  config.node_startup_timeout,
                  f"Peer node {peer.name} didn't start correctly")

    yield star_network
Exemplo n.º 3
0
def converged_network(config, started_rchain_network):
    wait_for(
        network_converged(started_rchain_network.bootstrap,
                          len(started_rchain_network.peers)),
        config.network_converge_timeout,
        "The network did NOT converge. Check container logs for issues. One or more containers might have failed to start or connect."
    )

    yield started_rchain_network
Exemplo n.º 4
0
def converged_complete_network(config, started_complete_network):
    for node in started_complete_network.nodes:
        wait_for(
            network_converged(node, len(started_complete_network.peers)),
            config.network_converge_timeout,
            "The network did NOT converge. Check container logs for issues. One or more containers might have failed to start or connect."
        )

    yield started_complete_network
Exemplo n.º 5
0
def test_casper_propose_and_deploy(config, converged_network):
    """
    This test represents an integration test that deploys a contract and then checks
    if all the nodes have received the block containing the contract.
    """

    token_size = 20

    contract_name = 'contract.rho'

    for node in converged_network.nodes:
        with log_box(logging.info, f"Run test on node '{node.name}'"):
            expected_string = f"<{node.container.name}:{random_string(token_size)}>"

            logging.info(f"Expected string: {expected_string}")

            copyfile(resources.file_path(contract_name, __name__),
                     f"{node.local_deploy_dir}/{contract_name}")

            exit_code, output = node.exec_run(
                f"sed -i -e 's/@placeholder@/{expected_string}/g' {node.remote_deploy_dir}/{contract_name}"
            )
            logging.debug(f"Sed result: {exit_code}, output: {output}")

            exit_code, output = node.deploy(contract_name)
            logging.debug(f"Deploy result: {exit_code}, output: {output}")

            logging.info(
                "Propose to blockchain previously deployed smart contracts.")

            exit_code, output = node.propose()
            logging.debug(f"Propose result: {exit_code}, output: {output}")

            logging.info(
                f"Check all peer logs for blocks containing {expected_string}")

            other_nodes = [
                n for n in converged_network.nodes
                if n.container.name != node.container.name
            ]

            for node in other_nodes:
                wait_for(
                    string_contains(show_blocks(node),
                                    expected_string), config.receive_timeout,
                    f"Container: {node.container.name}: String {expected_string} NOT found in blocks added."
                )

                logging.info(f"Container: {node.container.name}: SUCCESS!")
Exemplo n.º 6
0
def started_rchain_network(config, rchain_network):
    for peer in rchain_network.peers:
        assert wait_for( contains(container_logs(peer),
                                  "kamon.prometheus.PrometheusReporter - Started the embedded HTTP server on http://0.0.0.0:40403"),
                         config.node_startup_timeout), \
            "Prometeus port is not started "

    yield rchain_network
Exemplo n.º 7
0
def started_bootstrap(config, bootstrap):
    assert wait_for( contains( container_logs(bootstrap),
                               "coop.rchain.node.NodeRuntime - Starting stand-alone node."),
                     config.node_startup_timeout), \
        "Bootstrap node didn't start correctly"
    yield bootstrap