示例#1
0
def test_eth_to_ceth_and_back_to_eth(
    basic_transfer_request: EthereumToSifchainTransferRequest,
    source_ethereum_address: str,
    rowan_source_integrationtest_env_credentials: SifchaincliCredentials,
    rowan_source_integrationtest_env_transfer_request:
    EthereumToSifchainTransferRequest,
    ethereum_network,
    smart_contracts_dir,
    rowan_amount,
    ceth_amount,
    bridgetoken_address,
):
    # logging.info("shark")
    # x = 4.9908339925e+18
    # s = "{:d}".format(int(x))
    # logging.info(f"xiss: {s}")
    # logging.info(f"xiss: {x}")
    # assert False
    basic_transfer_request.ethereum_address = source_ethereum_address
    basic_transfer_request.check_wait_blocks = True
    logging.info(f"rq: {basic_transfer_request}")
    request, credentials = generate_test_account(
        basic_transfer_request,
        rowan_source_integrationtest_env_transfer_request,
        rowan_source_integrationtest_env_credentials,
        target_ceth_balance=ceth_amount,
        target_rowan_balance=rowan_amount)
    # send some test account ceth back to a new ethereum address
    request.ethereum_address, _ = test_utilities.create_ethereum_address(
        smart_contracts_dir, ethereum_network)
    logging.info(f"get balance of test account")
    test_utilities.get_sifchain_addr_balance(
        request.sifchain_address,
        sifnodecli_node=request.sifnodecli_node,
        denom="ceth")
    logging.info(
        "send erowan back to ethereum chain, saving 100k for ceth transfer fees"
    )
    request.sifchain_symbol = "rowan"
    request.ethereum_symbol = bridgetoken_address
    request.amount = rowan_amount - 200000
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
    test_utilities.get_eth_balance(request)

    logging.info("send eth back to ethereum chain")
    logging.info("get ceth balance to decide how much to return")
    request.sifchain_symbol = "ceth"
    request.ethereum_symbol = "eth"
    ceth_balance = test_utilities.get_sifchain_addr_balance(
        request.sifchain_address,
        sifnodecli_node=request.sifnodecli_node,
        denom="ceth")
    request.amount = ceth_balance - request.ceth_amount
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
    logging.info("get final eth balance")
    test_utilities.get_eth_balance(request)
    test_utilities.get_sifchain_addr_balance(
        request.sifchain_address,
        sifnodecli_node=request.sifnodecli_node,
        denom="ceth")
示例#2
0
def test_eth_to_ceth_and_back_to_eth(
        basic_transfer_request: EthereumToSifchainTransferRequest,
        source_ethereum_address: str,
        rowan_source_integrationtest_env_credentials: SifchaincliCredentials,
        rowan_source_integrationtest_env_transfer_request:
    EthereumToSifchainTransferRequest, ethereum_network, smart_contracts_dir):
    basic_transfer_request.ethereum_address = source_ethereum_address
    basic_transfer_request.check_wait_blocks = True
    request, credentials = generate_test_account(
        basic_transfer_request,
        rowan_source_integrationtest_env_transfer_request,
        rowan_source_integrationtest_env_credentials,
        target_ceth_balance=10**17,
        target_rowan_balance=10**18)
    # send some test account ceth back to a new ethereum address
    request.ethereum_address, _ = test_utilities.create_ethereum_address(
        smart_contracts_dir, ethereum_network)
    request.amount = int(request.amount / 2)
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
示例#3
0
def test_eth_to_ceth_and_back_to_eth(
    basic_transfer_request: EthereumToSifchainTransferRequest,
    source_ethereum_address: str,
    rowan_source_integrationtest_env_credentials: SifchaincliCredentials,
    rowan_source_integrationtest_env_transfer_request:
    EthereumToSifchainTransferRequest,
    ethereum_network,
    smart_contracts_dir,
    bridgetoken_address,
    sifchain_fees_int,
):
    basic_transfer_request.ethereum_address = source_ethereum_address
    basic_transfer_request.check_wait_blocks = True
    small_amount = 100

    logging.info(
        "the test account needs enough rowan and ceth for one burn and one lock, make sure it has that"
    )
    request, credentials = generate_test_account(
        basic_transfer_request,
        rowan_source_integrationtest_env_transfer_request,
        rowan_source_integrationtest_env_credentials,
        target_ceth_balance=test_utilities.burn_gas_cost +
        test_utilities.lock_gas_cost + small_amount,
        target_rowan_balance=sifchain_fees_int * 2 + small_amount)
    # send some test account ceth back to a new ethereum address
    request.ethereum_address, _ = test_utilities.create_ethereum_address(
        smart_contracts_dir, ethereum_network)
    request.sifchain_symbol = "rowan"
    request.ethereum_symbol = bridgetoken_address
    request.amount = small_amount
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
    test_utilities.get_eth_balance(request)

    logging.info("send eth back to ethereum chain")
    request.sifchain_symbol = "ceth"
    request.ethereum_symbol = "eth"
    request.amount = small_amount
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)