mirror of
https://github.com/basicswap/basicswap.git
synced 2026-05-08 23:42:12 +02:00
test: add balance check to test_swap_direction.py
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2022-2023 tecnovert
|
# Copyright (c) 2022-2023 tecnovert
|
||||||
# Copyright (c) 2024-2025 The Basicswap developers
|
# Copyright (c) 2024-2026 The Basicswap developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@@ -23,6 +23,25 @@ if not len(logger.handlers):
|
|||||||
logger.addHandler(logging.StreamHandler(sys.stdout))
|
logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_balance(
|
||||||
|
port: int,
|
||||||
|
coin: str,
|
||||||
|
expect_amount: float,
|
||||||
|
balance_key: str = "balance",
|
||||||
|
iterations: int = 30,
|
||||||
|
delay_time: int = 1,
|
||||||
|
) -> None:
|
||||||
|
logger.info(f"Waiting for balance, port: {port}")
|
||||||
|
for i in range(iterations):
|
||||||
|
rv_js = read_json_api(port, f"wallets/{coin}")
|
||||||
|
if float(rv_js[balance_key]) >= expect_amount:
|
||||||
|
return
|
||||||
|
time.sleep(delay_time)
|
||||||
|
|
||||||
|
logger.warning(f"{port} wallets/{coin} {rv_js}")
|
||||||
|
raise ValueError(f"Expect {balance_key} {expect_amount}")
|
||||||
|
|
||||||
|
|
||||||
def clear_offers(port_list) -> None:
|
def clear_offers(port_list) -> None:
|
||||||
logger.info(f"clear_offers {port_list}")
|
logger.info(f"clear_offers {port_list}")
|
||||||
|
|
||||||
@@ -82,6 +101,8 @@ def test_swap_dir(driver):
|
|||||||
logger.info(f"rv: {rv}")
|
logger.info(f"rv: {rv}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
wait_for_balance(node_2_port, "xmr", 5.0)
|
||||||
|
|
||||||
offer_data = {
|
offer_data = {
|
||||||
"addr_from": -1,
|
"addr_from": -1,
|
||||||
"coin_from": "XMR",
|
"coin_from": "XMR",
|
||||||
|
|||||||
Reference in New Issue
Block a user