Skip to content

Commit

Permalink
Addressing comment about this class not being a constant. see #399 (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewcasale committed Mar 28, 2024
1 parent 30039ae commit 180ac84
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 63 deletions.
63 changes: 63 additions & 0 deletions fastlane_bot/tests/deterministic/dtest_cmd_line_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from dataclasses import dataclass

from fastlane_bot.tools.cpc import T


@dataclass
class TestCommandLineArgs:
"""
This class is used to mock the command line arguments for the main.py
"""

cache_latest_only: str = "True"
backdate_pools: str = "True"
static_pool_data_filename: str = "static_pool_data_testing"
arb_mode: str = "multi_pairwise_all"
flashloan_tokens: str = (
f"{T.LINK},{T.NATIVE_ETH},{T.BNT},{T.WBTC},{T.DAI},{T.USDC},{T.USDT},{T.WETH}"
)
n_jobs: int = -1
exchanges: str = "carbon_v1,bancor_v3,bancor_v2,bancor_pol,uniswap_v3,uniswap_v2,sushiswap_v2,balancer,pancakeswap_v2,pancakeswap_v3"
polling_interval: int = 0
alchemy_max_block_fetch: int = 1
reorg_delay: int = 0
logging_path: str = "logs_dtest"
loglevel: str = "INFO"
use_cached_events: str = "False"
run_data_validator: str = "False"
randomizer: int = 1
limit_bancor3_flashloan_tokens: str = "True"
default_min_profit_gas_token: str = "0.002" # "0.01"
timeout: int = None
target_tokens: str = None
replay_from_block: int = None
tenderly_fork_id: int = None
tenderly_event_exchanges: str = "pancakeswap_v2,pancakeswap_v3"
increment_time: int = 1
increment_blocks: int = 1
blockchain: str = "ethereum"
pool_data_update_frequency: int = -1
use_specific_exchange_for_target_tokens: str = None
prefix_path: str = ""
version_check_frequency: int = 1
self_fund: str = "False"
read_only: str = "False"
is_args_test: str = "False"
rpc_url: str = None

@staticmethod
def args_to_command_line(args):
"""
Convert a TestCommandLineArgs instance to a list of command-line arguments.
Args:
args: An instance of TestCommandLineArgs.
Returns:
A list of command-line arguments.
"""
cmd_args = []
for field, value in args.__dict__.items():
if value is not None: # Only include fields that have a value
cmd_args.extend((f"--{field}", str(value)))
return cmd_args
61 changes: 0 additions & 61 deletions fastlane_bot/tests/deterministic/dtest_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
(c) Copyright Bprotocol foundation 2024.
Licensed under MIT License.
"""
from dataclasses import dataclass

from fastlane_bot.tools.cpc import T

KNOWN_UNABLE_TO_DELETE = {
68737038118029569619601670701217178714718: ("pDFS", "ETH"),
Expand Down Expand Up @@ -62,61 +59,3 @@
}


@dataclass
class TestCommandLineArgs:
"""
This class is used to mock the command line arguments for the main.py
"""

cache_latest_only: str = "True"
backdate_pools: str = "True"
static_pool_data_filename: str = "static_pool_data_testing"
arb_mode: str = "multi_pairwise_all"
flashloan_tokens: str = (
f"{T.LINK},{T.NATIVE_ETH},{T.BNT},{T.WBTC},{T.DAI},{T.USDC},{T.USDT},{T.WETH}"
)
n_jobs: int = -1
exchanges: str = "carbon_v1,bancor_v3,bancor_v2,bancor_pol,uniswap_v3,uniswap_v2,sushiswap_v2,balancer,pancakeswap_v2,pancakeswap_v3"
polling_interval: int = 0
alchemy_max_block_fetch: int = 1
reorg_delay: int = 0
logging_path: str = "logs_dtest"
loglevel: str = "INFO"
use_cached_events: str = "False"
run_data_validator: str = "False"
randomizer: int = 1
limit_bancor3_flashloan_tokens: str = "True"
default_min_profit_gas_token: str = "0.002" # "0.01"
timeout: int = None
target_tokens: str = None
replay_from_block: int = None
tenderly_fork_id: int = None
tenderly_event_exchanges: str = "pancakeswap_v2,pancakeswap_v3"
increment_time: int = 1
increment_blocks: int = 1
blockchain: str = "ethereum"
pool_data_update_frequency: int = -1
use_specific_exchange_for_target_tokens: str = None
prefix_path: str = ""
version_check_frequency: int = 1
self_fund: str = "False"
read_only: str = "False"
is_args_test: str = "False"
rpc_url: str = None

@staticmethod
def args_to_command_line(args):
"""
Convert a TestCommandLineArgs instance to a list of command-line arguments.
Args:
args: An instance of TestCommandLineArgs.
Returns:
A list of command-line arguments.
"""
cmd_args = []
for field, value in args.__dict__.items():
if value is not None: # Only include fields that have a value
cmd_args.extend((f"--{field}", str(value)))
return cmd_args
3 changes: 2 additions & 1 deletion fastlane_bot/tests/deterministic/dtest_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from web3 import Web3

from fastlane_bot.tests.deterministic.dtest_constants import KNOWN_UNABLE_TO_DELETE, TestCommandLineArgs
from fastlane_bot.tests.deterministic.dtest_constants import KNOWN_UNABLE_TO_DELETE
from fastlane_bot.tests.deterministic.dtest_cmd_line_args import TestCommandLineArgs
from fastlane_bot.tests.deterministic.dtest_manager import TestManager
from fastlane_bot.tests.deterministic.dtest_pool import TestPool
from fastlane_bot.tests.deterministic.dtest_pool_params_builder import TestPoolParamsBuilder
Expand Down
2 changes: 1 addition & 1 deletion fastlane_bot/tests/deterministic/dtest_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
ETH_ADDRESS,
TEST_DATA_DIR,
TOKENS_MODIFICATIONS,
TestCommandLineArgs,
)
from fastlane_bot.tests.deterministic.dtest_cmd_line_args import TestCommandLineArgs
from fastlane_bot.tests.deterministic.dtest_strategy import TestStrategy


Expand Down

0 comments on commit 180ac84

Please sign in to comment.