Remove neofs-keywords submodule

Signed-off-by: Vladimir Avdeev <v.avdeev@yadro.com>
This commit is contained in:
Vladimir Avdeev 2022-10-27 08:43:20 +03:00 committed by Vladimir Avdeev
parent bc1f873975
commit 70a0f9f216
16 changed files with 246 additions and 171 deletions

View file

@ -1,60 +1,63 @@
#!/usr/bin/python3.9
import json
import logging
from time import sleep
import allure
import contract
import wrappers
from common import (
IR_WALLET_PASS,
IR_WALLET_PATH,
MAINNET_BLOCK_TIME,
MORPH_ENDPOINT,
NEOFS_ADM_CONFIG_PATH,
NEOFS_ADM_EXEC,
NEOGO_EXECUTABLE,
)
from neofs_testlib.cli import NeofsAdm, NeoGo
from neofs_testlib.shell import Shell
from neofs_testlib.utils.wallet import get_last_address_from_wallet
from payment_neogo import get_contract_hash
from utility import parse_time
logger = logging.getLogger("NeoLogger")
@allure.step("Get Epoch")
def get_epoch():
epoch = int(
contract.testinvoke_contract(
contract.get_netmap_contract_hash(MORPH_ENDPOINT), "epoch", MORPH_ENDPOINT
)
def get_epoch(shell: Shell):
neogo = NeoGo(shell=shell, neo_go_exec_path=NEOGO_EXECUTABLE)
out = neogo.contract.testinvokefunction(
scripthash=get_contract_hash("netmap.neofs", shell=shell),
method="epoch",
rpc_endpoint=MORPH_ENDPOINT,
)
logger.info(f"Got epoch {epoch}")
return epoch
return int(json.loads(out.stdout.replace("\n", ""))["stack"][0]["value"])
@allure.step("Tick Epoch")
def tick_epoch():
def tick_epoch(shell: Shell):
if NEOFS_ADM_EXEC and NEOFS_ADM_CONFIG_PATH:
# If neofs-adm is available, then we tick epoch with it (to be consistent with UAT tests)
cmd = f"{NEOFS_ADM_EXEC} morph force-new-epoch -c {NEOFS_ADM_CONFIG_PATH}"
logger.info(f"Executing shell command: {cmd}")
out = ""
err = ""
try:
out = wrappers.run_sh(cmd)
logger.info(f"Command completed with output: {out}")
except Exception as exc:
logger.error(exc)
err = str(exc)
raise RuntimeError("Failed to tick epoch") from exc
finally:
allure.attach(
(f"COMMAND: {cmd}\n" f"OUTPUT:\n {out}\n" f"ERROR: {err}\n"),
"Tick Epoch",
allure.attachment_type.TEXT,
)
neofsadm = NeofsAdm(
shell=shell, neofs_adm_exec_path=NEOFS_ADM_EXEC, config_file=NEOFS_ADM_CONFIG_PATH
)
neofsadm.morph.force_new_epoch()
return
# Otherwise we tick epoch using transaction
cur_epoch = get_epoch()
return contract.invoke_contract_multisig(
contract.get_netmap_contract_hash(MORPH_ENDPOINT),
f"newEpoch int:{cur_epoch + 1}",
IR_WALLET_PATH,
IR_WALLET_PASS,
MORPH_ENDPOINT,
cur_epoch = get_epoch(shell)
ir_address = get_last_address_from_wallet(IR_WALLET_PATH, IR_WALLET_PASS)
neogo = NeoGo(shell, neo_go_exec_path=NEOGO_EXECUTABLE)
neogo.contract.invokefunction(
wallet=IR_WALLET_PATH,
wallet_password=IR_WALLET_PASS,
scripthash=get_contract_hash("netmap.neofs", shell=shell),
method="newEpoch",
arguments=f"int:{cur_epoch + 1}",
multisig_hash=f"{ir_address}:Global",
address=ir_address,
rpc_endpoint=MORPH_ENDPOINT,
force=True,
gas=1,
)
sleep(parse_time(MAINNET_BLOCK_TIME))