Skip to content

Commit c5031d8

Browse files
author
Evgeniy Zayats
committed
tests: add waiters for payments tests
closes #873 Signed-off-by: Evgeniy Zayats <[email protected]>
1 parent 1241979 commit c5031d8

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

pytest_tests/lib/helpers/wallet_helpers.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
import allure
66
from helpers.common import get_assets_dir_path
7-
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
8-
from neofs_testlib.utils.wallet import init_wallet, get_last_address_from_wallet
7+
from helpers.test_control import wait_for_success
98
from neofs_testlib.cli import NeofsCli, NeoGo
9+
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
10+
from neofs_testlib.utils.wallet import get_last_address_from_wallet, init_wallet
1011

1112

1213
@allure.title("Prepare wallet and deposit")
@@ -44,3 +45,20 @@ def get_neofs_balance(neofs_env: NeoFSEnv, neofs_cli: NeofsCli, wallet: NodeWall
4445
address=get_last_address_from_wallet(wallet.path, wallet.password),
4546
).stdout.strip()
4647
)
48+
49+
50+
@allure.step("Wait for correct neofs balance")
51+
@wait_for_success(60, 5)
52+
def wait_for_correct_neofs_balance(neofs_env, wallet, cli_wallet_config: str, compare_func: callable):
53+
neofs_cli = neofs_env.neofs_cli(cli_wallet_config)
54+
assert compare_func(get_neofs_balance(neofs_env, neofs_cli, wallet)), "Wallet balance in neofs is not correct"
55+
56+
57+
@allure.step("Wait for correct wallet balance")
58+
@wait_for_success(60, 5)
59+
def wait_for_correct_wallet_balance(
60+
neofs_env, neo_go: NeoGo, wallet, neo_go_wallet_config: str, compare_func: callable
61+
):
62+
assert compare_func(get_wallet_balance(neofs_env, neo_go, wallet, neo_go_wallet_config)), (
63+
"Wallet balance is not correct after"
64+
)

pytest_tests/tests/payment/test_container_payments.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
from helpers.file_helper import generate_file
1111
from helpers.neofs_verbs import put_object
1212
from helpers.node_management import restart_storage_nodes
13-
from helpers.wallet_helpers import get_neofs_balance, get_wallet_balance
13+
from helpers.wallet_helpers import (
14+
get_neofs_balance,
15+
get_wallet_balance,
16+
wait_for_correct_neofs_balance,
17+
)
1418
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
1519
from neofs_testlib.utils import wallet as wallet_utils
1620

@@ -64,10 +68,7 @@ def wallet_with_money(neofs_env_with_mainchain: NeoFSEnv) -> NodeWallet:
6468
assert get_wallet_balance(neofs_env, neo_go, wallet, wallet.neo_go_config) <= 900, (
6569
"Wallet balance is not correct after deposit"
6670
)
67-
neofs_cli = neofs_env.neofs_cli(wallet.cli_config)
68-
assert get_neofs_balance(neofs_env, neofs_cli, wallet) == 100, (
69-
"Wallet balance in neofs is not correct after deposit"
70-
)
71+
wait_for_correct_neofs_balance(neofs_env, wallet, wallet.cli_config, lambda balance: balance == 100)
7172

7273
return wallet
7374

pytest_tests/tests/payment/test_deposit_withdrawal.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import allure
2-
from helpers.test_control import wait_for_success
3-
from helpers.wallet_helpers import get_neofs_balance, get_wallet_balance
2+
from helpers.wallet_helpers import (
3+
get_wallet_balance,
4+
wait_for_correct_neofs_balance,
5+
wait_for_correct_wallet_balance,
6+
)
47
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
58
from neofs_testlib.utils import wallet as wallet_utils
69

710

8-
@allure.step("Wait for correct neofs balance")
9-
@wait_for_success(60, 5)
10-
def wait_for_correct_neofs_balance(
11-
neofs_env: NeoFSEnv, wallet: NodeWallet, cli_wallet_config: str, compare_func: callable
12-
):
13-
neofs_cli = neofs_env.neofs_cli(cli_wallet_config)
14-
assert compare_func(get_neofs_balance(neofs_env, neofs_cli, wallet)), "Wallet balance in neofs is not correct"
15-
16-
1711
class TestDepositWithdrawal:
1812
def test_deposit_withdrawal(self, neofs_env_with_mainchain: NeoFSEnv):
1913
neofs_env = neofs_env_with_mainchain
@@ -72,6 +66,6 @@ def test_deposit_withdrawal(self, neofs_env_with_mainchain: NeoFSEnv):
7266
force=True,
7367
)
7468
wait_for_correct_neofs_balance(neofs_env, wallet, cli_wallet_config, lambda balance: balance == 50)
75-
assert get_wallet_balance(neofs_env, neo_go, wallet, neo_go_wallet_config) > 940, (
76-
"Wallet balance is not correct after withdrawal"
69+
wait_for_correct_wallet_balance(
70+
neofs_env, neo_go, wallet, neo_go_wallet_config, lambda balance: balance > 940
7771
)

0 commit comments

Comments
 (0)