2022-07-04 19:49:14 +00:00
|
|
|
#!/usr/bin/python3.9
|
2022-09-20 15:03:52 +00:00
|
|
|
import logging
|
2022-07-05 10:17:36 +00:00
|
|
|
|
2022-09-20 15:03:52 +00:00
|
|
|
import allure
|
2022-07-13 14:30:57 +00:00
|
|
|
import contract
|
|
|
|
import wrappers
|
2022-09-20 15:03:52 +00:00
|
|
|
from common import (
|
|
|
|
IR_WALLET_PASS,
|
|
|
|
IR_WALLET_PATH,
|
|
|
|
MORPH_ENDPOINT,
|
|
|
|
NEOFS_ADM_CONFIG_PATH,
|
|
|
|
NEOFS_ADM_EXEC,
|
|
|
|
)
|
2022-07-05 10:17:36 +00:00
|
|
|
|
2022-09-20 15:03:52 +00:00
|
|
|
logger = logging.getLogger("NeoLogger")
|
2022-07-04 19:49:14 +00:00
|
|
|
|
|
|
|
|
2022-09-20 15:03:52 +00:00
|
|
|
@allure.step("Get Epoch")
|
2022-07-04 19:49:14 +00:00
|
|
|
def get_epoch():
|
2022-09-20 15:03:52 +00:00
|
|
|
epoch = int(
|
|
|
|
contract.testinvoke_contract(
|
|
|
|
contract.get_netmap_contract_hash(MORPH_ENDPOINT), "epoch", MORPH_ENDPOINT
|
|
|
|
)
|
2022-07-04 19:49:14 +00:00
|
|
|
)
|
|
|
|
logger.info(f"Got epoch {epoch}")
|
|
|
|
return epoch
|
|
|
|
|
|
|
|
|
2022-09-20 15:03:52 +00:00
|
|
|
@allure.step("Tick Epoch")
|
2022-07-04 19:49:14 +00:00
|
|
|
def tick_epoch():
|
2022-07-13 14:30:57 +00:00
|
|
|
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}")
|
2022-09-20 15:03:52 +00:00
|
|
|
out = ""
|
|
|
|
err = ""
|
2022-07-28 05:35:50 +00:00
|
|
|
try:
|
|
|
|
out = wrappers.run_sh(cmd)
|
|
|
|
logger.info(f"Command completed with output: {out}")
|
|
|
|
except Exception as exc:
|
|
|
|
logger.error(exc)
|
2022-08-03 15:20:50 +00:00
|
|
|
err = str(exc)
|
2022-07-28 05:35:50 +00:00
|
|
|
raise RuntimeError("Failed to tick epoch") from exc
|
2022-08-03 15:20:50 +00:00
|
|
|
finally:
|
2022-09-20 15:03:52 +00:00
|
|
|
allure.attach(
|
|
|
|
(f"COMMAND: {cmd}\n" f"OUTPUT:\n {out}\n" f"ERROR: {err}\n"),
|
|
|
|
"Tick Epoch",
|
|
|
|
allure.attachment_type.TEXT,
|
|
|
|
)
|
2022-07-13 14:30:57 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
# Otherwise we tick epoch using transaction
|
2022-07-04 19:49:14 +00:00
|
|
|
cur_epoch = get_epoch()
|
|
|
|
return contract.invoke_contract_multisig(
|
2022-07-12 09:59:19 +00:00
|
|
|
contract.get_netmap_contract_hash(MORPH_ENDPOINT),
|
2022-08-03 15:20:50 +00:00
|
|
|
f"newEpoch int:{cur_epoch + 1}",
|
2022-09-20 15:03:52 +00:00
|
|
|
IR_WALLET_PATH,
|
|
|
|
IR_WALLET_PASS,
|
|
|
|
MORPH_ENDPOINT,
|
|
|
|
)
|