From 42100da507c7f14549111c7ceec7bacd2a054000 Mon Sep 17 00:00:00 2001 From: Ilyas Niyazov Date: Mon, 27 Jan 2025 12:41:00 +0300 Subject: [PATCH] [#351] Added method resolve NNS contract Signed-off-by: Ilyas Niyazov --- src/frostfs_testlib/steps/payment_neogo.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/frostfs_testlib/steps/payment_neogo.py b/src/frostfs_testlib/steps/payment_neogo.py index 8e78cca..2895834 100644 --- a/src/frostfs_testlib/steps/payment_neogo.py +++ b/src/frostfs_testlib/steps/payment_neogo.py @@ -40,6 +40,18 @@ def get_contract_hash(morph_chain: MorphChain, resolve_name: str, shell: Shell) return bytes.decode(base64.b64decode(stack_data[0]["value"])) +def resolve_nns_contract(morph_chain: MorphChain, resolve_name: str, shell: Shell, nns_contract_hash: str) -> str: + neogo = NeoGo(shell=shell, neo_go_exec_path=NEOGO_EXECUTABLE) + out = neogo.contract.testinvokefunction( + scripthash=nns_contract_hash, + method="resolve", + arguments=f"string:{resolve_name} int:16", + rpc_endpoint=morph_chain.get_http_endpoint(), + ) + stack_data = json.loads(out.stdout.replace("\n", ""))["stack"][0]["value"] + return bytes.decode(base64.b64decode(stack_data[0]["value"])) + + def transaction_accepted(morph_chain: MorphChain, tx_id: str): """ This function returns True in case of accepted TX. @@ -73,9 +85,7 @@ def get_balance(shell: Shell, morph_chain: MorphChain, wallet_path: str, wallet_ acc = wallet.accounts[-1] payload = [{"type": "Hash160", "value": str(acc.script_hash)}] try: - resp = morph_chain.rpc_client.invoke_function( - get_contract_hash(morph_chain, "balance.frostfs", shell=shell), "balanceOf", payload - ) + resp = morph_chain.rpc_client.invoke_function(get_contract_hash(morph_chain, "balance.frostfs", shell=shell), "balanceOf", payload) logger.info(f"Got response \n{resp}") value = int(resp["stack"][0]["value"]) return value / ASSET_POWER_SIDECHAIN @@ -112,9 +122,7 @@ def transfer_gas( amount: Amount of gas to transfer. """ wallet_from_path = wallet_from_path or morph_chain.get_wallet_path() - wallet_from_password = ( - wallet_from_password if wallet_from_password is not None else morph_chain.get_wallet_password() - ) + wallet_from_password = wallet_from_password if wallet_from_password is not None else morph_chain.get_wallet_password() address_from = address_from or wallet_utils.get_last_address_from_wallet(wallet_from_path, wallet_from_password) address_to = address_to or wallet_utils.get_last_address_from_wallet(wallet_to_path, wallet_to_password) -- 2.45.3