forked from TrueCloudLab/frostfs-testcases
part of [#194] Get ScriptHash with address
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
parent
c8a5a63791
commit
3ffa4f4534
5 changed files with 37 additions and 31 deletions
|
@ -18,13 +18,6 @@ ROBOT_AUTO_KEYWORDS = False
|
|||
NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
|
||||
|
||||
|
||||
# TODO: move to neofs-keywords
|
||||
@keyword('Get ScriptHash')
|
||||
def get_scripthash(wif: str):
|
||||
acc = wallet.Account.from_wif(wif, '')
|
||||
return str(acc.script_hash)
|
||||
|
||||
|
||||
@keyword('Verify Head Tombstone')
|
||||
def verify_head_tombstone(wallet_path: str, cid: str, oid_ts: str, oid: str):
|
||||
header = neofs_verbs.head_object(wallet_path, cid, oid_ts)
|
||||
|
|
|
@ -8,9 +8,10 @@ from common import (MAINNET_WALLET_PATH, MORPH_ENDPOINT,
|
|||
import rpc_client
|
||||
import contract
|
||||
import converters
|
||||
import wallet
|
||||
from wallet import nep17_transfer
|
||||
from wrappers import run_sh_with_passwd_contract
|
||||
from converters import load_wallet
|
||||
from neo3 import wallet
|
||||
|
||||
from robot.api.deco import keyword
|
||||
from robot.api import logger
|
||||
|
@ -31,7 +32,10 @@ mainnet_rpc_cli = rpc_client.RPCClient(NEO_MAINNET_ENDPOINT)
|
|||
|
||||
|
||||
@keyword('Withdraw Mainnet Gas')
|
||||
def withdraw_mainnet_gas(wlt: str, address: str, scripthash: str, amount: int):
|
||||
def withdraw_mainnet_gas(wlt: str, amount: int):
|
||||
address = _address_from_wallet(wlt, EMPTY_PASSWORD)
|
||||
scripthash = wallet.Account.address_to_script_hash(address)
|
||||
|
||||
cmd = (
|
||||
f"{NEOGO_CLI_EXEC} contract invokefunction -w {wlt} -a {address} "
|
||||
f"-r {NEO_MAINNET_ENDPOINT} {NEOFS_CONTRACT} withdraw {scripthash} "
|
||||
|
@ -65,9 +69,9 @@ def transaction_accepted(tx_id: str):
|
|||
if resp is not None:
|
||||
logger.info(f"TX is accepted in block: {resp}")
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.info(f"request failed with error: {e}")
|
||||
raise e
|
||||
except Exception as out:
|
||||
logger.info(f"request failed with error: {out}")
|
||||
raise out
|
||||
return False
|
||||
|
||||
|
||||
|
@ -93,9 +97,9 @@ def get_balance(wallet_path: str):
|
|||
logger.info(f"Got response \n{resp}")
|
||||
value = int(resp['stack'][0]['value'])
|
||||
return value / (10 ** MORPH_TOKEN_POWER)
|
||||
except Exception as e:
|
||||
logger.error(f"failed to get wallet balance: {e}")
|
||||
raise e
|
||||
except Exception as out:
|
||||
logger.error(f"failed to get wallet balance: {out}")
|
||||
raise out
|
||||
|
||||
|
||||
@keyword('Transfer Mainnet Gas')
|
||||
|
@ -112,11 +116,9 @@ def transfer_mainnet_gas(wallet_to: str, amount: int, wallet_password: str = EMP
|
|||
Returns:
|
||||
(void)
|
||||
'''
|
||||
wlt = load_wallet(wallet_to, wallet_password)
|
||||
address_to = wlt.accounts[-1].address
|
||||
logger.info(f"got address to: {address_to}")
|
||||
address_to = _address_from_wallet(wallet_to, wallet_password)
|
||||
|
||||
txid = wallet.nep17_transfer(MAINNET_WALLET_PATH, address_to, amount, NEO_MAINNET_ENDPOINT,
|
||||
txid = nep17_transfer(MAINNET_WALLET_PATH, address_to, amount, NEO_MAINNET_ENDPOINT,
|
||||
wallet_pass=MAINNET_WALLET_PASS, addr_from=MAINNET_SINGLE_ADDR)
|
||||
if not transaction_accepted(txid):
|
||||
raise RuntimeError(f"TX {txid} hasn't been processed")
|
||||
|
@ -131,11 +133,23 @@ def neofs_deposit(wallet_to: str, amount: int, wallet_password: str = EMPTY_PASS
|
|||
deposit_addr = converters.contract_hash_to_address(NEOFS_CONTRACT)
|
||||
logger.info(f"NeoFS contract address: {deposit_addr}")
|
||||
|
||||
wlt = load_wallet(wallet_to, wallet_password)
|
||||
address_to = wlt.accounts[-1].address
|
||||
logger.info(f"got address to: {address_to}")
|
||||
address_to = _address_from_wallet(wallet_to, wallet_password)
|
||||
|
||||
txid = wallet.nep17_transfer(wallet_to, deposit_addr, amount, NEO_MAINNET_ENDPOINT,
|
||||
txid = nep17_transfer(wallet_to, deposit_addr, amount, NEO_MAINNET_ENDPOINT,
|
||||
wallet_pass=wallet_password, addr_from=address_to)
|
||||
if not transaction_accepted(txid):
|
||||
raise RuntimeError(f"TX {txid} hasn't been processed")
|
||||
|
||||
def _address_from_wallet(wlt: str, wallet_password: str):
|
||||
"""
|
||||
Extracting the address from the given wallet.
|
||||
Args:
|
||||
wlt (str): the path to the wallet to extract address from
|
||||
wallet_password (str): the password for the given wallet
|
||||
Returns:
|
||||
(str): the address for the wallet
|
||||
"""
|
||||
wallet_loaded = load_wallet(wlt, wallet_password)
|
||||
address = wallet_loaded.accounts[-1].address
|
||||
logger.info(f"got address: {address}")
|
||||
return address
|
||||
|
|
|
@ -35,7 +35,7 @@ CLI Accounting Balance Test
|
|||
Should Be Equal As Numbers ${OUTPUT.stdout} ${DEPOSIT_AMOUNT}
|
||||
|
||||
# Getting balance with wallet and wrong address
|
||||
${ANOTHER_WALLET} ${ANOTHER_ADDR} ${ANOTHER_WIF} = Init Wallet With Address ${ASSETS_DIR}
|
||||
${_} ${ANOTHER_ADDR} ${_} = Init Wallet With Address ${ASSETS_DIR}
|
||||
${OUTPUT} = Run Process ${NEOFS_CLI_EXEC} accounting balance -r ${NEOFS_ENDPOINT} --address ${ANOTHER_ADDR} --wallet ${WALLET} --config ${WALLET_CONFIG}
|
||||
... shell=True
|
||||
Should Be Equal As Strings ${OUTPUT.stderr} --address option must be specified and valid
|
||||
|
|
|
@ -20,8 +20,7 @@ NeoFS Deposit and Withdraw
|
|||
|
||||
[Setup] Setup
|
||||
|
||||
${WALLET} ${ADDR} ${WIF} = Init Wallet with Address ${ASSETS_DIR}
|
||||
${SCRIPT_HASH} = Get ScriptHash ${WIF}
|
||||
${WALLET} ${ADDR} ${_} = Init Wallet with Address ${ASSETS_DIR}
|
||||
|
||||
##########################################################
|
||||
# Transferring GAS from initial wallet to our test wallet
|
||||
|
@ -47,15 +46,15 @@ NeoFS Deposit and Withdraw
|
|||
###########################
|
||||
# Withdrawing deposit back
|
||||
###########################
|
||||
Withdraw Mainnet Gas ${WALLET} ${ADDR} ${SCRIPT_HASH} ${WITHDRAW_AMOUNT}
|
||||
Withdraw Mainnet Gas ${WALLET} ${WITHDRAW_AMOUNT}
|
||||
Sleep ${NEOFS_CONTRACT_CACHE_TIMEOUT}
|
||||
|
||||
${NEOFS_BALANCE} = Get NeoFS Balance ${WALLET}
|
||||
${EXPECTED_BALANCE} = Evaluate ${DEPOSIT_AMOUNT} - ${WITHDRAW_AMOUNT}
|
||||
Should Be Equal As numbers ${NEOFS_BALANCE} ${EXPECTED_BALANCE}
|
||||
|
||||
${MAINNET_BALANCE_AFTER} = Get Mainnet Balance ${ADDR}
|
||||
${MAINNET_BALANCE_DIFF} = Evaluate ${MAINNET_BALANCE_AFTER} - ${MAINNET_BALANCE}
|
||||
Should Be True ${MAINNET_BALANCE_DIFF} < ${WITHDRAW_AMOUNT}
|
||||
${MAINNET_BALANCE_AFTER} = Get Mainnet Balance ${ADDR}
|
||||
${MAINNET_BALANCE_DIFF} = Evaluate ${MAINNET_BALANCE_AFTER} - ${MAINNET_BALANCE}
|
||||
Should Be True ${MAINNET_BALANCE_DIFF} < ${WITHDRAW_AMOUNT}
|
||||
|
||||
[Teardown] Teardown withdraw
|
||||
|
|
|
@ -24,7 +24,7 @@ Buckets in NeoFS S3 Gateway
|
|||
[Setup] Setup
|
||||
Make Up ${INCLUDE_SVC}
|
||||
|
||||
${WALLET} ${_} ${WIF} = Prepare Wallet And Deposit
|
||||
${WALLET} ${_} ${_} = Prepare Wallet And Deposit
|
||||
${FILE_S3} ${_} = Generate file ${COMPLEX_OBJ_SIZE}
|
||||
${_} ${S3_OBJECT_KEY} = Split Path ${FILE_S3}
|
||||
|
||||
|
|
Loading…
Reference in a new issue