forked from TrueCloudLab/frostfs-testcases
(#102): neofs-cli accounting balance test
Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
parent
f3f3f00d4a
commit
19f9d97328
7 changed files with 134 additions and 14 deletions
23
robot/resources/lib/cli_keywords.py
Normal file
23
robot/resources/lib/cli_keywords.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/python3.8
|
||||
|
||||
import pexpect
|
||||
|
||||
from robot.api.deco import keyword
|
||||
|
||||
ROBOT_AUTO_KEYWORDS = False
|
||||
|
||||
@keyword('Run Process And Enter Empty Password')
|
||||
def run_proccess_and_interact(cmd: str) -> str:
|
||||
p = pexpect.spawn(cmd)
|
||||
p.expect("[pP]assword")
|
||||
# enter empty password
|
||||
p.sendline('\r')
|
||||
p.wait()
|
||||
# throw a string with password prompt
|
||||
first = p.readline()
|
||||
# take all output
|
||||
child_output = p.readline()
|
||||
p.close()
|
||||
if p.exitstatus != 0:
|
||||
raise Exception(f"{first}\n{child_output}")
|
||||
return child_output
|
|
@ -3,6 +3,7 @@ Variables ../../variables/common.py
|
|||
|
||||
Library wallet_keywords.py
|
||||
Library rpc_call_keywords.py
|
||||
Library payment_neogo.py
|
||||
|
||||
*** Variables ***
|
||||
${TRANSFER_AMOUNT} = ${30}
|
||||
|
@ -43,3 +44,20 @@ Payment Operations
|
|||
|
||||
${NEOFS_BALANCE} = Get NeoFS Balance ${WIF}
|
||||
Should Be Equal As Numbers ${NEOFS_BALANCE} ${DEPOSIT_AMOUNT}
|
||||
|
||||
Prepare Wallet And Deposit
|
||||
[Arguments] ${DEPOSIT}
|
||||
|
||||
${WALLET} ${ADDR} ${WIF} = Init Wallet with Address ${ASSETS_DIR}
|
||||
${TX} = Transfer Mainnet Gas ${MAINNET_WALLET_WIF} ${ADDR} ${DEPOSIT+1}
|
||||
Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME}
|
||||
... Transaction accepted in block ${TX}
|
||||
|
||||
${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT}
|
||||
Wait Until Keyword Succeeds ${MAINNET_TIMEOUT} ${MAINNET_BLOCK_TIME}
|
||||
... Transaction accepted in block ${TX_DEPOSIT}
|
||||
# Now we have TX in main chain, but deposit might not propagate into the side chain yet.
|
||||
# For certainty, sleeping during one morph block.
|
||||
Sleep ${MORPH_BLOCK_TIME}
|
||||
|
||||
[Return] ${WALLET} ${ADDR} ${WIF}
|
||||
|
|
|
@ -5,6 +5,7 @@ import os
|
|||
import tarfile
|
||||
import uuid
|
||||
|
||||
from neo3 import wallet
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
from robot.libraries.BuiltIn import BuiltIn
|
||||
|
@ -42,3 +43,11 @@ def get_container_logs(testcase_name: str) -> None:
|
|||
tar.add(file_name)
|
||||
os.remove(file_name)
|
||||
tar.close()
|
||||
|
||||
@keyword('WIF to Binary')
|
||||
def wif_to_binary(wif: str) -> str:
|
||||
priv_key = wallet.Account.private_key_from_wif(wif)
|
||||
path = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
|
||||
with open(path, "wb") as f:
|
||||
f.write(priv_key)
|
||||
return path
|
||||
|
|
72
robot/testsuites/integration/cli/accounting/balance.robot
Normal file
72
robot/testsuites/integration/cli/accounting/balance.robot
Normal file
|
@ -0,0 +1,72 @@
|
|||
*** Settings ***
|
||||
Variables ../../../../variables/common.py
|
||||
|
||||
Library Collections
|
||||
Library Process
|
||||
Library String
|
||||
Library contract_keywords.py
|
||||
Library cli_keywords.py
|
||||
Library utility_keywords.py
|
||||
|
||||
Resource setup_teardown.robot
|
||||
Resource payment_operations.robot
|
||||
|
||||
*** Variables ***
|
||||
${DEPOSIT_AMOUNT} = ${10}
|
||||
|
||||
*** Test cases ***
|
||||
CLI Accounting Balance Test
|
||||
[Documentation] neofs-cli accounting balance test
|
||||
[Tags] NeoFSCLI Accounting
|
||||
[Timeout] 10 min
|
||||
|
||||
[Setup] Setup
|
||||
|
||||
${WALLET} ${ADDR} ${WIF} = Prepare Wallet And Deposit ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with WIF
|
||||
${OUTPUT} = Run Process neofs-cli accounting balance -r ${NEOFS_ENDPOINT} --wif ${WIF}
|
||||
... shell=True
|
||||
Should Be Equal As Numbers ${OUTPUT.stdout} ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with wallet and address
|
||||
${OUTPUT} = Run Process And Enter Empty Password
|
||||
... neofs-cli accounting balance -r ${NEOFS_ENDPOINT} --address ${ADDR} --wallet ${WALLET}
|
||||
Should Be Equal As Numbers ${OUTPUT} ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with wallet only
|
||||
${OUTPUT} = Run Process And Enter Empty Password
|
||||
... neofs-cli accounting balance -r ${NEOFS_ENDPOINT} --wallet ${WALLET}
|
||||
Should Be Equal As Numbers ${OUTPUT} ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with wallet and wrong address
|
||||
${ANOTHER_WALLET} ${ANOTHER_ADDR} ${ANOTHER_WIF} = Init Wallet With Address ${ASSETS_DIR}
|
||||
${OUTPUT} = Run Process neofs-cli accounting balance -r ${NEOFS_ENDPOINT} --address ${ANOTHER_ADDR} --wallet ${WALLET}
|
||||
... shell=True
|
||||
Should Be Equal As Strings ${OUTPUT.stderr} --address option must be specified and valid
|
||||
Should Be Equal As Numbers ${OUTPUT.rc} 1
|
||||
|
||||
# Getting balance with control API
|
||||
${CONFIG_PATH} = Write Control API Config ${NEOFS_ENDPOINT} ${WIF}
|
||||
${OUTPUT} = Run Process neofs-cli accounting balance --config ${CONFIG_PATH}
|
||||
... shell=True
|
||||
Should Be Equal As Numbers ${OUTPUT.stdout} ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with binary key
|
||||
${KEY_PATH} = WIF To Binary ${WIF}
|
||||
${OUTPUT} = Run Process neofs-cli accounting balance -r ${NEOFS_ENDPOINT} --binary-key ${KEY_PATH}
|
||||
... shell=True
|
||||
Should Be Equal As Numbers ${OUTPUT.stdout} ${DEPOSIT_AMOUNT}
|
||||
|
||||
[Teardown] Teardown cli_accounting_balance
|
||||
|
||||
*** Keywords ***
|
||||
|
||||
Write Control API Config
|
||||
[Documentation] Write YAML config for requesting NeoFS Control API via CLI
|
||||
[Arguments] ${ENDPOINT} ${WIF}
|
||||
|
||||
Set Local Variable ${PATH} ${ASSETS_DIR}/config.yaml
|
||||
Create File ${PATH} rpc: ${ENDPOINT}\nwif: ${WIF}
|
||||
|
||||
[Return] ${PATH}
|
|
@ -15,7 +15,7 @@ ${SN_02_ADDR} = s02.neofs.devenv:8080
|
|||
*** Test cases ***
|
||||
NetworkInfo RPC Method
|
||||
[Documentation] Testcase to check NetworkInfo RPC method.
|
||||
[Tags] RPC NeoFS NeoCLI NetworkInfo
|
||||
[Tags] RPC NeoFS NeoFSCLI NetworkInfo
|
||||
[Timeout] 10 min
|
||||
|
||||
[Setup] Setup
|
||||
|
@ -32,10 +32,10 @@ NetworkInfo RPC Method
|
|||
#############################################
|
||||
# Checking if morph magic number is relevant
|
||||
#############################################
|
||||
|
||||
|
||||
${NETWORK_MAGIC_S01} = Parse Magic ${RESULT1_S01.stdout}
|
||||
Should Be Equal ${NETWORK_MAGIC_S01} ${MORPH_MAGIC}
|
||||
|
||||
|
||||
${NETWORK_MAGIC_S02} = Parse Magic ${RESULT1_S02.stdout}
|
||||
Should Be Equal ${NETWORK_MAGIC_S02} ${MORPH_MAGIC}
|
||||
|
||||
|
@ -50,7 +50,7 @@ NetworkInfo RPC Method
|
|||
########################################
|
||||
# Ticking epoch and getting new netinfo
|
||||
########################################
|
||||
|
||||
|
||||
Tick Epoch
|
||||
|
||||
${RESULT2_S01} Run Process neofs-cli netmap netinfo -r ${SN_01_ADDR} --wif ${MAINNET_WALLET_WIF} shell=True
|
||||
|
@ -69,13 +69,13 @@ NetworkInfo RPC Method
|
|||
${NEW_EPOCH} = Evaluate ${EPOCH1_S01}+${1}
|
||||
Should Be Equal ${EPOCH2_S01} ${NEW_EPOCH}
|
||||
|
||||
|
||||
[Teardown] Teardown network_rpc_method
|
||||
|
||||
[Teardown] Teardown network_rpc_method
|
||||
|
||||
*** Keywords ***
|
||||
|
||||
Parse Magic
|
||||
[Arguments] ${RESULT_STDOUT}
|
||||
[Arguments] ${RESULT_STDOUT}
|
||||
@{MAGIC} = Split String ${RESULT_STDOUT} ${\n}
|
||||
${NETWORK_MAGIC} = Get From List ${MAGIC} ${1}
|
||||
@{MAGIC_INFO} = Split String ${NETWORK_MAGIC} ${SPACE}
|
||||
|
@ -83,7 +83,7 @@ Parse Magic
|
|||
[Return] ${MAGIC_VALUE}
|
||||
|
||||
Parse Epoch
|
||||
[Arguments] ${RESULT_STDOUT}
|
||||
[Arguments] ${RESULT_STDOUT}
|
||||
@{EPOCH} = Split String ${RESULT_STDOUT} ${\n}
|
||||
${NETWORK_EPOCH} = Get From List ${EPOCH} ${0}
|
||||
@{EPOCH_INFO} = Split String ${NETWORK_EPOCH} ${SPACE}
|
|
@ -6,10 +6,6 @@ RESOURCES="%s/resources/lib" % ROOT
|
|||
CERT="%s/../../ca" % ROOT
|
||||
KEYWORDS="%s/../../../neofs-keywords/robot/" % ROOT
|
||||
|
||||
# path from repo root is required for object put and get
|
||||
# in case when test is run from root in docker
|
||||
ABSOLUTE_FILE_PATH="/robot/testsuites/integration"
|
||||
|
||||
# Common NeoFS variables can be declared from neofs-dev-env env variables.
|
||||
# High priority is accepted for those envs.
|
||||
|
||||
|
@ -36,7 +32,7 @@ NEOFS_NEO_API_ENDPOINT = os.getenv("NEOFS_NEO_API_ENDPOINT", 'http://morph_chain
|
|||
HTTP_GATE = os.getenv("HTTP_GATE", 'http://http.neofs.devenv')
|
||||
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')
|
||||
GAS_HASH = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
|
||||
|
||||
NEOFS_CONTRACT = (os.getenv("NEOFS_CONTRACT") if os.getenv("NEOFS_CONTRACT")
|
||||
else os.getenv("NEOFS_IR_CONTRACTS_NEOFS", '008b43d3de8741b896015f79ac0fbfa4055b4574'))
|
||||
|
@ -46,4 +42,4 @@ COMMON_PLACEMENT_RULE = "REP 2 IN X CBF 1 SELECT 4 FROM * AS X"
|
|||
ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/")
|
||||
|
||||
MORPH_MAGIC = os.environ["MORPH_MAGIC"]
|
||||
GATE_PUB_KEY = '0313b1ac3a8076e155a7e797b24f0b650cccad5941ea59d7cfd51a024a8b2a06bf'
|
||||
GATE_PUB_KEY = '0313b1ac3a8076e155a7e797b24f0b650cccad5941ea59d7cfd51a024a8b2a06bf'
|
||||
|
|
|
@ -3,3 +3,5 @@ export NEOFS_MORPH_DISABLE_CACHE=true
|
|||
pushd ../neofs-dev-env
|
||||
export `make env`
|
||||
popd
|
||||
|
||||
export PYTHONPATH=${PYTHONPATH}:${VIRTUAL_ENV}/neofs-keywords/lib:${VIRTUAL_ENV}/neofs-keywords/robot:~/neofs-testcases/robot/resources/lib
|
||||
|
|
Loading…
Reference in a new issue