Skip to content

Commit

Permalink
tests: add waiters for payments tests (#946)
Browse files Browse the repository at this point in the history
closes #873
  • Loading branch information
roman-khimov authored Feb 4, 2025
2 parents dabf5d1 + c5031d8 commit f2fbc53
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
22 changes: 20 additions & 2 deletions pytest_tests/lib/helpers/wallet_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import allure
from helpers.common import get_assets_dir_path
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
from neofs_testlib.utils.wallet import init_wallet, get_last_address_from_wallet
from helpers.test_control import wait_for_success
from neofs_testlib.cli import NeofsCli, NeoGo
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
from neofs_testlib.utils.wallet import get_last_address_from_wallet, init_wallet


@allure.title("Prepare wallet and deposit")
Expand Down Expand Up @@ -44,3 +45,20 @@ def get_neofs_balance(neofs_env: NeoFSEnv, neofs_cli: NeofsCli, wallet: NodeWall
address=get_last_address_from_wallet(wallet.path, wallet.password),
).stdout.strip()
)


@allure.step("Wait for correct neofs balance")
@wait_for_success(60, 5)
def wait_for_correct_neofs_balance(neofs_env, wallet, cli_wallet_config: str, compare_func: callable):
neofs_cli = neofs_env.neofs_cli(cli_wallet_config)
assert compare_func(get_neofs_balance(neofs_env, neofs_cli, wallet)), "Wallet balance in neofs is not correct"


@allure.step("Wait for correct wallet balance")
@wait_for_success(60, 5)
def wait_for_correct_wallet_balance(
neofs_env, neo_go: NeoGo, wallet, neo_go_wallet_config: str, compare_func: callable
):
assert compare_func(get_wallet_balance(neofs_env, neo_go, wallet, neo_go_wallet_config)), (
"Wallet balance is not correct after"
)
11 changes: 6 additions & 5 deletions pytest_tests/tests/payment/test_container_payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
from helpers.file_helper import generate_file
from helpers.neofs_verbs import put_object
from helpers.node_management import restart_storage_nodes
from helpers.wallet_helpers import get_neofs_balance, get_wallet_balance
from helpers.wallet_helpers import (
get_neofs_balance,
get_wallet_balance,
wait_for_correct_neofs_balance,
)
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
from neofs_testlib.utils import wallet as wallet_utils

Expand Down Expand Up @@ -64,10 +68,7 @@ def wallet_with_money(neofs_env_with_mainchain: NeoFSEnv) -> NodeWallet:
assert get_wallet_balance(neofs_env, neo_go, wallet, wallet.neo_go_config) <= 900, (
"Wallet balance is not correct after deposit"
)
neofs_cli = neofs_env.neofs_cli(wallet.cli_config)
assert get_neofs_balance(neofs_env, neofs_cli, wallet) == 100, (
"Wallet balance in neofs is not correct after deposit"
)
wait_for_correct_neofs_balance(neofs_env, wallet, wallet.cli_config, lambda balance: balance == 100)

return wallet

Expand Down
20 changes: 7 additions & 13 deletions pytest_tests/tests/payment/test_deposit_withdrawal.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import allure
from helpers.test_control import wait_for_success
from helpers.wallet_helpers import get_neofs_balance, get_wallet_balance
from helpers.wallet_helpers import (
get_wallet_balance,
wait_for_correct_neofs_balance,
wait_for_correct_wallet_balance,
)
from neofs_testlib.env.env import NeoFSEnv, NodeWallet
from neofs_testlib.utils import wallet as wallet_utils


@allure.step("Wait for correct neofs balance")
@wait_for_success(60, 5)
def wait_for_correct_neofs_balance(
neofs_env: NeoFSEnv, wallet: NodeWallet, cli_wallet_config: str, compare_func: callable
):
neofs_cli = neofs_env.neofs_cli(cli_wallet_config)
assert compare_func(get_neofs_balance(neofs_env, neofs_cli, wallet)), "Wallet balance in neofs is not correct"


class TestDepositWithdrawal:
def test_deposit_withdrawal(self, neofs_env_with_mainchain: NeoFSEnv):
neofs_env = neofs_env_with_mainchain
Expand Down Expand Up @@ -72,6 +66,6 @@ def test_deposit_withdrawal(self, neofs_env_with_mainchain: NeoFSEnv):
force=True,
)
wait_for_correct_neofs_balance(neofs_env, wallet, cli_wallet_config, lambda balance: balance == 50)
assert get_wallet_balance(neofs_env, neo_go, wallet, neo_go_wallet_config) > 940, (
"Wallet balance is not correct after withdrawal"
wait_for_correct_wallet_balance(
neofs_env, neo_go, wallet, neo_go_wallet_config, lambda balance: balance > 940
)

0 comments on commit f2fbc53

Please sign in to comment.