forked from TrueCloudLab/frostfs-testcases
single keyword for wallet initialization (#54)
Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
parent
2f31e79327
commit
9c1d4b9b07
14 changed files with 153 additions and 228 deletions
15
Makefile
15
Makefile
|
@ -1,9 +1,18 @@
|
|||
.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"
|
||||
@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:
|
||||
@echo "⇒ run Run testcases ${R}"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
4. Install Testcases dependencies
|
||||
- `pip3 install -r requirements.txt`
|
||||
- `make deps`
|
||||
|
||||
(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
|
||||
|
||||
0. Add keywords repo to PYTHONPATH `export PYTHONPATH=${PYTHONPATH}:~/neofs-keywords`
|
||||
|
||||
1. Execute the command `make run`
|
||||
|
||||
2. Logs will be available in the artifacts/ directory after tests with any of the statuses are completed.
|
||||
|
|
|
@ -367,7 +367,6 @@ def container_existing(private_key: str, cid: str):
|
|||
_find_cid(complProc.stdout, cid)
|
||||
return
|
||||
|
||||
|
||||
@keyword('Search object')
|
||||
def search_object(private_key: str, cid: str, keys: str, bearer: str, filters: str,
|
||||
expected_objects_list=[], options:str=""):
|
||||
|
|
|
@ -23,46 +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('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')
|
||||
def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int, wallet_pass:str=''):
|
||||
cmd = (
|
||||
|
@ -257,15 +217,6 @@ def _get_balance_request(privkey: str):
|
|||
|
||||
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):
|
||||
p = pexpect.spawn(cmd)
|
||||
p.expect(".*")
|
||||
|
@ -275,20 +226,3 @@ def _run_sh_with_passwd(passwd, cmd):
|
|||
# take a string with tx hash
|
||||
tx_hash = p.read().splitlines()[-1]
|
||||
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
|
|
@ -1,3 +1,8 @@
|
|||
*** Settings ***
|
||||
Variables ../../../variables/common.py
|
||||
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
|
||||
*** Variables ***
|
||||
${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 ***
|
||||
|
||||
Generate Keys
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${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}
|
||||
${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
|
||||
${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
|
||||
|
||||
${SYSTEM_KEY_GEN} = Set Variable ${NEOFS_IR_WIF}
|
||||
${SYSTEM_KEY_GEN_SN} = Set Variable ${NEOFS_SN_WIF}
|
||||
|
|
|
@ -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_DEL} = key1=del,key2=del
|
||||
${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 new wallets
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${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}
|
||||
${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
|
||||
${WALLET_OTH} ${ADDR_OTH} ${OTHER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
|
||||
|
||||
# Get pre-defined keys
|
||||
${EACL_KEY_GEN} = Form WIF from String 782676b81a35c5f07325ec523e8521ee4946b6e5d4c6cd652dd0c3ba51ce03de
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
*** Settings ***
|
||||
Variables ../../../variables/common.py
|
||||
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
|
||||
*** Variables ***
|
||||
${FILE_USR_HEADER} = key1=1,key2=abc
|
||||
${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 ***
|
||||
Generate Keys
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${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}
|
||||
${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
|
||||
|
|
|
@ -3,6 +3,7 @@ Variables ../../../variables/common.py
|
|||
|
||||
Library ../${RESOURCES}/neofs.py
|
||||
Library ../${RESOURCES}/payment_neogo.py
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
Library ../${RESOURCES}/utility_keywords.py
|
||||
|
||||
|
||||
|
@ -73,16 +74,10 @@ Generate file
|
|||
Set Global Variable ${FILE} ${FILE}
|
||||
|
||||
Generate Key and Pre-payment
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
${USER_KEY_GEN} = Dump PrivKey ${WALLET} ${ADDR}
|
||||
|
||||
${WALLET} ${ADDR} ${USER_KEY_GEN} = Init Wallet with Address ${TEMP_DIR}
|
||||
Set Global Variable ${PRIV_KEY} ${USER_KEY_GEN}
|
||||
|
||||
Payment Operations ${WALLET} ${ADDR} ${PRIV_KEY}
|
||||
|
||||
|
||||
Payment Operations
|
||||
[Arguments] ${WALLET} ${ADDR} ${KEY}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ Variables ../../../variables/common.py
|
|||
|
||||
Library ../${RESOURCES}/neofs.py
|
||||
Library ../${RESOURCES}/payment_neogo.py
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
Library ../${RESOURCES}/utility_keywords.py
|
||||
|
||||
*** Test cases ***
|
||||
|
@ -13,11 +14,7 @@ NeoFS Object Replication
|
|||
|
||||
[Setup] Create Temporary Directory
|
||||
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
|
||||
|
||||
${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
|
||||
${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 11
|
||||
Wait Until Keyword Succeeds 1 min 15 sec
|
||||
... Transaction accepted in block ${TX}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
*** Settings ***
|
||||
Variables ../../../variables/common.py
|
||||
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
|
||||
*** Variables ***
|
||||
${FILE_USR_HEADER} = key1=1,key2=abc
|
||||
${FILE_USR_HEADER_OTH} = key1=2
|
||||
|
@ -8,10 +13,7 @@ ${DEPOSIT_AMOUNT} = 10
|
|||
*** Keywords ***
|
||||
|
||||
Payment operations
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
|
||||
${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
|
||||
${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_PATH} ${DEF_WALLET_ADDR} ${ADDR} ${TRANSFER_AMOUNT}
|
||||
|
||||
Wait Until Keyword Succeeds ${BASENET_WAIT_TIME} ${BASENET_BLOCK_TIME}
|
||||
|
|
|
@ -3,6 +3,7 @@ Variables ../../../variables/common.py
|
|||
|
||||
Library ../${RESOURCES}/neofs.py
|
||||
Library ../${RESOURCES}/payment_neogo.py
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
Library ../${RESOURCES}/utility_keywords.py
|
||||
|
||||
*** Variables ***
|
||||
|
@ -17,11 +18,7 @@ NeoFS Deposit and Withdraw
|
|||
|
||||
[Setup] Create Temporary Directory
|
||||
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
|
||||
|
||||
${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}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
*** Settings ***
|
||||
Variables ../../../variables/common.py
|
||||
<<<<<<< HEAD
|
||||
|
||||
Library ../${RESOURCES}/neofs.py
|
||||
Library ../${RESOURCES}/payment_neogo.py
|
||||
Library ../${RESOURCES}/gates.py
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
Library ../${RESOURCES}/utility_keywords.py
|
||||
|
||||
|
||||
|
@ -13,11 +16,7 @@ NeoFS HTTP Gateway
|
|||
[Timeout] 5 min
|
||||
|
||||
[Setup] Create Temporary Directory
|
||||
|
||||
${WALLET} = Init wallet
|
||||
Generate wallet ${WALLET}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
${PRIV_KEY} = Dump PrivKey ${WALLET} ${ADDR}
|
||||
${WALLET} ${ADDR} ${PRIV_KEY} = Init Wallet with Address ${TEMP_DIR}
|
||||
${TX} = Transfer Mainnet Gas wallets/wallet.json ${DEF_WALLET_ADDR} ${ADDR} 6
|
||||
|
||||
Wait Until Keyword Succeeds 1 min 15 sec
|
||||
|
|
|
@ -4,6 +4,7 @@ Library Collections
|
|||
Library ../${RESOURCES}/neofs.py
|
||||
Library ../${RESOURCES}/payment_neogo.py
|
||||
Library ../${RESOURCES}/gates.py
|
||||
Library ${KEYWORDS}/wallet.py
|
||||
Library ../${RESOURCES}/utility_keywords.py
|
||||
|
||||
|
||||
|
@ -15,13 +16,8 @@ NeoFS S3 Gateway
|
|||
[Setup] Create Temporary Directory
|
||||
|
||||
${PRIV_KEY} = Form WIF from String 1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb
|
||||
${WALLET} = Init wallet
|
||||
|
||||
Generate wallet from WIF ${WALLET} ${PRIV_KEY}
|
||||
${ADDR} = Dump Address ${WALLET}
|
||||
Dump PrivKey ${WALLET} ${ADDR}
|
||||
${WALLET} ${ADDR} = Init Wallet from WIF ${TEMP_DIR} ${PRIV_KEY}
|
||||
${SCRIPT_HASH} = Get ScriptHash ${PRIV_KEY}
|
||||
|
||||
${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} 5
|
||||
Wait Until Keyword Succeeds 1 min 15 sec
|
||||
... Transaction accepted in block ${TX_DEPOSIT}
|
||||
|
|
|
@ -4,6 +4,7 @@ ROOT='../..'
|
|||
|
||||
RESOURCES="%s/resources/lib" % ROOT
|
||||
CERT="%s/../../ca" % ROOT
|
||||
KEYWORDS="%s/../../../neofs-keywords/" % ROOT
|
||||
|
||||
# path from repo root is required for object put and get
|
||||
# in case when test is run from root in docker
|
||||
|
|
Loading…
Reference in a new issue