diff --git a/robot/resources/lib/payment_neogo.py b/robot/resources/lib/payment_neogo.py index db0e7b79..177f49b5 100644 --- a/robot/resources/lib/payment_neogo.py +++ b/robot/resources/lib/payment_neogo.py @@ -23,22 +23,6 @@ ROBOT_AUTO_KEYWORDS = False NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') NEOGO_CLI_EXEC = os.getenv('NEOGO_CLI_EXEC', 'neo-go') -@keyword('Transfer Mainnet Gas') -def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int, wallet_pass:str=''): - cmd = ( - f"{NEOGO_CLI_EXEC} wallet nep17 transfer -w {wallet} " - f"-r {NEO_MAINNET_ENDPOINT} --from {address} --to {address_to} " - f"--token GAS --amount {amount}" - ) - - logger.info(f"Executing command: {cmd}") - out = _run_sh_with_passwd(wallet_pass, cmd) - logger.info(f"Command completed with output: {out}") - - if not re.match(r'^(\w{64})$', out): - raise Exception("Can not get Tx.") - - return out @keyword('Withdraw Mainnet Gas') def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int): @@ -57,49 +41,6 @@ def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int tx = m.group(1) return tx -@keyword('Mainnet Balance') -def mainnet_balance(address: str): - headers = {'Content-type': 'application/json'} - data = { "jsonrpc": "2.0", "id": 5, "method": "getnep17balances", "params": [ address ] } - response = requests.post(NEO_MAINNET_ENDPOINT, json=data, headers=headers, verify=False) - - if not response.ok: - raise Exception(f"""Failed: - request: {data}, - response: {response.text}, - status code: {response.status_code} {response.reason}""") - - m = re.search(rf'"{GAS_HASH}","amount":"([\d\.]+)"', response.text) - if not m: - raise Exception("Can not get mainnet gas balance. Output: %s" % response.text ) - else: - logger.info("Output: %s" % response.text) - amount = m.group(1) - return amount - -@keyword('Expected Mainnet Balance') -def expected_mainnet_balance(address: str, expected: float): - amount = mainnet_balance(address) - gas_expected = int(expected * 10**8) - if int(amount) != int(gas_expected): - raise Exception(f"Expected amount ({gas_expected}) of GAS has not been found. Found {amount}.") - return amount - -@keyword('Expected Mainnet Balance Diff') -def expected_mainnet_balance_diff(address: str, old_value: float, expected_diff: float): - amount = mainnet_balance(address) - gas_expected = old_value + _convert_int_to_gas(expected_diff) - if int(amount) != int(gas_expected): - raise Exception(f"Balance amount ({int(amount)})) of GAS has not been changed for expected value:", - f"{_convert_int_to_gas(expected_diff)} from initial {old_value}.", - f"Expected: {old_value + _convert_int_to_gas(expected_diff)}") - return amount - -def _convert_int_to_gas(input_value: float): - return int(input_value * 10**8) - -def _convert_gas_to_int(input_value: float): - return int(input_value / 10**8) @keyword('NeoFS Deposit') def neofs_deposit(wallet: str, address: str, scripthash: str, amount: int, wallet_pass:str=''): @@ -166,7 +107,7 @@ def get_transaction(tx_id: str): logger.info(response.text) -@keyword('Get Balance') +@keyword('Get NeoFS Balance') def get_balance(privkey: str): """ This function returns NeoFS balance for selected public key. @@ -177,24 +118,6 @@ def get_balance(privkey: str): return balance -@keyword('Expected Balance') -def expected_balance(privkey: str, init_amount: float, deposit_size: float): - """ - This function returns NeoFS balance for selected public key. - :param public_key: neo public key - :param init_amount: initial number of tokens in the account - :param deposit_size: expected amount of the balance increasing - """ - - balance = _get_balance_request(privkey) - - deposit_change = round((float(balance) - init_amount),8) - if deposit_change != deposit_size: - raise Exception('Expected deposit increase: {}. This does not correspond to the actual change in account: {}'.format(deposit_size, deposit_change)) - - logger.info('Expected deposit increase: {}. This correspond to the actual change in account: {}'.format(deposit_size, deposit_change)) - - return deposit_change def _get_balance_request(privkey: str): ''' diff --git a/robot/resources/lib/utility_keywords.py b/robot/resources/lib/utility_keywords.py index 892c36ea..403b5cf6 100644 --- a/robot/resources/lib/utility_keywords.py +++ b/robot/resources/lib/utility_keywords.py @@ -12,7 +12,8 @@ from robot.api import logger from common import * ROBOT_AUTO_KEYWORDS = False - +# TODO: get this variable from env +LOGS_DIR = 'artifacts/' @keyword('Generate file of bytes') def generate_file_of_bytes(size: str) -> str: @@ -30,12 +31,12 @@ def generate_file_of_bytes(size: str) -> str: @keyword('Get Docker Logs') def get_container_logs(testcase_name: str) -> None: client = docker.APIClient(base_url='unix://var/run/docker.sock') - tar_name = f"artifacts/dockerlogs({testcase_name}).tar.gz" + tar_name = f"{LOGS_DIR}/dockerlogs({testcase_name}).tar.gz" tar = tarfile.open(tar_name, "w:gz") for container in client.containers(): container_name = container['Names'][0][1:] if client.inspect_container(container_name)['Config']['Domainname'] == "neofs.devenv": - file_name = f"artifacts/docker_log_{container_name}" + file_name = f"{LOGS_DIR}/docker_log_{container_name}" with open(file_name,'wb') as out: out.write(client.logs(container_name)) logger.info(f"Collected logs from container {container_name}") diff --git a/robot/testsuites/integration/acl/common_steps_acl_basic.robot b/robot/testsuites/integration/acl/common_steps_acl_basic.robot index cd7d3dea..49e38e02 100644 --- a/robot/testsuites/integration/acl/common_steps_acl_basic.robot +++ b/robot/testsuites/integration/acl/common_steps_acl_basic.robot @@ -1,10 +1,12 @@ *** Settings *** Variables ../../../variables/common.py -Library ${KEYWORDS}/wallet.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X +${TRANSFER_AMOUNT} = ${3} *** Keywords *** @@ -31,11 +33,12 @@ Generate Keys Payment Operations [Arguments] ${WALLET} ${ADDR} ${KEY} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 3 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} 3 Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 3 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${KEY} diff --git a/robot/testsuites/integration/acl/common_steps_acl_bearer.robot b/robot/testsuites/integration/acl/common_steps_acl_bearer.robot index 74c7b9c6..972ab7ab 100644 --- a/robot/testsuites/integration/acl/common_steps_acl_bearer.robot +++ b/robot/testsuites/integration/acl/common_steps_acl_bearer.robot @@ -1,13 +1,15 @@ *** Settings *** Variables ../../../variables/common.py -Library ${KEYWORDS}/wallet.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** ${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER_DEL} = key1=del,key2=del ${FILE_OTH_HEADER} = key1=oth,key2=oth ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X +${TRANSFER_AMOUNT} = ${3} *** Keywords *** @@ -36,11 +38,12 @@ Generate Keys Payment Operations [Arguments] ${WALLET} ${ADDR} ${KEY} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 3 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${TRANSFER_AMOUNT} Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 3 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${KEY} diff --git a/robot/testsuites/integration/acl/common_steps_acl_extended.robot b/robot/testsuites/integration/acl/common_steps_acl_extended.robot index f6b44fa8..13c34dad 100644 --- a/robot/testsuites/integration/acl/common_steps_acl_extended.robot +++ b/robot/testsuites/integration/acl/common_steps_acl_extended.robot @@ -1,24 +1,26 @@ *** Settings *** Variables ../../../variables/common.py -Library ${KEYWORDS}/wallet.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** ${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER_DEL} = key1=del,key2=del ${FILE_OTH_HEADER} = key1=oth,key2=oth ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X +${TRANSFER_AMOUNT} = ${3} *** Keywords *** Generate Keys - ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} - ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} + ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} + ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR} ${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de ${SYSTEM_KEY_GEN} = Set Variable ${NEOFS_IR_WIF} - ${SYSTEM_KEY_GEN_SN} = Set Variable ${NEOFS_SN_WIF} + ${SYSTEM_KEY_GEN_SN} = Set Variable ${NEOFS_SN_WIF} Set Global Variable ${USER_KEY} ${USER_KEY_GEN} Set Global Variable ${OTHER_KEY} ${OTHER_KEY_GEN} @@ -33,12 +35,13 @@ Generate Keys Payment Operations [Arguments] ${WALLET} ${ADDR} ${KEY} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 3 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} 3 Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 3 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${KEY} diff --git a/robot/testsuites/integration/network/netmap_simple.robot b/robot/testsuites/integration/network/netmap_simple.robot index 196e2d7b..98f2ff9e 100644 --- a/robot/testsuites/integration/network/netmap_simple.robot +++ b/robot/testsuites/integration/network/netmap_simple.robot @@ -3,8 +3,12 @@ Variables ../../../variables/common.py Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/payment_neogo.py -Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py + +*** Variables *** +${TRANSFER_AMOUNT} = ${11} *** Test cases *** @@ -81,11 +85,12 @@ Generate Key and Pre-payment Payment Operations [Arguments] ${WALLET} ${ADDR} ${KEY} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 11 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${TRANSFER_AMOUNT} Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 11 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${KEY} diff --git a/robot/testsuites/integration/network/replication.robot b/robot/testsuites/integration/network/replication.robot index 2e7f2fff..468e4660 100644 --- a/robot/testsuites/integration/network/replication.robot +++ b/robot/testsuites/integration/network/replication.robot @@ -3,11 +3,13 @@ Variables ../../../variables/common.py Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/payment_neogo.py -Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** -${PLACEMENT_RULE} = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X" +${PLACEMENT_RULE} = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X" +${TRANSFER_AMOUNT} = ${11} *** Test cases *** NeoFS Object Replication @@ -18,11 +20,13 @@ NeoFS Object Replication [Setup] Create Temporary Directory ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 11 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${TRANSFER_AMOUNT} Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 11 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} + ${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY} @@ -71,5 +75,3 @@ NeoFS Object Replication Cleanup Cleanup Files Get Docker Logs replication - - diff --git a/robot/testsuites/integration/object/common_steps_object.robot b/robot/testsuites/integration/object/common_steps_object.robot index 639152cd..2df7d41c 100644 --- a/robot/testsuites/integration/object/common_steps_object.robot +++ b/robot/testsuites/integration/object/common_steps_object.robot @@ -1,7 +1,8 @@ *** Settings *** Variables ../../../variables/common.py -Library ${KEYWORDS}/wallet.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** ${FILE_USR_HEADER} = key1=1,key2=abc @@ -15,22 +16,22 @@ ${EMPTY_ACL} = "" Payment operations ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR} - ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_PATH} ${DEF_WALLET_ADDR} ${ADDR} ${TRANSFER_AMOUNT} + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${TRANSFER_AMOUNT} - Wait Until Keyword Succeeds ${BASENET_WAIT_TIME} ${BASENET_BLOCK_TIME} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} ${TRANSFER_AMOUNT} + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY} ${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} ${DEPOSIT_AMOUNT} - Wait Until Keyword Succeeds ${BASENET_WAIT_TIME} ${BASENET_BLOCK_TIME} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} ... Transaction accepted in block ${TX_DEPOSIT} - Get Transaction ${TX_DEPOSIT} - ${BALANCE} = Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME} - ... Expected Balance ${PRIV_KEY} 0 ${DEPOSIT_AMOUNT} + ${NEOFS_BALANCE} = Get NeoFS Balance ${PRIV_KEY} + Should Be Equal As Numbers ${NEOFS_BALANCE} ${DEPOSIT_AMOUNT} Set Global Variable ${PRIV_KEY} ${PRIV_KEY} Set Global Variable ${ADDR} ${ADDR} @@ -40,6 +41,10 @@ Prepare container Container Existing ${PRIV_KEY} ${CID} Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME} - ... Expected Balance ${PRIV_KEY} ${DEPOSIT_AMOUNT} ${NEOFS_CREATE_CONTAINER_GAS_FEE} + + ${NEOFS_BALANCE} = Get NeoFS Balance ${PRIV_KEY} + Should Be True ${NEOFS_BALANCE} < ${DEPOSIT_AMOUNT} + ${CONTAINER_FEE} = Evaluate ${DEPOSIT_AMOUNT} - ${NEOFS_BALANCE} + Log Container fee is ${CONTAINER_FEE} Set Global Variable ${CID} ${CID} diff --git a/robot/testsuites/integration/payment/withdraw.robot b/robot/testsuites/integration/payment/withdraw.robot index cba2cf66..226978b2 100644 --- a/robot/testsuites/integration/payment/withdraw.robot +++ b/robot/testsuites/integration/payment/withdraw.robot @@ -3,12 +3,14 @@ Variables ../../../variables/common.py Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/payment_neogo.py -Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** -${DEPOSIT_AMOUNT} = 10 -${WITHDRAW_AMOUNT} = 10 +${DEPOSIT_AMOUNT} = ${10} +${WITHDRAW_AMOUNT} = ${10} +${TRANSFER_AMOUNT} = ${15} *** Test cases *** NeoFS Deposit and Withdraw @@ -19,45 +21,57 @@ NeoFS Deposit and Withdraw [Setup] Create Temporary Directory ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 15 - Wait Until Keyword Succeeds 1 min 15 sec - ... Transaction accepted in block ${TX} - Get Transaction ${TX} - ${MAINNET_BALANCE} = Expected Mainnet Balance ${ADDR} 15 - ${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY} + ########################################################## + # Transferring GAS from initial wallet to our test wallet + ########################################################## + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${TRANSFER_AMOUNT} + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} + ... Transaction accepted in block ${TX} + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} + ############################ + # Making deposit into NeoFS + ############################ ${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} ${DEPOSIT_AMOUNT} - Wait Until Keyword Succeeds 1 min 15 sec + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} ... Transaction accepted in block ${TX_DEPOSIT} - Get Transaction ${TX_DEPOSIT} + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + ${EXPECTED_BALANCE} = Evaluate ${TRANSFER_AMOUNT}-${DEPOSIT_AMOUNT} + Should Be True ${MAINNET_BALANCE} < ${EXPECTED_BALANCE} + ${DEPOSIT_FEE} = Evaluate ${EXPECTED_BALANCE} - ${MAINNET_BALANCE} + Log Deposit fee is ${DEPOSIT_FEE} + ${NEOFS_BALANCE} = Get NeoFS Balance ${PRIV_KEY} + Should Be Equal As Numbers ${NEOFS_BALANCE} ${DEPOSIT_AMOUNT} - # Expected amount diff will be formed from deposit amount and contract fee - ${EXPECTED_DIFF} = Evaluate -${DEPOSIT_AMOUNT}-${NEOFS_CONTRACT_DEPOSIT_GAS_FEE} - ${DEPOSIT_BALANCE} = Expected Mainnet Balance Diff ${ADDR} ${MAINNET_BALANCE} ${EXPECTED_DIFF} - - ${NEOFS_BALANCE} = Get Balance ${PRIV_KEY} + # TODO: try to withdraw more than was deposited + ########################### + # Withdrawing deposit back + ########################### ${TX} = Withdraw Mainnet Gas ${WALLET} ${ADDR} ${SCRIPT_HASH} ${WITHDRAW_AMOUNT} - Wait Until Keyword Succeeds 1 min 15 sec + Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME} ... Transaction accepted in block ${TX} Sleep ${NEOFS_CONTRACT_CACHE_TIMEOUT} - Get Balance ${PRIV_KEY} - Mainnet Balance ${ADDR} + ${NEOFS_BALANCE} = Get NeoFS Balance ${PRIV_KEY} + ${EXPECTED_BALANCE} = Evaluate ${DEPOSIT_AMOUNT} - ${WITHDRAW_AMOUNT} + Should Be Equal As Numbers ${NEOFS_BALANCE} ${EXPECTED_BALANCE} - Expected Balance ${PRIV_KEY} ${NEOFS_BALANCE} -${WITHDRAW_AMOUNT} - - # Expected amount diff will be formed from withdrawal amount and contract fee - ${EXPECTED_DIFF_W} = Evaluate ${WITHDRAW_AMOUNT}-${NEOFS_CONTRACT_WITHDRAW_GAS_FEE} - Expected Mainnet Balance Diff ${ADDR} ${DEPOSIT_BALANCE} ${EXPECTED_DIFF_W} + ${MAINNET_BALANCE_AFTER} = Get Mainnet Balance ${ADDR} + ${MAINNET_BALANCE_DIFF} = Evaluate ${MAINNET_BALANCE_AFTER} - ${MAINNET_BALANCE} + Should Be True ${MAINNET_BALANCE_DIFF} < ${WITHDRAW_AMOUNT} + ${WITHDRAW_FEE} = Evaluate ${WITHDRAW_AMOUNT} - ${MAINNET_BALANCE_DIFF} + Log Withdraw fee is ${WITHDRAW_FEE} [Teardown] Cleanup + *** Keywords *** Cleanup diff --git a/robot/testsuites/integration/services/http_gate.robot b/robot/testsuites/integration/services/http_gate.robot index 96b41322..91d00d09 100644 --- a/robot/testsuites/integration/services/http_gate.robot +++ b/robot/testsuites/integration/services/http_gate.robot @@ -4,11 +4,13 @@ Variables ../../../variables/common.py Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/gates.py -Library ${KEYWORDS}/wallet.py Library ../${RESOURCES}/utility_keywords.py +Library ${KEYWORDS}/wallet_keywords.py +Library ${KEYWORDS}/rpc_call_keywords.py *** Variables *** ${PLACEMENT_RULE} = "REP 1 IN X CBF 1 SELECT 1 FROM * AS X" +${TRANSFER_AMOUNT} = ${3} *** Test cases *** @@ -18,12 +20,13 @@ NeoFS HTTP Gateway [Setup] Create Temporary Directory ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR} - ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 6 + ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} 6 Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX} - Get Transaction ${TX} - Expected Mainnet Balance ${ADDR} 6 + + ${MAINNET_BALANCE} = Get Mainnet Balance ${ADDR} + Should Be Equal As Numbers ${MAINNET_BALANCE} ${TRANSFER_AMOUNT} ${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY} diff --git a/robot/variables/common.py b/robot/variables/common.py index 248746f2..ccba328c 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -10,36 +10,30 @@ KEYWORDS="%s/../../../neofs-keywords/" % ROOT # in case when test is run from root in docker ABSOLUTE_FILE_PATH="/robot/testsuites/integration" -# Price of the contract Deposit/Withdraw execution: -MAINNET_WALLET_PATH = os.getenv("MAINNET_WALLET_PATH", "wallets/wallet.json") -NEOFS_CONTRACT_DEPOSIT_GAS_FEE = os.getenv("NEOFS_CONTRACT_DEPOSIT_GAS_FEE", "0.1679897") -NEOFS_CONTRACT_WITHDRAW_GAS_FEE = os.getenv("NEOFS_CONTRACT_WITHDRAW_GAS_FEE", "0.0382514") -NEOFS_CREATE_CONTAINER_GAS_FEE = os.getenv("NEOFS_CREATE_CONTAINER_GAS_FEE", "-1e-08") +# Common NeoFS variables can be declared from neofs-dev-env env variables. +# High priority is accepted for those envs. -# NEOFS_EPOCH_TIMEOUT can be declared from neofs-dev-env env variables as NEOFS_IR_TIMERS_EPOCH -# (high priority is accepted for env as NEOFS_EPOCH_TIMEOUT) NEOFS_EPOCH_TIMEOUT = (os.getenv("NEOFS_EPOCH_TIMEOUT") if os.getenv("NEOFS_EPOCH_TIMEOUT") else os.getenv("NEOFS_IR_TIMERS_EPOCH", "300s")) -BASENET_BLOCK_TIME = os.getenv('BASENET_BLOCK_TIME', "15s") -BASENET_WAIT_TIME = os.getenv("BASENET_WAIT_TIME", "1min") -MORPH_BLOCK_TIME = os.getenv("MORPH_BLOCK_TIME", '1s') -NEOFS_CONTRACT_CACHE_TIMEOUT = os.getenv("NEOFS_CONTRACT_CACHE_TIMEOUT", "30s") -NEOFS_IR_WIF = os.getenv("NEOFS_IR_WIF", "KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY") -NEOFS_SN_WIF = os.getenv("NEOFS_SN_WIF", "Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s") -DEF_WALLET_ADDR = os.getenv("DEF_WALLET_ADDR", "NVUzCUvrbuWadAm6xBoyZ2U7nCmS9QBZtb") SIMPLE_OBJ_SIZE = os.getenv("SIMPLE_OBJ_SIZE", "1024") COMPLEX_OBJ_SIZE = os.getenv("COMPLEX_OBJ_SIZE", "70000000") -NEOFS_ENDPOINT = os.getenv("NEOFS_ENDPOINT", "s01.neofs.devenv:8080") -NEOGO_CLI_PREFIX = os.getenv("NEOGO_CLI_PREFIX", "docker exec -it main_chain neo-go") -# NEO_MAINNET_ENDPOINT can be declared from neofs-dev-env env variables as NEOFS_IR_MAINNET_ENDPOINT_CLIENT -# (high priority is accepted for env as NEO_MAINNET_ENDPOINT) +MAINNET_BLOCK_TIME = os.getenv('MAINNET_BLOCK_TIME', "15s") +MAINNET_TIMEOUT = os.getenv('MAINNET_TIMEOUT', "1min") +MORPH_BLOCK_TIME = os.getenv("MORPH_BLOCK_TIME", '1s') +NEOFS_CONTRACT_CACHE_TIMEOUT = os.getenv("NEOFS_CONTRACT_CACHE_TIMEOUT", "30s") + +NEOFS_IR_WIF = os.getenv("NEOFS_IR_WIF", "KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY") +NEOFS_SN_WIF = os.getenv("NEOFS_SN_WIF", "Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s") +MAINNET_WALLET_WIF = os.getenv("MAINNET_WALLET_WIF", "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr") + +NEOFS_ENDPOINT = os.getenv("NEOFS_ENDPOINT", "s01.neofs.devenv:8080") +NEOGO_CLI_EXEC = os.getenv("NEOGO_CLI_EXEC", "neo-go") + NEO_MAINNET_ENDPOINT = (os.getenv("NEO_MAINNET_ENDPOINT") if os.getenv("NEO_MAINNET_ENDPOINT") else os.getenv("NEOFS_IR_MAINNET_ENDPOINT_CLIENT", 'http://main_chain.neofs.devenv:30333')) -# NEOFS_NEO_API_ENDPOINT can be declared from neofs-dev-env env variables as NEOFS_IR_MORPH_ENDPOINT_CLIENT -# (high priority is accepted for env as NEOFS_NEO_API_ENDPOINT) NEOFS_NEO_API_ENDPOINT = (os.getenv("NEOFS_NEO_API_ENDPOINT") if os.getenv("NEOFS_NEO_API_ENDPOINT") else os.getenv("NEOFS_IR_MORPH_ENDPOINT_CLIENT", 'http://morph_chain.neofs.devenv:30333')) @@ -48,8 +42,6 @@ S3_GATE = os.getenv("S3_GATE", 'https://s3.neofs.devenv:8080') NEOFS_NETMAP = os.getenv("NEOFS_NETMAP", ['s01.neofs.devenv:8080', 's02.neofs.devenv:8080','s03.neofs.devenv:8080','s04.neofs.devenv:8080']) GAS_HASH = os.getenv("GAS_HASH", '0xd2a4cff31913016155e38e474a2c06d08be276cf') -# NEOFS_CONTRACT can be declared from neofs-dev-env env variables as NEOFS_IR_CONTRACTS_NEOFS -# (high priority is accepted for env as NEOFS_CONTRACT) NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT") else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", 'cfe89912c457754b7eb1f89781dc74bb3e0070bf')) diff --git a/wallets/wallet.json b/wallets/wallet.json deleted file mode 100644 index 40dcbfc5..00000000 --- a/wallets/wallet.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"3.0","accounts":[{"address":"NVUzCUvrbuWadAm6xBoyZ2U7nCmS9QBZtb","key":"6PYLKJhiSub5imt6WCVy6Quxtd9xu176omev1vWYovzkAQCTSQabAAQXii","label":"","contract":{"script":"DCEDGmxvu98CyjUXRfqGubpalFLXhaxPf8K3VIyipGxPz0pBdHR2qg==","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}} \ No newline at end of file