single keyword for wallet initialization (#54)

Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
Anastasia Prasolova 2021-04-26 20:48:43 +03:00 committed by GitHub
parent 2f31e79327
commit 9c1d4b9b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 153 additions and 228 deletions

View file

@ -1,9 +1,18 @@
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
run: OUTPUT_DIR = artifacts/
KEYWORDS_PATH = ../neofs-keywords
KEYWORDS_REPO = git@github.com:nspcc-dev/neofs-keywords.git
run: deps
@echo "⇒ Test Run" @echo "⇒ Test Run"
@robot --timestampoutputs --outputdir artifacts/ robot/testsuites/integration/ @robot --timestampoutputs --outputdir $(OUTPUT_DIR) robot/testsuites/integration/
deps: $(KEYWORDS_PATH)
$(KEYWORDS_PATH):
@echo "Cloning keywords repo"
@git clone $(KEYWORDS_REPO) $(KEYWORDS_PATH)
help: help:
@echo "⇒ run Run testcases ${R}" @echo "⇒ run Run testcases ${R}"

View file

@ -30,6 +30,7 @@
4. Install Testcases dependencies 4. Install Testcases dependencies
- `pip3 install -r requirements.txt` - `pip3 install -r requirements.txt`
- `make deps`
(replace pip3 with the appropriate python package manager on the system). (replace pip3 with the appropriate python package manager on the system).
@ -37,6 +38,8 @@ Test cases are designed to run on Python 3.7+
### Run ### Run
0. Add keywords repo to PYTHONPATH `export PYTHONPATH=${PYTHONPATH}:~/neofs-keywords`
1. Execute the command `make run` 1. Execute the command `make run`
2. Logs will be available in the artifacts/ directory after tests with any of the statuses are completed. 2. Logs will be available in the artifacts/ directory after tests with any of the statuses are completed.

View file

@ -367,7 +367,6 @@ def container_existing(private_key: str, cid: str):
_find_cid(complProc.stdout, cid) _find_cid(complProc.stdout, cid)
return return
@keyword('Search object') @keyword('Search object')
def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: str, def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: str,
expected_objects_list=[], options:str=""): expected_objects_list=[], options:str=""):

View file

@ -23,46 +23,6 @@ ROBOT_AUTO_KEYWORDS = False
NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli') NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
NEOGO_CLI_EXEC = os.getenv('NEOGO_CLI_EXEC', 'neo-go') NEOGO_CLI_EXEC = os.getenv('NEOGO_CLI_EXEC', 'neo-go')
@keyword('Init wallet')
def init_wallet():
if not os.path.exists(TEMP_DIR):
os.makedirs(TEMP_DIR)
filename = os.getcwd() + '/' + TEMP_DIR + str(uuid.uuid4()) + ".json"
cmd = f"{NEOGO_CLI_EXEC} wallet init -w {filename}"
logger.info(f"Executing command: {cmd}")
stdout = _run_sh(cmd)
logger.info(f"wallet init succeeded with output: {stdout}")
return filename
@keyword('Generate wallet from WIF')
def generate_wallet_from_wif(wallet: str, wif: str):
cmd = f"{NEOGO_CLI_EXEC} wallet import --wallet {wallet} --wif {wif}"
out = _run_sh_wallet_gen(cmd)
logger.info(f"Command completed with output: {out}")
@keyword('Generate wallet')
def generate_wallet(wallet: str):
cmd = f"{NEOGO_CLI_EXEC} wallet create -w {wallet}"
out = _run_sh_wallet_gen(cmd)
logger.info(f"Command completed with output: {out}")
@keyword('Dump Address')
def dump_address(wallet: str):
with open(wallet) as json_file:
data = json.load(json_file)
if len(data['accounts']) != 0:
return data['accounts'][0]['address']
else:
raise Exception("Can not get address.")
@keyword('Dump PrivKey')
def dump_privkey(wallet: str, address: str):
cmd = f"{NEOGO_CLI_EXEC} wallet export -w {wallet} --decrypt {address}"
logger.info(f"Executing command: {cmd}")
out = _run_sh_with_passwd('\r', cmd)
logger.info(f"Command completed with output: {out}")
return out
@keyword('Transfer Mainnet Gas') @keyword('Transfer Mainnet Gas')
def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int, wallet_pass:str=''): def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int, wallet_pass:str=''):
cmd = ( cmd = (
@ -257,15 +217,6 @@ def _get_balance_request(privkey: str):
return output return output
def _run_sh(args):
complProc = subprocess.run(args, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
timeout=150, shell=True)
output, errors = complProc.stdout, complProc.stderr
if errors:
return errors
return output
def _run_sh_with_passwd(passwd, cmd): def _run_sh_with_passwd(passwd, cmd):
p = pexpect.spawn(cmd) p = pexpect.spawn(cmd)
p.expect(".*") p.expect(".*")
@ -275,20 +226,3 @@ def _run_sh_with_passwd(passwd, cmd):
# take a string with tx hash # take a string with tx hash
tx_hash = p.read().splitlines()[-1] tx_hash = p.read().splitlines()[-1]
return tx_hash.decode() return tx_hash.decode()
def _run_sh_wallet_gen(cmd):
'''
Internal method.
'''
logger.info(f"Executing command: {cmd}")
p = pexpect.spawn(cmd)
p.expect(".*")
p.sendline('\r')
p.expect(".*")
p.sendline('\r')
p.expect(".*")
p.sendline('\r')
p.wait()
out = p.read()
return out

View file

@ -1,3 +1,8 @@
*** Settings ***
Variables ../../../variables/common.py
Library ${KEYWORDS}/wallet.py
*** Variables *** *** Variables ***
${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X
@ -5,15 +10,8 @@ ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X
*** Keywords *** *** Keywords ***
Generate Keys Generate Keys
${WALLET} = Init wallet ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET} ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
${ADDR} = Dump Address ${WALLET}
${USER_KEY_GEN} = Dump PrivKey ${WALLET} ${ADDR}
${WALLET_OTH} = Init wallet
Generate wallet ${WALLET_OTH}
${ADDR_OTH} = Dump Address ${WALLET_OTH}
${OTHER_KEY_GEN} = Dump PrivKey ${WALLET_OTH} ${ADDR_OTH}
${SYSTEM_KEY_GEN} = Set Variable ${NEOFS_IR_WIF} ${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}

View file

@ -1,5 +1,9 @@
*** Variables *** *** Settings ***
Variables ../../../variables/common.py
Library ${KEYWORDS}/wallet.py
*** Variables ***
${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER} = key1=1,key2=abc
${FILE_USR_HEADER_DEL} = key1=del,key2=del ${FILE_USR_HEADER_DEL} = key1=del,key2=del
${FILE_OTH_HEADER} = key1=oth,key2=oth ${FILE_OTH_HEADER} = key1=oth,key2=oth
@ -10,15 +14,8 @@ ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X
Generate Keys Generate Keys
# Generate new wallets # Generate new wallets
${WALLET} = Init wallet ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET} ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
${ADDR} = Dump Address ${WALLET}
${USER_KEY_GEN} = Dump PrivKey ${WALLET} ${ADDR}
${WALLET_OTH} = Init wallet
Generate wallet ${WALLET_OTH}
${ADDR_OTH} = Dump Address ${WALLET_OTH}
${OTHER_KEY_GEN} = Dump PrivKey ${WALLET_OTH} ${ADDR_OTH}
# Get pre-defined keys # Get pre-defined keys
${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de ${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de

View file

@ -1,3 +1,8 @@
*** Settings ***
Variables ../../../variables/common.py
Library ${KEYWORDS}/wallet.py
*** Variables *** *** Variables ***
${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER} = key1=1,key2=abc
${FILE_USR_HEADER_DEL} = key1=del,key2=del ${FILE_USR_HEADER_DEL} = key1=del,key2=del
@ -7,15 +12,8 @@ ${RULE_FOR_ALL} = REP 2 IN X CBF 1 SELECT 4 FROM * AS X
*** Keywords *** *** Keywords ***
Generate Keys Generate Keys
${WALLET} = Init wallet ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET} ${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
${ADDR} = Dump Address ${WALLET}
${USER_KEY_GEN} = Dump PrivKey ${WALLET} ${ADDR}
${WALLET_OTH} = Init wallet
Generate wallet ${WALLET_OTH}
${ADDR_OTH} = Dump Address ${WALLET_OTH}
${OTHER_KEY_GEN} = Dump PrivKey ${WALLET_OTH} ${ADDR_OTH}
${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de ${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de

View file

@ -3,6 +3,7 @@ Variables ../../../variables/common.py
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
@ -73,16 +74,10 @@ Generate file
Set Global Variable ${FILE} ${FILE} Set Global Variable ${FILE} ${FILE}
Generate Key and Pre-payment Generate Key and Pre-payment
${WALLET} = Init wallet ${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET}
${ADDR} = Dump Address ${WALLET}
${USER_KEY_GEN} = Dump PrivKey ${WALLET} ${ADDR}
Set Global Variable ${PRIV_KEY} ${USER_KEY_GEN} Set Global Variable ${PRIV_KEY} ${USER_KEY_GEN}
Payment Operations ${WALLET} ${ADDR} ${PRIV_KEY} Payment Operations ${WALLET} ${ADDR} ${PRIV_KEY}
Payment Operations Payment Operations
[Arguments] ${WALLET} ${ADDR} ${KEY} [Arguments] ${WALLET} ${ADDR} ${KEY}

View file

@ -3,6 +3,7 @@ Variables ../../../variables/common.py
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
*** Test cases *** *** Test cases ***
@ -13,11 +14,7 @@ NeoFS Object Replication
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
${WALLET} = Init wallet ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET}
${ADDR} = Dump Address ${WALLET}
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 11 ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 11
Wait Until Keyword Succeeds 1 min 15 sec Wait Until Keyword Succeeds 1 min 15 sec
... Transaction accepted in block ${TX} ... Transaction accepted in block ${TX}

View file

@ -1,3 +1,8 @@
*** Settings ***
Variables ../../../variables/common.py
Library ${KEYWORDS}/wallet.py
*** Variables *** *** Variables ***
${FILE_USR_HEADER} = key1=1,key2=abc ${FILE_USR_HEADER} = key1=1,key2=abc
${FILE_USR_HEADER_OTH} = key1=2 ${FILE_USR_HEADER_OTH} = key1=2
@ -8,10 +13,7 @@ ${DEPOSIT_AMOUNT} = 10
*** Keywords *** *** Keywords ***
Payment operations Payment operations
${WALLET} = Init wallet ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET}
${ADDR} = Dump Address ${WALLET}
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_PATH} ${DEF_WALLET_ADDR} ${ADDR} ${TRANSFER_AMOUNT} ${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_PATH} ${DEF_WALLET_ADDR} ${ADDR} ${TRANSFER_AMOUNT}
Wait Until Keyword Succeeds ${BASENET_WAIT_TIME} ${BASENET_BLOCK_TIME} Wait Until Keyword Succeeds ${BASENET_WAIT_TIME} ${BASENET_BLOCK_TIME}

View file

@ -3,6 +3,7 @@ Variables ../../../variables/common.py
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
*** Variables *** *** Variables ***
@ -17,11 +18,7 @@ NeoFS Deposit and Withdraw
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
${WALLET} = Init wallet ${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
Generate wallet ${WALLET}
${ADDR} = Dump Address ${WALLET}
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 15 ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 15
Wait Until Keyword Succeeds 1 min 15 sec Wait Until Keyword Succeeds 1 min 15 sec
... Transaction accepted in block ${TX} ... Transaction accepted in block ${TX}

View file

@ -1,8 +1,11 @@
*** Settings *** *** Settings ***
Variables ../../../variables/common.py Variables ../../../variables/common.py
<<<<<<< HEAD
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
Library ../${RESOURCES}/gates.py Library ../${RESOURCES}/gates.py
Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
@ -13,11 +16,7 @@ NeoFS HTTP Gateway
[Timeout] 5 min [Timeout] 5 min
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
${WALLET} = Init wallet
Generate wallet ${WALLET}
${ADDR} = Dump Address ${WALLET}
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 6 ${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 6
Wait Until Keyword Succeeds 1 min 15 sec Wait Until Keyword Succeeds 1 min 15 sec

View file

@ -4,6 +4,7 @@ Library Collections
Library ../${RESOURCES}/neofs.py Library ../${RESOURCES}/neofs.py
Library ../${RESOURCES}/payment_neogo.py Library ../${RESOURCES}/payment_neogo.py
Library ../${RESOURCES}/gates.py Library ../${RESOURCES}/gates.py
Library ${KEYWORDS}/wallet.py
Library ../${RESOURCES}/utility_keywords.py Library ../${RESOURCES}/utility_keywords.py
@ -15,13 +16,8 @@ NeoFS S3 Gateway
[Setup] Create Temporary Directory [Setup] Create Temporary Directory
${PRIV_KEY} = Form WIF from String 1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb ${PRIV_KEY} = Form WIF from String 1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb
${WALLET} = Init wallet ${WALLET} ${ADDR} = Init Wallet from WIF ${TEMP_DIR} ${PRIV_KEY}
${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY}
Generate wallet from WIF ${WALLET} ${PRIV_KEY}
${ADDR} = Dump Address ${WALLET}
Dump PrivKey ${WALLET} ${ADDR}
${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY}
${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} 5 ${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} 5
Wait Until Keyword Succeeds 1 min 15 sec Wait Until Keyword Succeeds 1 min 15 sec
... Transaction accepted in block ${TX_DEPOSIT} ... Transaction accepted in block ${TX_DEPOSIT}

View file

@ -4,6 +4,7 @@ ROOT='../..'
RESOURCES="%s/resources/lib" % ROOT RESOURCES="%s/resources/lib" % ROOT
CERT="%s/../../ca" % ROOT CERT="%s/../../ca" % ROOT
KEYWORDS="%s/../../../neofs-keywords/" % ROOT
# path from repo root is required for object put and get # path from repo root is required for object put and get
# in case when test is run from root in docker # in case when test is run from root in docker