def test_request_faucet_coins( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest): basic_transfer_request.ethereum_address = source_ethereum_address basic_transfer_request.check_wait_blocks = True target_rowan_balance = 10**18 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=0, target_rowan_balance=target_rowan_balance) time.sleep(10) sifaddress = request.sifchain_address logging.info("get balances just to have those commands in the history") balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") get_faucet_balance(basic_transfer_request.sifnodecli_node) basic_transfer_request.amount = 10**17 basic_transfer_request.sifchain_symbol = "rowan" basic_transfer_request.sifchain_address = sifaddress request_faucet_coins(basic_transfer_request, credentials) time.sleep(10) get_faucet_balance(basic_transfer_request.sifnodecli_node) balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan")
def test_rowan_to_erowan( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest, ethereum_network, bridgetoken_address, smart_contracts_dir ): basic_transfer_request.ethereum_address = source_ethereum_address basic_transfer_request.check_wait_blocks = True target_rowan_balance = 10 ** 18 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=10 ** 18, target_rowan_balance=target_rowan_balance ) logging.info(f"send erowan to ethereum from test account") request.ethereum_address, _ = test_utilities.create_ethereum_address( smart_contracts_dir, ethereum_network ) request.sifchain_symbol = "rowan" request.ethereum_symbol = bridgetoken_address request.amount = int(target_rowan_balance / 2) burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials)
def test_create_pools( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest): basic_transfer_request.ethereum_address = source_ethereum_address basic_transfer_request.check_wait_blocks = True target_rowan_balance = 10**19 target_ceth_balance = 10**19 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=target_ceth_balance, target_rowan_balance=target_rowan_balance) sifaddress = request.sifchain_address # wait for balance test_utilities.wait_for_sifchain_addr_balance( sifaddress, "rowan", target_rowan_balance, basic_transfer_request.sifnodecli_node) test_utilities.wait_for_sifchain_addr_balance( sifaddress, "ceth", target_ceth_balance, basic_transfer_request.sifnodecli_node) pools = get_pools(basic_transfer_request.sifnodecli_node) change_amount = 10**18 sifchain_fees = 100000 # Should probably make this a constant basic_transfer_request.amount = change_amount basic_transfer_request.sifchain_symbol = "ceth" basic_transfer_request.sifchain_address = sifaddress current_ceth_balance = target_ceth_balance current_rowan_balance = target_rowan_balance # Only works the first time, fails later. Make this flexible for manual and private net testing for now. if pools is None: create_pool(basic_transfer_request, credentials) get_pools(basic_transfer_request.sifnodecli_node) current_ceth_balance = current_ceth_balance - change_amount current_rowan_balance = current_rowan_balance - change_amount - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "ceth") == current_ceth_balance) # check for failure if we try to create a pool twice txn = create_pool(basic_transfer_request, credentials) assert (txn["code"] == 14) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "ceth") == current_ceth_balance)
def test_rescue_ceth( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest, sifchain_fees_int, ethbridge_module_address, sifchain_admin_account ): """ does a lock of rowan (using another test) that should result in ceth being sent to a place it can be rescued from """ basic_transfer_request.ethereum_address = source_ethereum_address admin_user_credentials = SifchaincliCredentials( from_key=sifchain_admin_account ) small_amount = 100 test_account_request, test_account_credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request=rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials=rowan_source_integrationtest_env_credentials, target_ceth_balance=test_utilities.burn_gas_cost + small_amount, target_rowan_balance=sifchain_fees_int ) logging.info("get the starting balance for the ethbridge module - that's where fees should be going") ethbridge_module_balance = test_utilities.get_sifchain_addr_balance( ethbridge_module_address, basic_transfer_request.sifnodecli_node, "ceth" ) test_account_request.amount = small_amount burn_lock_functions.transfer_sifchain_to_ethereum(test_account_request, test_account_credentials) logging.info( f"test account {test_account_request.sifchain_address} should now have no ceth") logging.info("ethbridge should have the fee that was paid") test_utilities.wait_for_sifchain_addr_balance( ethbridge_module_address, "ceth", ethbridge_module_balance + test_utilities.burn_gas_cost, test_account_request.sifnodecli_node ) logging.info(f"rescue ceth into {test_account_request.sifchain_address}") test_utilities.rescue_ceth( receiver_account=test_account_request.sifchain_address, admin_account=sifchain_admin_account, amount=test_utilities.burn_gas_cost, transfer_request=basic_transfer_request, credentials=admin_user_credentials ) test_utilities.wait_for_sifchain_addr_balance( test_account_request.sifchain_address, "ceth", test_utilities.burn_gas_cost, test_account_request.sifnodecli_node, max_seconds=10, debug_prefix="wait for rescue ceth" )
def test_transfer_eth_to_ceth_without_a_validator_should_throw_exception( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, no_whitelisted_validators, ): with pytest.raises(Exception): basic_transfer_request.ethereum_address = source_ethereum_address return generate_minimal_test_account( base_transfer_request=basic_transfer_request, target_ceth_balance=10, timeout=5)
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)
def test_do_not_transfer_if_fee_allowed_is_too_low( 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, ): basic_transfer_request.ethereum_address = source_ethereum_address target_ceth_balance = 10**18 target_rowan_balance = 10**18 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=target_ceth_balance, target_rowan_balance=target_rowan_balance) # 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 = 31500 logging.info( "try to transfer rowan to erowan with a ceth_amount that's too low") with pytest.raises(Exception): request.ceth_amount = test_utilities.lock_gas_cost - 1 burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials) ending_ceth_balance = test_utilities.get_sifchain_addr_balance( request.sifchain_address, request.sifnodecli_node, "ceth") assert ending_ceth_balance == target_ceth_balance logging.info("try with not owning enough ceth to cover the offer") with pytest.raises(Exception): request.ceth_amount = target_ceth_balance + 1 burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials) ending_ceth_balance = test_utilities.get_sifchain_addr_balance( request.sifchain_address, request.sifnodecli_node, "ceth") assert ending_ceth_balance == target_ceth_balance
def test_fee_charged_to_transfer_rowan_to_erowan( 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, ): basic_transfer_request.ethereum_address = source_ethereum_address logging.info( f"credentials: {rowan_source_integrationtest_env_credentials}") request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=10**18, 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) logging.info( f"sending rowan to erowan and checking that a ceth fee was charged") request.sifchain_symbol = "rowan" request.ethereum_symbol = bridgetoken_address request.amount = 31500 # get the starting ceth balance, transfer some rowan to erowan, get the ending ceth # balance. The difference is the fee charged and should be equal to request.ceth_amount starting_ceth_balance = test_utilities.get_sifchain_addr_balance( request.sifchain_address, request.sifnodecli_node, "ceth") burn_lock_functions.transfer_sifchain_to_ethereum(request, credentials) ending_ceth_balance = test_utilities.get_sifchain_addr_balance( request.sifchain_address, request.sifnodecli_node, "ceth") fee = starting_ceth_balance - ending_ceth_balance assert fee == test_utilities.lock_gas_cost
def test_pools( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest, solidity_json_path): # max symbol length in clp is 10 new_currency_symbol = ("a" + get_shell_output("uuidgen").replace("-", ""))[:8] target_new_currency_balance = 5 * 10**18 logging.info(f"create new currency") new_currency = test_utilities.create_new_currency( 1000 * target_new_currency_balance, new_currency_symbol, smart_contracts_dir=smart_contracts_dir, bridgebank_address=bridgebank_address, solidity_json_path=solidity_json_path) sifchain_symbol = ("c" + new_currency["newtoken_symbol"]).lower() basic_transfer_request.ethereum_address = source_ethereum_address basic_transfer_request.check_wait_blocks = True target_rowan_balance = 5 * 10**18 target_ceth_balance = 10**18 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=target_ceth_balance, target_rowan_balance=target_rowan_balance) 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 = sifchain_symbol request.amount = target_new_currency_balance burn_lock_functions.transfer_ethereum_to_sifchain(request) sifaddress = request.sifchain_address sifchain_fees = 100000 # Should probably make this a constant #from_key = credentials.from_key # wait for balance test_utilities.wait_for_sifchain_addr_balance( sifaddress, "rowan", target_rowan_balance, basic_transfer_request.sifnodecli_node) test_utilities.wait_for_sifchain_addr_balance( sifaddress, sifchain_symbol, target_new_currency_balance, basic_transfer_request.sifnodecli_node) pools = get_pools(basic_transfer_request.sifnodecli_node) basic_transfer_request.sifchain_symbol = sifchain_symbol basic_transfer_request.sifchain_address = sifaddress current_coin_balance = target_new_currency_balance current_rowan_balance = target_rowan_balance change_amount = 10**19 basic_transfer_request.amount = change_amount # Fail if amount is greater than user has txn = create_pool(basic_transfer_request, credentials) assert (txn["code"] == 12) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) change_amount = 10**17 basic_transfer_request.amount = change_amount # Fail if amount is less than or equal to minimum txn = create_pool(basic_transfer_request, credentials) assert (txn["code"] == 7) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) change_amount = 10**18 basic_transfer_request.amount = change_amount # Only works the first time, fails later. txn = create_pool(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) get_pools(basic_transfer_request.sifnodecli_node) current_coin_balance = current_coin_balance - change_amount current_rowan_balance = current_rowan_balance - change_amount - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # check for failure if we try to create a pool twice txn = create_pool(basic_transfer_request, credentials) assert (txn["code"] == 14) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # ensure we can add liquidity, money gets transferred txn = add_pool_liquidity(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) get_pools(basic_transfer_request.sifnodecli_node) current_coin_balance = current_coin_balance - change_amount current_rowan_balance = current_rowan_balance - change_amount - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # check for failure if we try to remove all liquidity txn = remove_pool_liquidity(basic_transfer_request, credentials, 10000) assert (txn["code"] == 26) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # ensure we can remove liquidity, money gets transferred txn = remove_pool_liquidity(basic_transfer_request, credentials, 5000) assert (txn.get("code", 0) == 0) get_pools(basic_transfer_request.sifnodecli_node) current_coin_balance = current_coin_balance + change_amount current_rowan_balance = current_rowan_balance + change_amount - sifchain_fees #assert(test_utilities.get_sifchain_addr_balance(sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) #assert(test_utilities.get_sifchain_addr_balance(sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_ceth_balance) # no slippage if pool is perfectly balanced. # TODO: compute this precisely? slip_pct = 0.01 balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") slip_cost = (slip_pct * current_rowan_balance) assert (balance >= current_rowan_balance - slip_cost and balance <= current_rowan_balance + slip_cost) current_rowan_balance = balance balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) slip_cost = (slip_pct * current_coin_balance) assert (balance >= current_coin_balance - slip_cost and balance <= current_coin_balance + slip_cost) current_coin_balance = balance # check for failure if we try to add too much liquidity basic_transfer_request.amount = 10**19 txn = add_pool_liquidity(basic_transfer_request, credentials) assert (txn["code"] == 25) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # check for failure if we try to remove too much liquidity, only occurs now if not 100% liquidity provider """ txn = remove_pool_liquidity(basic_transfer_request, credentials, 10000) assert(txn["code"] == 3) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert(test_utilities.get_sifchain_addr_balance(sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert(test_utilities.get_sifchain_addr_balance(sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) """ # check for failure if we try to swap too much for user txn = swap_pool(basic_transfer_request, "rowan", sifchain_symbol, credentials) assert (txn["code"] == 27) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # check for failure if we try to swap too much for pool basic_transfer_request.amount = 5 * 10**17 txn = swap_pool(basic_transfer_request, "rowan", sifchain_symbol, credentials) assert (txn["code"] == 31) get_pools(basic_transfer_request.sifnodecli_node) current_rowan_balance = current_rowan_balance - sifchain_fees assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") == current_rowan_balance) assert (test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) == current_coin_balance) # now try to do a swap that works change_amount = 10**15 basic_transfer_request.amount = change_amount txn = swap_pool(basic_transfer_request, "rowan", sifchain_symbol, credentials) # TODO: compute this precisely? slip_pct = 0.01 balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") assert (balance < current_rowan_balance) current_rowan_balance = balance balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, sifchain_symbol) assert (balance > current_coin_balance) current_coin_balance = balance
def test_request_faucet_coins( basic_transfer_request: EthereumToSifchainTransferRequest, source_ethereum_address: str, rowan_source_integrationtest_env_credentials: SifchaincliCredentials, rowan_source_integrationtest_env_transfer_request: EthereumToSifchainTransferRequest, solidity_json_path, operator_address, ethereum_network): #Generate New Random Currency new_currency_symbol = ("a" + get_shell_output("uuidgen").replace("-", ""))[:8] target_new_currency_balance = 300000 new_currency = generate_new_currency(new_currency_symbol, target_new_currency_balance, solidity_json_path, operator_address, ethereum_network) sifchain_symbol = ("c" + new_currency["newtoken_symbol"]).lower() basic_transfer_request.ethereum_address = source_ethereum_address basic_transfer_request.check_wait_blocks = True target_rowan_balance = 10**18 request, credentials = generate_test_account( basic_transfer_request, rowan_source_integrationtest_env_transfer_request, rowan_source_integrationtest_env_credentials, target_ceth_balance=100, target_rowan_balance=target_rowan_balance) #Transfer Newly Generated Currency transfer_new_currency(request, sifchain_symbol, new_currency, target_new_currency_balance) sifaddress = request.sifchain_address logging.info("get balances just to have those commands in the history") balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") balance_ceth = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "ceth") balance_new_currency = test_utilities.get_sifchain_addr_balance( sifaddress, request.sifnodecli_node, sifchain_symbol) assert balance_new_currency == 300000, "new currency balance is wrong in the test account" assert balance_ceth == 100, "new ceth currency balance is wrong in the test account" assert balance == 10**18, "new rowan currency balance is wrong in the test account" logging.info(f"{sifchain_symbol} balance = {balance_new_currency}") logging.info(f"ceth balance = {balance_ceth}") logging.info(f"rowan balance = {balance}") #rowan start_faucet_rowan_balance = get_currency_faucet_balance( "rowan", get_faucet_balance(basic_transfer_request.sifnodecli_node)) logging.info(get_faucet_balance(basic_transfer_request.sifnodecli_node)) basic_transfer_request.amount = 50000 basic_transfer_request.sifchain_symbol = "rowan" basic_transfer_request.sifchain_address = sifaddress # add txn = add_faucet_coins(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) after_add_faucet_rowan_balance = get_currency_faucet_balance( "rowan", get_faucet_balance(basic_transfer_request.sifnodecli_node)) assert ( start_faucet_rowan_balance + 50000 == after_add_faucet_rowan_balance ), "faucet balance in rowan should be higher after adding coins to faucet" get_faucet_balance(basic_transfer_request.sifnodecli_node) # request basic_transfer_request.amount = 25000 txn = request_faucet_coins(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) after_request_faucet_rowan_balance = get_currency_faucet_balance( "rowan", get_faucet_balance(basic_transfer_request.sifnodecli_node)) assert ( start_faucet_rowan_balance + 25000 == after_request_faucet_rowan_balance ), "current faucet balance in rowan should be equal with the initial faucet balance + 25000" get_faucet_balance(basic_transfer_request.sifnodecli_node) balance = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "rowan") #ceth start_faucet_ceth_balance = get_currency_faucet_balance( "ceth", get_faucet_balance(basic_transfer_request.sifnodecli_node)) get_faucet_balance(basic_transfer_request.sifnodecli_node) basic_transfer_request.amount = 10 basic_transfer_request.sifchain_symbol = "ceth" basic_transfer_request.sifchain_address = sifaddress # add txn = add_faucet_coins(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) after_add_faucet_ceth_balance = get_currency_faucet_balance( "ceth", get_faucet_balance(basic_transfer_request.sifnodecli_node)) assert ( start_faucet_ceth_balance + 10 == after_add_faucet_ceth_balance ), "faucet balance in ceth should be higher after adding coins to faucet" get_faucet_balance(request.sifnodecli_node) # request basic_transfer_request.amount = 5 txn = request_faucet_coins(basic_transfer_request, credentials) assert (txn.get("code", 0) == 0) get_faucet_balance(basic_transfer_request.sifnodecli_node) balance_ceth = test_utilities.get_sifchain_addr_balance( sifaddress, basic_transfer_request.sifnodecli_node, "ceth") #random currency start_faucet_random_balance = get_currency_faucet_balance( sifchain_symbol, get_faucet_balance(request.sifnodecli_node)) get_faucet_balance(request.sifnodecli_node) request.amount = 20000 request.sifchain_symbol = sifchain_symbol request.sifchain_address = sifaddress # add txn = add_faucet_coins(request, credentials) assert (txn.get("code", 0) == 0) after_add_faucet_random_balance = get_currency_faucet_balance( sifchain_symbol, get_faucet_balance(request.sifnodecli_node)) assert ( start_faucet_random_balance + 20000 == after_add_faucet_random_balance ), "faucet balance in random currency should be higher after adding coins to faucet" get_faucet_balance(request.sifnodecli_node) balance_new_currency = test_utilities.get_sifchain_addr_balance( sifaddress, request.sifnodecli_node, sifchain_symbol) # request request.amount = 1000 txn = request_faucet_coins(request, credentials) assert (txn.get("code", 0) == 0) get_faucet_balance(request.sifnodecli_node) balance_new_currency = test_utilities.get_sifchain_addr_balance( sifaddress, request.sifnodecli_node, sifchain_symbol) #get faucet balances logging.info( "get remaining balances just to have those commands in the history") assert balance_new_currency == 281000, "new currency balance is wrong in the test account" assert balance_ceth == 95, "new ceth currency balance is wrong in the test account" assert balance == 999999999999575000, "new rowan currency balance is wrong in the test account" logging.info(f"{sifchain_symbol} balance = {balance_new_currency}") logging.info(f"ceth balance = {balance_ceth}") logging.info(f"rowan balance = {balance}") logging.info(get_faucet_balance(request.sifnodecli_node))