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

4
.gitmodules vendored
View file

@ -1,4 +0,0 @@
[submodule "neofs-keywords"]
path = neofs-keywords
url = ssh://git@github.com/nspcc-dev/neofs-keywords.git
ignore = all

View file

@ -4,8 +4,8 @@ import uuid
from typing import Optional from typing import Optional
import allure import allure
from neofs_testlib.shell.interfaces import CommandOptions
from neofs_testlib.shell import Shell from neofs_testlib.shell import Shell
from neofs_testlib.shell.interfaces import CommandOptions
from tenacity import retry, stop_after_attempt, wait_fixed from tenacity import retry, stop_after_attempt, wait_fixed

View file

@ -35,7 +35,7 @@ neo-mamba==0.10.0
neo3crypto==0.2.1 neo3crypto==0.2.1
neo3vm==0.9.0 neo3vm==0.9.0
neo3vm-stubs==0.9.0 neo3vm-stubs==0.9.0
neofs-testlib==0.2.1 neofs-testlib==0.2.2
netaddr==0.8.0 netaddr==0.8.0
orjson==3.6.8 orjson==3.6.8
packaging==21.3 packaging==21.3

View file

@ -1,3 +1,5 @@
import os
import uuid
from dataclasses import dataclass from dataclasses import dataclass
from typing import Dict, List, Optional from typing import Dict, List, Optional
@ -10,12 +12,13 @@ from common import (
STORAGE_WALLET_CONFIG, STORAGE_WALLET_CONFIG,
STORAGE_WALLET_PATH, STORAGE_WALLET_PATH,
WALLET_CONFIG, WALLET_CONFIG,
WALLET_PASS,
) )
from file_helper import generate_file from file_helper import generate_file
from neofs_testlib.utils.wallet import init_wallet
from python_keywords.acl import EACLRole from python_keywords.acl import EACLRole
from python_keywords.container import create_container from python_keywords.container import create_container
from python_keywords.neofs_verbs import put_object from python_keywords.neofs_verbs import put_object
from wallet import init_wallet
from wellknown_acl import PUBLIC_ACL from wellknown_acl import PUBLIC_ACL
OBJECT_COUNT = 5 OBJECT_COUNT = 5
@ -40,14 +43,20 @@ class Wallets:
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def wallets(prepare_wallet_and_deposit): def wallets(prepare_wallet_and_deposit):
other_wallets_paths = [
os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json") for _ in range(2)
]
for other_wallet_path in other_wallets_paths:
init_wallet(other_wallet_path, WALLET_PASS)
yield Wallets( yield Wallets(
wallets={ wallets={
EACLRole.USER: [ EACLRole.USER: [
Wallet(wallet_path=prepare_wallet_and_deposit, config_path=WALLET_CONFIG) Wallet(wallet_path=prepare_wallet_and_deposit, config_path=WALLET_CONFIG)
], ],
EACLRole.OTHERS: [ EACLRole.OTHERS: [
Wallet(wallet_path=init_wallet(ASSETS_DIR)[0], config_path=WALLET_CONFIG), Wallet(wallet_path=other_wallet_path, config_path=WALLET_CONFIG)
Wallet(wallet_path=init_wallet(ASSETS_DIR)[0], config_path=WALLET_CONFIG), for other_wallet_path in other_wallets_paths
], ],
EACLRole.SYSTEM: [ EACLRole.SYSTEM: [
Wallet(wallet_path=IR_WALLET_PATH, config_path=IR_WALLET_CONFIG), Wallet(wallet_path=IR_WALLET_PATH, config_path=IR_WALLET_CONFIG),

View file

@ -1,3 +1,5 @@
import os
import uuid
import logging import logging
from typing import Optional from typing import Optional
@ -11,11 +13,13 @@ from common import (
IR_WALLET_PASS, IR_WALLET_PASS,
IR_WALLET_PATH, IR_WALLET_PATH,
SIMPLE_OBJ_SIZE, SIMPLE_OBJ_SIZE,
WALLET_PASS,
) )
from epoch import tick_epoch from epoch import tick_epoch
from file_helper import generate_file from file_helper import generate_file
from grpc_responses import OBJECT_ACCESS_DENIED, OBJECT_NOT_FOUND from grpc_responses import OBJECT_ACCESS_DENIED, OBJECT_NOT_FOUND
from neofs_testlib.shell import Shell from neofs_testlib.shell import Shell
from neofs_testlib.utils.wallet import init_wallet
from python_keywords.acl import ( from python_keywords.acl import (
EACLAccess, EACLAccess,
EACLOperation, EACLOperation,
@ -27,7 +31,7 @@ from python_keywords.acl import (
) )
from python_keywords.container import create_container from python_keywords.container import create_container
from python_keywords.neofs_verbs import put_object from python_keywords.neofs_verbs import put_object
from python_keywords.payment_neogo import neofs_deposit, transfer_mainnet_gas from python_keywords.payment_neogo import deposit_gas, transfer_gas
from python_keywords.storage_group import ( from python_keywords.storage_group import (
delete_storagegroup, delete_storagegroup,
get_storagegroup, get_storagegroup,
@ -36,7 +40,6 @@ from python_keywords.storage_group import (
verify_get_storage_group, verify_get_storage_group,
verify_list_storage_group, verify_list_storage_group,
) )
from wallet import init_wallet
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
deposit = 30 deposit = 30
@ -50,12 +53,24 @@ deposit = 30
@pytest.mark.storage_group @pytest.mark.storage_group
class TestStorageGroup: class TestStorageGroup:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def prepare_two_wallets(self, prepare_wallet_and_deposit): def prepare_two_wallets(self, prepare_wallet_and_deposit, client_shell):
self.main_wallet = prepare_wallet_and_deposit self.main_wallet = prepare_wallet_and_deposit
self.other_wallet, _, _ = init_wallet(ASSETS_DIR) self.other_wallet = os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json")
init_wallet(self.other_wallet, WALLET_PASS)
if not FREE_STORAGE: if not FREE_STORAGE:
transfer_mainnet_gas(self.other_wallet, 31) deposit = 30
neofs_deposit(self.other_wallet, 30) transfer_gas(
shell=client_shell,
amount=deposit + 1,
wallet_to_path=self.other_wallet,
wallet_to_password=WALLET_PASS,
)
deposit_gas(
shell=client_shell,
amount=deposit,
wallet_from_path=self.other_wallet,
wallet_from_password=WALLET_PASS,
)
@allure.title("Test Storage Group in Private Container") @allure.title("Test Storage Group in Private Container")
def test_storagegroup_basic_private_container(self, client_shell, object_size): def test_storagegroup_basic_private_container(self, client_shell, object_size):
@ -226,8 +241,19 @@ class TestStorageGroup:
that System key is granted to make all operations except PUT and DELETE. that System key is granted to make all operations except PUT and DELETE.
""" """
if not FREE_STORAGE: if not FREE_STORAGE:
transfer_mainnet_gas(IR_WALLET_PATH, deposit + 1, wallet_password=IR_WALLET_PASS) deposit = 30
neofs_deposit(IR_WALLET_PATH, deposit, wallet_password=IR_WALLET_PASS) transfer_gas(
shell=shell,
amount=deposit + 1,
wallet_to_path=IR_WALLET_PATH,
wallet_to_password=IR_WALLET_PASS,
)
deposit_gas(
shell=shell,
amount=deposit,
wallet_from_path=IR_WALLET_PATH,
wallet_from_password=IR_WALLET_PASS,
)
storage_group = put_storagegroup(wallet, cid, obj_list) storage_group = put_storagegroup(wallet, cid, obj_list)
with pytest.raises(Exception, match=OBJECT_ACCESS_DENIED): with pytest.raises(Exception, match=OBJECT_ACCESS_DENIED):
put_storagegroup(IR_WALLET_PATH, cid, obj_list, wallet_config=IR_WALLET_CONFIG) put_storagegroup(IR_WALLET_PATH, cid, obj_list, wallet_config=IR_WALLET_CONFIG)

View file

@ -1,25 +1,20 @@
import logging import logging
import os import os
import shutil import shutil
import uuid
from datetime import datetime from datetime import datetime
import allure import allure
import pytest import pytest
import wallet
import yaml import yaml
from binary_version_helper import get_local_binaries_versions, get_remote_binaries_versions from binary_version_helper import get_local_binaries_versions, get_remote_binaries_versions
from common import ( from common import ASSETS_DIR, FREE_STORAGE, HOSTING_CONFIG_FILE, NEOFS_NETMAP_DICT, WALLET_PASS
ASSETS_DIR,
FREE_STORAGE,
HOSTING_CONFIG_FILE,
MAINNET_WALLET_PATH,
NEOFS_NETMAP_DICT,
)
from env_properties import save_env_properties from env_properties import save_env_properties
from neofs_testlib.hosting import Hosting from neofs_testlib.hosting import Hosting
from neofs_testlib.reporter import AllureHandler, get_reporter from neofs_testlib.reporter import AllureHandler, get_reporter
from neofs_testlib.shell import LocalShell, Shell from neofs_testlib.shell import LocalShell, Shell
from payment_neogo import neofs_deposit, transfer_mainnet_gas from neofs_testlib.utils.wallet import init_wallet
from payment_neogo import deposit_gas, transfer_gas
from python_keywords.node_management import node_healthcheck from python_keywords.node_management import node_healthcheck
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
@ -112,14 +107,24 @@ def run_health_check(collect_logs, hosting: Hosting):
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
@allure.title("Prepare wallet and deposit") @allure.title("Prepare wallet and deposit")
def prepare_wallet_and_deposit(prepare_tmp_dir): def prepare_wallet_and_deposit(client_shell, prepare_tmp_dir):
wallet_path, address, _ = wallet.init_wallet(ASSETS_DIR) wallet_path = os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json")
logger.info(f"Init wallet: {wallet_path}, address: {address}") init_wallet(wallet_path, WALLET_PASS)
allure.attach.file(wallet_path, os.path.basename(wallet_path), allure.attachment_type.JSON) allure.attach.file(wallet_path, os.path.basename(wallet_path), allure.attachment_type.JSON)
if not FREE_STORAGE: if not FREE_STORAGE:
deposit = 30 deposit = 30
transfer_mainnet_gas(wallet_path, deposit + 1, wallet_path=MAINNET_WALLET_PATH) transfer_gas(
neofs_deposit(wallet_path, deposit) shell=client_shell,
amount=deposit + 1,
wallet_to_path=wallet_path,
wallet_to_password=WALLET_PASS,
)
deposit_gas(
shell=client_shell,
amount=deposit,
wallet_from_path=wallet_path,
wallet_from_password=WALLET_PASS,
)
return wallet_path return wallet_path

View file

@ -58,7 +58,7 @@ def test_container_creation(client_shell, prepare_wallet_and_deposit, name):
with allure.step("Delete container and check it was deleted"): with allure.step("Delete container and check it was deleted"):
delete_container(wallet, cid, shell=client_shell) delete_container(wallet, cid, shell=client_shell)
tick_epoch() tick_epoch(shell=client_shell)
wait_for_container_deletion(wallet, cid, shell=client_shell) wait_for_container_deletion(wallet, cid, shell=client_shell)
@ -92,5 +92,5 @@ def test_container_creation_deletion_parallel(client_shell, prepare_wallet_and_d
with allure.step("Delete containers and check they were deleted"): with allure.step("Delete containers and check they were deleted"):
for cid in cids: for cid in cids:
delete_container(wallet, cid, shell=client_shell) delete_container(wallet, cid, shell=client_shell)
tick_epoch() tick_epoch(shell=client_shell)
wait_for_container_deletion(wallet, cid, shell=client_shell) wait_for_container_deletion(wallet, cid, shell=client_shell)

View file

@ -151,7 +151,7 @@ def test_object_api(prepare_wallet_and_deposit, client_shell, request, object_si
wallet_path=wallet, cid=cid, oid_ts=tombstone_h, oid=oids[1], shell=client_shell wallet_path=wallet, cid=cid, oid_ts=tombstone_h, oid=oids[1], shell=client_shell
) )
tick_epoch() tick_epoch(shell=client_shell)
sleep(CLEANUP_TIMEOUT) sleep(CLEANUP_TIMEOUT)
with allure.step("Get objects and check errors"): with allure.step("Get objects and check errors"):
@ -180,7 +180,7 @@ def test_object_api_lifetime(prepare_wallet_and_deposit, client_shell, request,
file_path = generate_file(object_size) file_path = generate_file(object_size)
file_hash = get_file_hash(file_path) file_hash = get_file_hash(file_path)
epoch = get_epoch() epoch = get_epoch(shell=client_shell)
oid = put_object(wallet, file_path, cid, shell=client_shell, expire_at=epoch + 1) oid = put_object(wallet, file_path, cid, shell=client_shell, expire_at=epoch + 1)
got_file = get_object(wallet, cid, oid, shell=client_shell) got_file = get_object(wallet, cid, oid, shell=client_shell)
@ -188,7 +188,7 @@ def test_object_api_lifetime(prepare_wallet_and_deposit, client_shell, request,
with allure.step("Tick two epochs"): with allure.step("Tick two epochs"):
for _ in range(2): for _ in range(2):
tick_epoch() tick_epoch(shell=client_shell)
# Wait for GC, because object with expiration is counted as alive until GC removes it # Wait for GC, because object with expiration is counted as alive until GC removes it
wait_for_gc_pass_on_storage_nodes() wait_for_gc_pass_on_storage_nodes()

View file

@ -1,13 +1,13 @@
import logging import logging
import os import os
import uuid
import allure import allure
import pytest import pytest
import yaml import yaml
from common import ASSETS_DIR, FREE_STORAGE, NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_CONFIG from common import ASSETS_DIR, FREE_STORAGE, NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_CONFIG, WALLET_PASS
from neofs_testlib.cli import NeofsCli from neofs_testlib.cli import NeofsCli
from python_keywords.payment_neogo import _address_from_wallet from neofs_testlib.utils.wallet import get_last_address_from_wallet, init_wallet
from wallet import init_wallet
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
DEPOSIT_AMOUNT = 30 DEPOSIT_AMOUNT = 30
@ -19,8 +19,10 @@ class TestBalanceAccounting:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def prepare_two_wallets(self, prepare_wallet_and_deposit): def prepare_two_wallets(self, prepare_wallet_and_deposit):
self.user_wallet = prepare_wallet_and_deposit self.user_wallet = prepare_wallet_and_deposit
self.address = _address_from_wallet(self.user_wallet, "") self.address = get_last_address_from_wallet(self.user_wallet, WALLET_PASS)
_, self.another_address, _ = init_wallet(ASSETS_DIR) another_wallet = os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json")
init_wallet(another_wallet, WALLET_PASS)
self.another_address = get_last_address_from_wallet(another_wallet, WALLET_PASS)
@allure.title("Test balance request with wallet and address") @allure.title("Test balance request with wallet and address")
def test_balance_wallet_address(self, client_shell): def test_balance_wallet_address(self, client_shell):

View file

@ -66,7 +66,7 @@ class TestS3Gate(TestS3GateBase):
s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket) s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket)
@allure.title("Test S3 Bucket API") @allure.title("Test S3 Bucket API")
def test_s3_buckets(self): def test_s3_buckets(self, client_shell):
""" """
Test base S3 Bucket API (Create/List/Head/Delete). Test base S3 Bucket API (Create/List/Head/Delete).
""" """
@ -110,7 +110,7 @@ class TestS3Gate(TestS3GateBase):
with allure.step(f"Delete empty bucket {bucket_2}"): with allure.step(f"Delete empty bucket {bucket_2}"):
s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket_2) s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket_2)
tick_epoch() tick_epoch(shell=client_shell)
with allure.step(f"Check bucket {bucket_2} deleted"): with allure.step(f"Check bucket {bucket_2} deleted"):
with pytest.raises(Exception, match=r".*Not Found.*"): with pytest.raises(Exception, match=r".*Not Found.*"):
@ -126,7 +126,7 @@ class TestS3Gate(TestS3GateBase):
with allure.step(f"Delete bucket {bucket_1}"): with allure.step(f"Delete bucket {bucket_1}"):
s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket_1) s3_gate_bucket.delete_bucket_s3(self.s3_client, bucket_1)
tick_epoch() tick_epoch(shell=client_shell)
with allure.step(f"Check bucket {bucket_1} deleted"): with allure.step(f"Check bucket {bucket_1} deleted"):
with pytest.raises(Exception, match=r".*Not Found.*"): with pytest.raises(Exception, match=r".*Not Found.*"):

View file

@ -5,12 +5,12 @@ from random import sample
import allure import allure
import pytest import pytest
from common import ASSETS_DIR, COMPLEX_OBJ_SIZE, FREE_STORAGE, SIMPLE_OBJ_SIZE from common import ASSETS_DIR, COMPLEX_OBJ_SIZE, FREE_STORAGE, SIMPLE_OBJ_SIZE, WALLET_PASS
from data_formatters import get_wallet_public_key from data_formatters import get_wallet_public_key
from file_helper import concat_files, generate_file, generate_file_with_content, get_file_hash from file_helper import concat_files, generate_file, generate_file_with_content, get_file_hash
from python_keywords.payment_neogo import neofs_deposit, transfer_mainnet_gas from python_keywords.payment_neogo import deposit_gas, transfer_gas
from s3_helper import assert_object_lock_mode, check_objects_in_bucket, set_bucket_versioning from s3_helper import assert_object_lock_mode, check_objects_in_bucket, set_bucket_versioning
from wallet import init_wallet from neofs_testlib.utils.wallet import init_wallet
from steps import s3_gate_bucket, s3_gate_object from steps import s3_gate_bucket, s3_gate_object
from steps.aws_cli_client import AwsCliClient from steps.aws_cli_client import AwsCliClient
@ -660,14 +660,27 @@ class TestS3GateObject(TestS3GateBase):
], "Tags must be the same" ], "Tags must be the same"
@pytest.fixture @pytest.fixture
def prepare_two_wallets(self, prepare_wallet_and_deposit): def prepare_two_wallets(self, prepare_wallet_and_deposit, client_shell):
self.main_wallet = prepare_wallet_and_deposit self.main_wallet = prepare_wallet_and_deposit
self.main_public_key = get_wallet_public_key(self.main_wallet, "") self.main_public_key = get_wallet_public_key(self.main_wallet, WALLET_PASS)
self.other_wallet, _, _ = init_wallet(ASSETS_DIR) self.other_wallet = os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json")
self.other_public_key = get_wallet_public_key(self.other_wallet, "") init_wallet(self.other_wallet, WALLET_PASS)
self.other_public_key = get_wallet_public_key(self.other_wallet, WALLET_PASS)
if not FREE_STORAGE: if not FREE_STORAGE:
transfer_mainnet_gas(self.other_wallet, 31) deposit = 30
neofs_deposit(self.other_wallet, 30) transfer_gas(
shell=client_shell,
amount=deposit + 1,
wallet_to_path=self.other_wallet,
wallet_to_password=WALLET_PASS,
)
deposit_gas(
shell=client_shell,
amount=deposit,
wallet_from_path=self.other_wallet,
wallet_from_password=WALLET_PASS,
)
@allure.title("Test S3: put object with ACL") @allure.title("Test S3: put object with ACL")
@pytest.mark.parametrize("bucket_versioning", ["ENABLED", "SUSPENDED"]) @pytest.mark.parametrize("bucket_versioning", ["ENABLED", "SUSPENDED"])

View file

@ -154,7 +154,7 @@ class TestHttpGate:
file_path = generate_file() file_path = generate_file()
oids = [] oids = []
curr_epoch = get_epoch() curr_epoch = get_epoch(client_shell)
epochs = (curr_epoch, curr_epoch + 1, curr_epoch + 2, curr_epoch + 100) epochs = (curr_epoch, curr_epoch + 1, curr_epoch + 2, curr_epoch + 100)
for epoch in epochs: for epoch in epochs:
@ -170,7 +170,7 @@ class TestHttpGate:
get_via_http_gate(cid=cid, oid=oid) get_via_http_gate(cid=cid, oid=oid)
for expired_objects, not_expired_objects in [(oids[:1], oids[1:]), (oids[:2], oids[2:])]: for expired_objects, not_expired_objects in [(oids[:1], oids[1:]), (oids[:2], oids[2:])]:
tick_epoch() tick_epoch(shell=client_shell)
# Wait for GC, because object with expiration is counted as alive until GC removes it # Wait for GC, because object with expiration is counted as alive until GC removes it
wait_for_gc_pass_on_storage_nodes() wait_for_gc_pass_on_storage_nodes()

View file

@ -6,7 +6,7 @@ from common import COMPLEX_OBJ_SIZE, NEOFS_NETMAP_DICT, SIMPLE_OBJ_SIZE
from file_helper import generate_file from file_helper import generate_file
from grpc_responses import SESSION_NOT_FOUND from grpc_responses import SESSION_NOT_FOUND
from neofs_testlib.shell import Shell from neofs_testlib.shell import Shell
from payment_neogo import _address_from_wallet from neofs_testlib.utils.wallet import get_last_address_from_wallet
from python_keywords.container import create_container from python_keywords.container import create_container
from python_keywords.neofs_verbs import ( from python_keywords.neofs_verbs import (
delete_object, delete_object,
@ -39,7 +39,7 @@ def test_object_session_token(prepare_wallet_and_deposit, client_shell: Shell, o
with allure.step("Init wallet"): with allure.step("Init wallet"):
wallet = prepare_wallet_and_deposit wallet = prepare_wallet_and_deposit
address = _address_from_wallet(wallet, "") address = get_last_address_from_wallet(wallet, "")
with allure.step("Nodes Settlements"): with allure.step("Nodes Settlements"):
( (

View file

@ -1,60 +1,63 @@
#!/usr/bin/python3.9 import json
import logging import logging
from time import sleep
import allure import allure
import contract
import wrappers
from common import ( from common import (
IR_WALLET_PASS, IR_WALLET_PASS,
IR_WALLET_PATH, IR_WALLET_PATH,
MAINNET_BLOCK_TIME,
MORPH_ENDPOINT, MORPH_ENDPOINT,
NEOFS_ADM_CONFIG_PATH, NEOFS_ADM_CONFIG_PATH,
NEOFS_ADM_EXEC, 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") logger = logging.getLogger("NeoLogger")
@allure.step("Get Epoch") @allure.step("Get Epoch")
def get_epoch(): def get_epoch(shell: Shell):
epoch = int( neogo = NeoGo(shell=shell, neo_go_exec_path=NEOGO_EXECUTABLE)
contract.testinvoke_contract( out = neogo.contract.testinvokefunction(
contract.get_netmap_contract_hash(MORPH_ENDPOINT), "epoch", MORPH_ENDPOINT scripthash=get_contract_hash("netmap.neofs", shell=shell),
method="epoch",
rpc_endpoint=MORPH_ENDPOINT,
) )
) return int(json.loads(out.stdout.replace("\n", ""))["stack"][0]["value"])
logger.info(f"Got epoch {epoch}")
return epoch
@allure.step("Tick Epoch") @allure.step("Tick Epoch")
def tick_epoch(): def tick_epoch(shell: Shell):
if NEOFS_ADM_EXEC and NEOFS_ADM_CONFIG_PATH: 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) # 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}" neofsadm = NeofsAdm(
logger.info(f"Executing shell command: {cmd}") shell=shell, neofs_adm_exec_path=NEOFS_ADM_EXEC, config_file=NEOFS_ADM_CONFIG_PATH
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.morph.force_new_epoch()
return return
# Otherwise we tick epoch using transaction # Otherwise we tick epoch using transaction
cur_epoch = get_epoch() cur_epoch = get_epoch(shell)
return contract.invoke_contract_multisig(
contract.get_netmap_contract_hash(MORPH_ENDPOINT), ir_address = get_last_address_from_wallet(IR_WALLET_PATH, IR_WALLET_PASS)
f"newEpoch int:{cur_epoch + 1}",
IR_WALLET_PATH, neogo = NeoGo(shell, neo_go_exec_path=NEOGO_EXECUTABLE)
IR_WALLET_PASS, neogo.contract.invokefunction(
MORPH_ENDPOINT, 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))

View file

@ -174,7 +174,7 @@ def exclude_node_from_network_map(
node_set_status(hosting, node_to_exclude, status="offline") node_set_status(hosting, node_to_exclude, status="offline")
time.sleep(parse_time(MORPH_BLOCK_TIME)) time.sleep(parse_time(MORPH_BLOCK_TIME))
tick_epoch() tick_epoch(shell=shell)
snapshot = get_netmap_snapshot(node_name=alive_node, shell=shell) snapshot = get_netmap_snapshot(node_name=alive_node, shell=shell)
assert ( assert (
@ -189,7 +189,7 @@ def include_node_to_network_map(
node_set_status(hosting, node_to_include, status="online") node_set_status(hosting, node_to_include, status="online")
time.sleep(parse_time(MORPH_BLOCK_TIME)) time.sleep(parse_time(MORPH_BLOCK_TIME))
tick_epoch() tick_epoch(shell=shell)
check_node_in_map(node_to_include, shell, alive_node) check_node_in_map(node_to_include, shell, alive_node)

View file

@ -1,15 +1,14 @@
#!/usr/bin/python3 import base64
import json
import logging import logging
import re import re
import time import time
from typing import Optional
import allure import allure
import contract
import converters
import rpc_client
from common import ( from common import (
GAS_HASH, GAS_HASH,
MAINNET_BLOCK_TIME,
MAINNET_SINGLE_ADDR, MAINNET_SINGLE_ADDR,
MAINNET_WALLET_PASS, MAINNET_WALLET_PASS,
MAINNET_WALLET_PATH, MAINNET_WALLET_PATH,
@ -18,10 +17,13 @@ from common import (
NEOFS_CONTRACT, NEOFS_CONTRACT,
NEOGO_EXECUTABLE, NEOGO_EXECUTABLE,
) )
from converters import load_wallet from neo3 import wallet as neo3_wallet
from neo3 import wallet from neofs_testlib.blockchain import RPCClient
from wallet import nep17_transfer from neofs_testlib.cli import NeoGo
from wrappers import run_sh_with_passwd_contract from neofs_testlib.shell import Shell
from neofs_testlib.utils.converters import contract_hash_to_address
from neofs_testlib.utils.wallet import get_last_address_from_wallet
from utility import parse_time
logger = logging.getLogger("NeoLogger") logger = logging.getLogger("NeoLogger")
@ -30,26 +32,46 @@ TX_PERSIST_TIMEOUT = 15 # seconds
ASSET_POWER_MAINCHAIN = 10**8 ASSET_POWER_MAINCHAIN = 10**8
ASSET_POWER_SIDECHAIN = 10**12 ASSET_POWER_SIDECHAIN = 10**12
morph_rpc_cli = rpc_client.RPCClient(MORPH_ENDPOINT) morph_rpc_client = RPCClient(MORPH_ENDPOINT)
mainnet_rpc_cli = rpc_client.RPCClient(NEO_MAINNET_ENDPOINT) mainnet_rpc_client = RPCClient(NEO_MAINNET_ENDPOINT)
def get_nns_contract_hash() -> str:
rpc_client = RPCClient(MORPH_ENDPOINT)
return rpc_client.get_contract_state(1)["hash"]
def get_contract_hash(resolve_name: str, shell: Shell) -> str:
nns_contract_hash = get_nns_contract_hash()
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_ENDPOINT,
)
stack_data = json.loads(out.stdout.replace("\n", ""))["stack"][0]["value"]
return bytes.decode(base64.b64decode(stack_data[0]["value"]))
@allure.step("Withdraw Mainnet Gas") @allure.step("Withdraw Mainnet Gas")
def withdraw_mainnet_gas(wlt: str, amount: int): def withdraw_mainnet_gas(shell: Shell, wlt: str, amount: int):
address = _address_from_wallet(wlt, EMPTY_PASSWORD) address = get_last_address_from_wallet(wlt, EMPTY_PASSWORD)
scripthash = wallet.Account.address_to_script_hash(address) scripthash = neo3_wallet.Account.address_to_script_hash(address)
cmd = ( neogo = NeoGo(shell=shell, neo_go_exec_path=NEOGO_EXECUTABLE)
f"{NEOGO_EXECUTABLE} contract invokefunction -w {wlt} -a {address} " out = neogo.contract.invokefunction(
f"-r {NEO_MAINNET_ENDPOINT} {NEOFS_CONTRACT} withdraw {scripthash} " wallet=wlt,
f"int:{amount} -- {scripthash}:Global" address=address,
rpc_endpoint=NEO_MAINNET_ENDPOINT,
scripthash=NEOFS_CONTRACT,
method="withdraw",
arguments=f"{scripthash} int:{amount}",
multisig_hash=f"{scripthash}:Global",
wallet_password="",
) )
logger.info(f"Executing command: {cmd}") m = re.match(r"^Sent invocation transaction (\w{64})$", out.stdout)
raw_out = run_sh_with_passwd_contract("", cmd, expect_confirmation=True)
out = raw_out.decode("utf-8")
logger.info(f"Command completed with output: {out}")
m = re.match(r"^Sent invocation transaction (\w{64})$", out)
if m is None: if m is None:
raise Exception("Can not get Tx.") raise Exception("Can not get Tx.")
tx = m.group(1) tx = m.group(1)
@ -69,7 +91,7 @@ def transaction_accepted(tx_id: str):
try: try:
for _ in range(0, TX_PERSIST_TIMEOUT): for _ in range(0, TX_PERSIST_TIMEOUT):
time.sleep(1) time.sleep(1)
resp = mainnet_rpc_cli.get_transaction_height(tx_id) resp = mainnet_rpc_client.get_transaction_height(tx_id)
if resp is not None: if resp is not None:
logger.info(f"TX is accepted in block: {resp}") logger.info(f"TX is accepted in block: {resp}")
return True return True
@ -80,16 +102,17 @@ def transaction_accepted(tx_id: str):
@allure.step("Get NeoFS Balance") @allure.step("Get NeoFS Balance")
def get_balance(wallet_path: str): def get_balance(shell: Shell, wallet_path: str, wallet_password: str = ""):
""" """
This function returns NeoFS balance for given wallet. This function returns NeoFS balance for given wallet.
""" """
wlt = load_wallet(wallet_path) with open(wallet_path) as wallet_file:
acc = wlt.accounts[-1] wallet = neo3_wallet.Wallet.from_json(json.load(wallet_file), password=wallet_password)
acc = wallet.accounts[-1]
payload = [{"type": "Hash160", "value": str(acc.script_hash)}] payload = [{"type": "Hash160", "value": str(acc.script_hash)}]
try: try:
resp = morph_rpc_cli.invoke_function( resp = morph_rpc_client.invoke_function(
contract.get_balance_contract_hash(MORPH_ENDPOINT), "balanceOf", payload get_contract_hash("balance.neofs", shell=shell), "balanceOf", payload
) )
logger.info(f"Got response \n{resp}") logger.info(f"Got response \n{resp}")
value = int(resp["stack"][0]["value"]) value = int(resp["stack"][0]["value"])
@ -99,81 +122,79 @@ def get_balance(wallet_path: str):
raise out raise out
@allure.step("Transfer Mainnet Gas") @allure.title("Transfer Gas")
def transfer_mainnet_gas( def transfer_gas(
wallet_to: str, shell: Shell,
amount: int, amount: int,
wallet_password: str = EMPTY_PASSWORD, wallet_from_path: str = MAINNET_WALLET_PATH,
wallet_path: str = MAINNET_WALLET_PATH, wallet_from_password: str = MAINNET_WALLET_PASS,
address_from: str = MAINNET_SINGLE_ADDR,
address_to: Optional[str] = None,
wallet_to_path: Optional[str] = None,
wallet_to_password: Optional[str] = None,
): ):
""" """
This function transfer GAS in main chain from mainnet wallet to This function transfer GAS in main chain from mainnet wallet to
the provided wallet. If the wallet contains more than one address, the provided wallet. If the wallet contains more than one address,
the assets will be transferred to the last one. the assets will be transferred to the last one.
Args: Args:
wallet_to (str): the path to the wallet to transfer assets to shell: Shell instance.
amount (int): amount of gas to transfer wallet_from_password: password of the wallet; it is
wallet_password (optional, str): password of the wallet; it is
required to decode the wallet and extract its addresses required to decode the wallet and extract its addresses
wallet_path (str): path to chain node wallet wallet_from_path: path to chain node wallet
address_from: the address of the wallet to transfer assets from
wallet_to_path: the path to the wallet to transfer assets to
wallet_to_password: the password to the wallet to transfer assets to
address_to: the address of the wallet to transfer assets to
amount: amount of gas to transfer
Returns: Returns:
(void) (void)
""" """
address_to = _address_from_wallet(wallet_to, wallet_password) address_to = address_to or get_last_address_from_wallet(wallet_to_path, wallet_to_password)
txid = nep17_transfer( neogo = NeoGo(shell, neo_go_exec_path=NEOGO_EXECUTABLE)
wallet_path, out = neogo.nep17.transfer(
address_to, rpc_endpoint=NEO_MAINNET_ENDPOINT,
amount, wallet=wallet_from_path,
NEO_MAINNET_ENDPOINT, wallet_password=wallet_from_password,
wallet_pass=MAINNET_WALLET_PASS, amount=amount,
addr_from=MAINNET_SINGLE_ADDR, from_address=address_from,
to_address=address_to,
token="GAS",
force=True,
) )
txid = out.stdout.strip().split("\n")[-1]
if len(txid) != 64:
raise Exception("Got no TXID after run the command")
if not transaction_accepted(txid): if not transaction_accepted(txid):
raise AssertionError(f"TX {txid} hasn't been processed") raise AssertionError(f"TX {txid} hasn't been processed")
time.sleep(parse_time(MAINNET_BLOCK_TIME))
@allure.step("NeoFS Deposit") @allure.step("NeoFS Deposit")
def neofs_deposit(wallet_to: str, amount: int, wallet_password: str = EMPTY_PASSWORD): def deposit_gas(shell: Shell, amount: int, wallet_from_path: str, wallet_from_password: str):
""" """
Transferring GAS from given wallet to NeoFS contract address. Transferring GAS from given wallet to NeoFS contract address.
""" """
# get NeoFS contract address # get NeoFS contract address
deposit_addr = converters.contract_hash_to_address(NEOFS_CONTRACT) deposit_addr = contract_hash_to_address(NEOFS_CONTRACT)
logger.info(f"NeoFS contract address: {deposit_addr}") logger.info(f"NeoFS contract address: {deposit_addr}")
address_from = get_last_address_from_wallet(
address_to = _address_from_wallet(wallet_to, wallet_password) wallet_path=wallet_from_path, wallet_password=wallet_from_password
)
txid = nep17_transfer( transfer_gas(
wallet_to, shell=shell,
deposit_addr, amount=amount,
amount, wallet_from_path=wallet_from_path,
NEO_MAINNET_ENDPOINT, wallet_from_password=wallet_from_password,
wallet_pass=wallet_password, address_to=deposit_addr,
addr_from=address_to, address_from=address_from,
) )
if not transaction_accepted(txid):
raise AssertionError(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
@allure.step("Get Mainnet Balance") @allure.step("Get Mainnet Balance")
def get_mainnet_balance(address: str): def get_mainnet_balance(address: str):
resp = mainnet_rpc_cli.get_nep17_balances(address=address) resp = mainnet_rpc_client.get_nep17_balances(address=address)
logger.info(f"Got getnep17balances response: {resp}") logger.info(f"Got getnep17balances response: {resp}")
for balance in resp["balance"]: for balance in resp["balance"]:
if balance["assethash"] == GAS_HASH: if balance["assethash"] == GAS_HASH:
@ -183,7 +204,7 @@ def get_mainnet_balance(address: str):
@allure.step("Get Sidechain Balance") @allure.step("Get Sidechain Balance")
def get_sidechain_balance(address: str): def get_sidechain_balance(address: str):
resp = morph_rpc_cli.get_nep17_balances(address=address) resp = morph_rpc_client.get_nep17_balances(address=address)
logger.info(f"Got getnep17balances response: {resp}") logger.info(f"Got getnep17balances response: {resp}")
for balance in resp["balance"]: for balance in resp["balance"]:
if balance["assethash"] == GAS_HASH: if balance["assethash"] == GAS_HASH: