Skip to content

Commit 402664d

Browse files
author
Evgeniy Zayats
committed
tests: add estimations verification to payments tests
closes #1137 Signed-off-by: Evgeniy Zayats <[email protected]>
1 parent b68505f commit 402664d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

neofs-testlib/neofs_testlib/cli/neofs_adm/fschain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def netmap_candidates(
407407
**{param: param_value for param, param_value in locals().items() if param not in ["self"]},
408408
)
409409

410-
def estimations(self, rpc_endpoint: str, cid: str, epoch: str) -> CommandResult:
410+
def estimations(self, rpc_endpoint: str, cid: str, epoch: str = None) -> CommandResult:
411411
"""Set NeoFS config settings.
412412
413413
Args:

pytest_tests/lib/helpers/utility.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,33 @@ def parse_node_height(stdout: str) -> tuple[float, float]:
8484
block_height = float(lines[0].split(": ")[1].strip())
8585
state = float(lines[1].split(": ")[1].strip())
8686
return block_height, state
87+
88+
89+
def parse_container_estimations_info(s: str) -> dict:
90+
pattern = (
91+
r"^(?P<container_id>[A-Za-z0-9]+): "
92+
r"container size: (?P<container_size>\d+); "
93+
r"number of objects: (?P<number_of_objects>\d+)"
94+
)
95+
match = re.match(pattern, s.strip())
96+
if not match:
97+
raise ValueError(f"String format does not match expected pattern: {s=}")
98+
99+
return {
100+
"container_id": match.group("container_id"),
101+
"container_size": int(match.group("container_size")),
102+
"number_of_objects": int(match.group("number_of_objects")),
103+
}
104+
105+
106+
def verify_container_estimations(cli_output: str, cid: str, container_size: int, number_of_objects: int):
107+
container_info = parse_container_estimations_info(cli_output)
108+
assert container_info["container_id"] == cid, (
109+
f"invalid container_id, expected: {cid}, got: {container_info['container_id']}"
110+
)
111+
assert int(container_info["container_size"]) == container_size, (
112+
f"invalid container size, expected: {container_size}, got: {container_info['container_size']}"
113+
)
114+
assert int(container_info["number_of_objects"]) == number_of_objects, (
115+
f"invalid number of objects, expected: {number_of_objects}, got: {container_info['number_of_objects']}"
116+
)

pytest_tests/tests/payment/test_container_payments.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from helpers.file_helper import generate_file
1010
from helpers.neofs_verbs import put_object
1111
from helpers.node_management import restart_storage_nodes
12+
from helpers.utility import verify_container_estimations
1213
from helpers.wallet_helpers import create_wallet_with_money, get_neofs_balance
1314
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
1415

@@ -121,6 +122,15 @@ def test_container_payments(
121122
new_epoch = neofs_epoch.wait_until_new_epoch(neofs_env, neofs_epoch.get_epoch(neofs_env))
122123
new_epoch = neofs_epoch.wait_until_new_epoch(neofs_env, new_epoch)
123124

125+
verify_container_estimations(
126+
neofs_env.neofs_adm()
127+
.fschain.estimations(rpc_endpoint=f"http://{neofs_env.fschain_rpc}", cid=cid)
128+
.stdout.strip(),
129+
cid,
130+
container_size=objects_count * MAX_OBJECT_SIZE,
131+
number_of_objects=objects_count,
132+
)
133+
124134
with allure.step("Ensure the user wallet balance is charged only once per epoch"):
125135
deltas = []
126136
last_balance = get_neofs_balance(

0 commit comments

Comments
 (0)