From 5a6c260e814cb029bc6460378c16d945e919befb Mon Sep 17 00:00:00 2001 From: Alexey Chursinau Date: Thu, 14 Mar 2024 14:20:34 +0100 Subject: [PATCH 1/2] Add assert to test_single_chain_single_cffm_route_full_symmetry_exist --- .../simulation/routers/oracles/test_bforacle.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mantis/simulation/routers/oracles/test_bforacle.py b/mantis/simulation/routers/oracles/test_bforacle.py index 1b674cd9..a62c77a2 100644 --- a/mantis/simulation/routers/oracles/test_bforacle.py +++ b/mantis/simulation/routers/oracles/test_bforacle.py @@ -2,6 +2,7 @@ # clarabel cvxpy local mip import copy import itertools +import pytest import numpy as np from loguru import logger @@ -37,15 +38,23 @@ def populate_chain_dict(chains: dict[TNetworkId, list[TId]], center_node: TNetwo if chain != center_node: chains[chain].extend(f"{center_node}/{token}" for token in chains[center_node] if f"{chain}/" not in token) - +@pytest.mark.run_these_tests def test_single_chain_single_cffm_route_full_symmetry_exist(): input = new_input(1, 2, 100, 50) pair = new_pair(1, 1, 2, 0, 0, 1, 1, 100, 1_000_000, 1_000_000) data = new_data([pair], []) result = route(input, data) logger.info(result) - - + logger.info(len(result)) + logger.info("") + logger.info(input) + logger.info(pair) + logger.info(data) + assert len(result) == 1, "The list of routes is empty or contains too many items. A single route is expected to be present." + assert result[0].in_asset_id == input.in_asset_id, f"Expected in_asset_id={input.in_asset_id}, received {result[0].in_asset_id}" + assert result[0].out_asset_id == input.out_asset_id, f"Expected out_asset_id={input.out_asset_id}, received {result[0].out_asset_id}" + +@pytest.mark.run_these_tests def test_big_numeric_range_one_pair_of_same_value(): in_amount = 10000 input = new_input(1, 5, in_amount, 50) From 86b9a190fed19124d7a58709e31ebfbab15b9959 Mon Sep 17 00:00:00 2001 From: Alexey Chursinau Date: Thu, 14 Mar 2024 14:51:50 +0100 Subject: [PATCH 2/2] Add two asserts to check in & out asset id --- mantis/simulation/routers/oracles/test_bforacle.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mantis/simulation/routers/oracles/test_bforacle.py b/mantis/simulation/routers/oracles/test_bforacle.py index a62c77a2..48fad193 100644 --- a/mantis/simulation/routers/oracles/test_bforacle.py +++ b/mantis/simulation/routers/oracles/test_bforacle.py @@ -13,6 +13,7 @@ AssetTransfers, Ctx, Input, + SingleInputAssetCvmRoute, TId, TNetworkId, new_data, @@ -50,9 +51,11 @@ def test_single_chain_single_cffm_route_full_symmetry_exist(): logger.info(input) logger.info(pair) logger.info(data) + assert isinstance(result, list), "The result is expected to be a list." + assert all(isinstance(route, SingleInputAssetCvmRoute) for route in result), "All result elements must be of the SingleInputAssetCvmRoute type." assert len(result) == 1, "The list of routes is empty or contains too many items. A single route is expected to be present." - assert result[0].in_asset_id == input.in_asset_id, f"Expected in_asset_id={input.in_asset_id}, received {result[0].in_asset_id}" - assert result[0].out_asset_id == input.out_asset_id, f"Expected out_asset_id={input.out_asset_id}, received {result[0].out_asset_id}" + assert result[0].next[0].in_asset_id == input.in_asset_id, f"Expected in_asset_id={input.in_asset_id}, received {result[0].next[0].in_asset_id}" + assert result[0].next[0].out_asset_id == input.out_asset_id, f"Expected out_asset_id={input.out_asset_id}, received {result[0].next[0].out_asset_id}" @pytest.mark.run_these_tests def test_big_numeric_range_one_pair_of_same_value():