From 063e54d60b7cc9aba1c440ab5d6f6f1094cfe767 Mon Sep 17 00:00:00 2001 From: Tulio Miranda Date: Sat, 21 Feb 2026 07:06:54 -0300 Subject: [PATCH] feat: add --test-mode-block-weight CLI flag Expose the existing TestMode.TEST_BLOCK_WEIGHT via a CLI flag, making block mining trivial (weight=1) for integration testing. Requires --unsafe-mode, same as --test-mode-tx-weight. --- hathor_cli/builder.py | 4 +++- hathor_cli/run_node.py | 3 +++ hathor_cli/run_node_args.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hathor_cli/builder.py b/hathor_cli/builder.py index e0bb6de07..6cc886c78 100644 --- a/hathor_cli/builder.py +++ b/hathor_cli/builder.py @@ -273,9 +273,11 @@ def create_manager(self, reactor: Reactor) -> HathorManager: test_mode = TestMode.DISABLED if self._args.test_mode_tx_weight: - test_mode = TestMode.TEST_TX_WEIGHT + test_mode |= TestMode.TEST_TX_WEIGHT if self.wallet: self.wallet.test_mode = True + if self._args.test_mode_block_weight: + test_mode |= TestMode.TEST_BLOCK_WEIGHT daa = DifficultyAdjustmentAlgorithm(settings=settings, test_mode=test_mode) diff --git a/hathor_cli/run_node.py b/hathor_cli/run_node.py index ddef45847..5b4a34a66 100644 --- a/hathor_cli/run_node.py +++ b/hathor_cli/run_node.py @@ -49,6 +49,7 @@ def temp_fifo(filename: str, tempdir: str | None) -> Iterator[None]: class RunNode: UNSAFE_ARGUMENTS: list[tuple[str, Callable[['RunNodeArgs'], bool]]] = [ ('--test-mode-tx-weight', lambda args: bool(args.test_mode_tx_weight)), + ('--test-mode-block-weight', lambda args: bool(args.test_mode_block_weight)), ('--enable-crash-api', lambda args: bool(args.enable_crash_api)), ('--sync-bridge', lambda args: bool(args.sync_bridge)), ('--sync-v1-only', lambda args: bool(args.sync_v1_only)), @@ -87,6 +88,8 @@ def create_parser(cls) -> ArgumentParser: parser.add_argument('--test-mode-tx-weight', action='store_true', help='Reduces tx weight to 1 for testing purposes') + parser.add_argument('--test-mode-block-weight', action='store_true', + help='Reduces block weight to 1 for testing purposes') parser.add_argument('--dns', action='append', help='Seed DNS') parser.add_argument('--peer', help='json file with peer info') parser.add_argument('--sysctl', diff --git a/hathor_cli/run_node_args.py b/hathor_cli/run_node_args.py index 89b0d2826..7fe1f2e2e 100644 --- a/hathor_cli/run_node_args.py +++ b/hathor_cli/run_node_args.py @@ -35,6 +35,7 @@ class RunNodeArgs(BaseModel): testnet_hotel: bool testnet_golf: bool test_mode_tx_weight: bool + test_mode_block_weight: bool dns: Optional[str] peer: Optional[str] sysctl: Optional[str]