Ejemplo n.º 1
0
def setup_currencies():
    owner_addr = get_required_env_var("OWNER_ADDR")
    user1_addr = get_required_env_var("USER1ADDR")
    print(f"adding eth to {owner_addr}")
    transact_ethereum_to_sifchain(owner_addr, "eth", amount_in_wei(10))
    print(f"adding eth to {user1_addr}")
    transact_ethereum_to_sifchain(user1_addr, "eth", amount_in_wei(13))
    time.sleep(15)
    send_from_sifchain_to_sifchain(owner_addr, user1_addr, amount_in_wei(23),
                                   "rowan",
                                   get_required_env_var("OWNER_PASSWORD"))
def test_cannot_create_two_currencies_with_the_same_name(
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
):
    new_account_key = get_shell_output("uuidgen").replace("-", "")
    new_currency = create_new_currency(amount_in_wei(10), new_account_key,
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    with pytest.raises(Exception):
        new_currency = create_new_currency(amount_in_wei(10), new_account_key,
                                           smart_contracts_dir,
                                           bridgebank_address,
                                           solidity_json_path)
def test_can_create_a_new_token_and_peg_it(
    token_length: int,
    basic_transfer_request: EthereumToSifchainTransferRequest,
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
    operator_address,
    ethereum_network,
    source_ethereum_address,
):
    new_account_key = (
        "a" + get_shell_output("uuidgen").replace("-", ""))[:token_length]
    token_name = new_account_key
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount=amount,
                                       symbol=new_account_key,
                                       token_name=token_name,
                                       decimals=18,
                                       smart_contracts_dir=smart_contracts_dir,
                                       bridgebank_address=bridgebank_address,
                                       solidity_json_path=solidity_json_path,
                                       operator_address=operator_address,
                                       ethereum_network=ethereum_network)
    request = build_request_for_new_sifchain_address(basic_transfer_request,
                                                     source_ethereum_address,
                                                     new_currency, amount / 10)
    burn_lock_functions.transfer_ethereum_to_sifchain(request)
def test_two_currencies_with_different_capitalization_should_not_interfere_with_each_other(
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
):
    new_account_key = (
        "a" + get_shell_output("uuidgen").replace("-", "").lower())[:5]
    amount = amount_in_wei(9)

    new_currency = create_new_currency(amount, new_account_key,
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    (request1,
     _) = build_request_for_new_sifchain_address(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
    balance_1 = get_sifchain_addr_balance(request1.sifchain_address,
                                          request1.sifnodecli_node,
                                          request1.sifchain_symbol)
    assert (balance_1 == request1.amount)

    new_currency = create_new_currency(amount, new_account_key.upper(),
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    (request2,
     _) = build_request_for_new_sifchain_address(new_currency, amount + 70000)
    burn_lock_functions.transfer_ethereum_to_sifchain(request2, 10)

    balance_1_again = get_sifchain_addr_balance(request1.sifchain_address,
                                                request1.sifnodecli_node,
                                                request1.sifchain_symbol)

    assert (balance_1 == balance_1_again)
def test_can_use_a_token_with_a_dash_in_the_name(
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
):
    n = "a-b"
    new_currency = create_new_currency(amount_in_wei(10), n,
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    (request, _) = build_request_for_new_sifchain_address(new_currency, 60000)
    burn_lock_functions.transfer_ethereum_to_sifchain(request, 10)
Ejemplo n.º 6
0
def test_can_create_a_new_token_with_a_long_name_and_peg_it(
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
):
    new_account_key = "ca36e47edfeb28489d8e110fb91d351bcd"
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount, new_account_key,
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    (request1, _) = build_request(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
def test_can_create_a_new_token_with_a_one_letter_name_and_peg_it(
    smart_contracts_dir,
    bridgebank_address,
    solidity_json_path,
):
    new_account_key = "a"
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount, new_account_key,
                                       smart_contracts_dir, bridgebank_address,
                                       solidity_json_path)
    (request1,
     _) = build_request_for_new_sifchain_address(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
def do_currency_test(
    new_currency_symbol,
    basic_transfer_request: EthereumToSifchainTransferRequest,
    source_ethereum_address: str,
    rowan_source_integrationtest_env_credentials: SifchaincliCredentials,
    rowan_source_integrationtest_env_transfer_request:
    EthereumToSifchainTransferRequest,
    ethereum_network,
    solidity_json_path,
):
    amount = amount_in_wei(9)
    logging.info(f"create new currency")
    new_currency = test_utilities.create_new_currency(
        amount,
        new_currency_symbol,
        new_currency_symbol,
        18,
        smart_contracts_dir=smart_contracts_dir,
        bridgebank_address=bridgebank_address,
        solidity_json_path=solidity_json_path)

    logging.info(
        f"create test account to use with new currency {new_currency_symbol}")
    basic_transfer_request.ethereum_address = source_ethereum_address
    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)
    test_amount = 39000
    logging.info(
        f"transfer some of the new currency {new_currency_symbol} to the test sifchain address"
    )
    request.ethereum_symbol = new_currency["newtoken_address"]
    request.sifchain_symbol = ("c" + new_currency["newtoken_symbol"]).lower()
    request.amount = test_amount
    burn_lock_functions.transfer_ethereum_to_sifchain(request)

    logging.info("send some new currency to ethereum")
    request.ethereum_address, _ = test_utilities.create_ethereum_address(
        smart_contracts_dir, ethereum_network)
    request.amount = test_amount - 1
    burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
Ejemplo n.º 9
0
def test_can_create_a_new_token_with_a_7_char_name_and_peg_it():
    new_account_key = ("a" + get_shell_output("uuidgen").replace("-", ""))[:7]
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount, new_account_key)
    (request1, _) = build_request(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
Ejemplo n.º 10
0
def test_can_create_a_new_token_with_a_long_name_and_peg_it():
    new_account_key = "ca36e47edfeb28489d8e110fb91d351bcd"
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount, new_account_key)
    (request1, _) = build_request(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
Ejemplo n.º 11
0
def test_can_create_a_new_token_with_a_one_letter_name_and_peg_it():
    new_account_key = "a"
    amount = amount_in_wei(9)
    new_currency = create_new_currency(amount, new_account_key)
    (request1, _) = build_request(new_currency, amount)
    burn_lock_functions.transfer_ethereum_to_sifchain(request1, 10)
Ejemplo n.º 12
0
def test_can_use_a_token_with_a_dash_in_the_name():
    n = "a-b"
    new_currency = create_new_currency(amount_in_wei(10), n)
    (request, _) = build_request(new_currency, 60000)
    burn_lock_functions.transfer_ethereum_to_sifchain(request, 10)
Ejemplo n.º 13
0
def test_cannot_create_two_currencies_with_the_same_name():
    new_account_key = get_shell_output("uuidgen").replace("-", "")
    create_new_currency(amount_in_wei(10), new_account_key)
    with pytest.raises(Exception):
        create_new_currency(amount_in_wei(10), new_account_key)
Ejemplo n.º 14
0
def test_cannot_create_two_currencies_that_only_differ_in_capitalization():
    new_account_key = get_shell_output("uuidgen").replace("-", "").lower()
    create_new_currency(amount_in_wei(10), new_account_key)
    with pytest.raises(Exception):
        create_new_currency(amount_in_wei(10), new_account_key.upper())