def test_gossip_proxy(intercepted_two_node_network):
    nodes = intercepted_two_node_network.docker_nodes
    node = nodes[0]

    tls_certificate_path = node.config.tls_certificate_local_path()
    tls_parameters = {
        "--certificate-file": tls_certificate_path,
        "--node-id": extract_common_name(tls_certificate_path),
    }
    cli = CLI(nodes[0], tls_parameters=tls_parameters)
    account = cli.node.genesis_account
    cli.set_default_deploy_args(
        "--from",
        account.public_key_hex,
        "--private-key",
        cli.private_key_path(account),
        "--public-key",
        cli.public_key_path(account),
        "--payment",
        cli.resource(Contract.STANDARD_PAYMENT),
        "--payment-args",
        cli.payment_json,
    )
    cli("deploy", "--session", cli.resource(Contract.HELLO_NAME_DEFINE))
    block_hash = cli("propose")
    wait_for_block_hash_propagated_to_all_nodes(nodes, block_hash)
def check_upgrades_applied(network):
    node = network.docker_nodes[0]

    cmd = "ls -la /etc/casperlabs /root/.casperlabs/chainspec /root/.casperlabs/chainspec/genesis"
    rc, output = node.exec_run(cmd)
    logging.info(f"============================ {cmd} => {rc}")
    logging.info(f"============================ [")
    logging.info(f"============================ {output}")
    logging.info(f"============================ ]")

    cli = CLI(network.docker_nodes[0], "casperlabs_client")
    account = cli.node.test_account

    cli.set_default_deploy_args(
        "--from", account.public_key_hex,
        "--private-key", cli.private_key_path(account),
        "--public-key", cli.public_key_path(account)
    )

    # First deploy
    deploy_hash = cli("deploy", "--payment-amount", 10000000, "--session", cli.resource(Contract.COUNTER_DEFINE))
    get_cost_and_block_hash(node, deploy_hash)

    # When activation-point-rank of an upgrade is reached, and upgrade is executed,
    # the cost of execution should change.

    # We have spec of genesis, upgrade-1 and upgrade-2 in our custom chainspec
    # (in integration-testing/resources/test-chainspec)
    # Upgrades change cost of executing opcodes, so cost of execution of the same contract should change
    # after the upgrades are applied.
    costs = []
    versions = []

    # Currently test-chainspec activation points configured like below:

    # upgrade-1/manifest.toml:activation-point-rank = 20
    # upgrade-2/manifest.toml:activation-point-rank = 30

    # So, a number of deploys above 30 should be enough to activate both upgrades.
    offset = 2  # First deploy after genesis
    upgrade_1 = 20
    upgrade_2 = 30

    for i in range(1, 35):
        position = i + offset
        if position == upgrade_1 or position == upgrade_2:
            logging.info(f'Redeploying contract at position {position}')
            deploy_hash = cli("deploy", "--payment-amount", 10000000, "--session", cli.resource(Contract.COUNTER_DEFINE))
            get_cost_and_block_hash(node, deploy_hash)
            # Add up, as another deploy shifts the block position
            offset += 1

        deploy_hash = cli("deploy", "--payment-amount", 10000000, "--session", cli.resource(Contract.COUNTER_CALL))
        cost, block_hash = get_cost_and_block_hash(node, deploy_hash)
        if cost not in costs:
            logging.info(f"Execution cost at iteration {i}, is {cost}. ")
            costs.append(cost)
            version = cli("show-block", block_hash).summary.header.protocol_version
            versions.append(version)

    logging.info(f"Costs of execution: {' '.join(str(c) for c in costs)}")
    logging.info(f"Versions: {' '.join(str(v) for v in versions)}")
    return costs