From e0b0cbf8236e54778b955115af08c73eb8d23a4d Mon Sep 17 00:00:00 2001 From: anatoly-bogatyrev <45566606+anatoly-bogatyrev@users.noreply.github.com> Date: Wed, 26 May 2021 17:14:46 +0300 Subject: [PATCH] Update testcases for NeoFS 0.20.0 version and fix issues (#62) * update testcases for NeoFS 0.20.0 version * fix issues --- robot/resources/lib/neofs.py | 3 +- robot/resources/lib/payment_neogo.py | 29 ++++++++++--------- .../integration/network/replication.robot | 4 +-- .../object/common_steps_object.robot | 5 +--- robot/variables/common.py | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/robot/resources/lib/neofs.py b/robot/resources/lib/neofs.py index b7525fd..fdb038f 100644 --- a/robot/resources/lib/neofs.py +++ b/robot/resources/lib/neofs.py @@ -320,7 +320,8 @@ def get_range(private_key: str, cid: str, oid: str, range_file: str, bearer: str def create_container(private_key: str, basic_acl:str, rule:str): if rule == "": logger.error("Cannot create container with empty placement rule") - if basic_acl != "": + + if basic_acl: basic_acl = f"--basic-acl {basic_acl}" createContainerCmd = ( diff --git a/robot/resources/lib/payment_neogo.py b/robot/resources/lib/payment_neogo.py index 177f49b..1f603ab 100644 --- a/robot/resources/lib/payment_neogo.py +++ b/robot/resources/lib/payment_neogo.py @@ -9,6 +9,11 @@ import requests import json import os import tarfile +import sys + +sys.path.insert(0,'../neofs-keywords') +import converters +import wallet from robot.api.deco import keyword from robot.api import logger @@ -29,7 +34,7 @@ def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int cmd = ( f"{NEOGO_CLI_EXEC} contract invokefunction -w {wallet} -a {address} " f"-r {NEO_MAINNET_ENDPOINT} {NEOFS_CONTRACT} withdraw {scripthash} " - f"int:{amount} -- {scripthash}" + f"int:{amount} -- {scripthash}:Global" ) logger.info(f"Executing command: {cmd}") @@ -43,21 +48,19 @@ def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int @keyword('NeoFS Deposit') -def neofs_deposit(wallet: str, address: str, scripthash: str, amount: int, wallet_pass:str=''): - cmd = ( f"{NEOGO_CLI_EXEC} contract invokefunction -w {wallet} -a {address} " - f"-r {NEO_MAINNET_ENDPOINT} {NEOFS_CONTRACT} " - f"deposit {scripthash} int:{amount} bytes: -- {scripthash}") +def neofs_deposit(wallet_file: str, address: str, scripthash: str, amount: int, wallet_pass:str=''): - logger.info(f"Executing command: {cmd}") - out = _run_sh_with_passwd(wallet_pass, cmd) - logger.info(f"Command completed with output: {out}") + # 1) Get NeoFS contract address. + deposit_addr = converters.contract_hash_to_address(NEOFS_CONTRACT) + logger.info(f"deposit_addr: {deposit_addr}") - m = re.match(r'^Sent invocation transaction (\w{64})$', out) - if m is None: + # 2) Transfer GAS to the NeoFS contract address. + out = wallet.new_nep17_transfer(address, deposit_addr, amount, 'GAS', wallet_file, '', NEO_MAINNET_ENDPOINT) + + if len(out) != 64: raise Exception("Can not get Tx.") - tx = m.group(1) - return tx + return out @keyword('Transaction accepted in block') def transaction_accepted_in_block(tx_id): @@ -116,7 +119,7 @@ def get_balance(privkey: str): balance = _get_balance_request(privkey) - return balance + return float(balance) def _get_balance_request(privkey: str): diff --git a/robot/testsuites/integration/network/replication.robot b/robot/testsuites/integration/network/replication.robot index 468e466..71e926a 100644 --- a/robot/testsuites/integration/network/replication.robot +++ b/robot/testsuites/integration/network/replication.robot @@ -8,7 +8,7 @@ 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 *** @@ -34,7 +34,7 @@ NeoFS Object Replication Wait Until Keyword Succeeds 1 min 15 sec ... Transaction accepted in block ${TX_DEPOSIT} Get Transaction ${TX_DEPOSIT} - + ${CID} = Create container ${PRIV_KEY} ${EMPTY} ${PLACEMENT_RULE} Container Existing ${PRIV_KEY} ${CID} diff --git a/robot/testsuites/integration/object/common_steps_object.robot b/robot/testsuites/integration/object/common_steps_object.robot index 2df7d41..c4fc181 100644 --- a/robot/testsuites/integration/object/common_steps_object.robot +++ b/robot/testsuites/integration/object/common_steps_object.robot @@ -10,7 +10,6 @@ ${FILE_USR_HEADER_OTH} = key1=2 ${UNEXIST_OID} = B2DKvkHnLnPvapbDgfpU1oVUPuXQo5LTfKVxmNDZXQff ${TRANSFER_AMOUNT} = 15 ${DEPOSIT_AMOUNT} = 10 -${EMPTY_ACL} = "" *** Keywords *** @@ -37,11 +36,9 @@ Payment operations Set Global Variable ${ADDR} ${ADDR} Prepare container - ${CID} = Create container ${PRIV_KEY} ${EMPTY_ACL} ${COMMON_PLACEMENT_RULE} + ${CID} = Create container ${PRIV_KEY} ${EMPTY} ${COMMON_PLACEMENT_RULE} Container Existing ${PRIV_KEY} ${CID} - Wait Until Keyword Succeeds ${NEOFS_EPOCH_TIMEOUT} ${MORPH_BLOCK_TIME} - ${NEOFS_BALANCE} = Get NeoFS Balance ${PRIV_KEY} Should Be True ${NEOFS_BALANCE} < ${DEPOSIT_AMOUNT} ${CONTAINER_FEE} = Evaluate ${DEPOSIT_AMOUNT} - ${NEOFS_BALANCE} diff --git a/robot/variables/common.py b/robot/variables/common.py index ccba328..2738458 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -43,7 +43,7 @@ NEOFS_NETMAP = os.getenv("NEOFS_NETMAP", ['s01.neofs.devenv:8080', 's02.neofs.de GAS_HASH = os.getenv("GAS_HASH", '0xd2a4cff31913016155e38e474a2c06d08be276cf') NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT") - else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", 'cfe89912c457754b7eb1f89781dc74bb3e0070bf')) + else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", '008b43d3de8741b896015f79ac0fbfa4055b4574')) COMMON_PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 2 FROM * AS X"