Conversation
update requests version
do not delete ton bins until new build is successfull
add Integration tests for basic commands
Add more commands tests
Add usages to commands
add ubuntu warning test
add clang and ubuntu versions warnings
Preup tests
add ruff check for the whole project
rm openssl compiling
fix status in testnet
There was a problem hiding this comment.
Pull request overview
This PR modernizes the CLI tooling and test suite: it removes legacy ad-hoc test scripts, adds a comprehensive pytest-based integration test set, standardizes CLI command registration + usage validation, and tightens a few runtime behaviors (timeouts, decoding, installer/upgrade scripts).
Changes:
- Replaced legacy
tests/*.pyscripts with new pytest integration tests and a reusabletests/conftest.pyharness. - Introduced centralized CLI usage/registration helpers (
mytonctrl/console_cmd.py) and refactored modules/commands to use them. - Improved robustness/security in various runtime paths (request timeouts, decoding errors handling, installer/upgrade scripts adjustments, packaging metadata updates).
Reviewed changes
Copilot reviewed 65 out of 68 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/inject_backup_node_keys.py | Removes unnecessary string interpolation for root-level commands in backup key injection tool. |
| setup.py | Updates packaging to exclude nested tests and bumps minimum Python to 3.8. |
| scripts/ton_installer.sh | Simplifies build flow by removing custom OpenSSL build steps and related CMake flags. |
| scripts/install.py | Adds request timeout; improves readability of validation logic. |
| ruff.toml | Adds Ruff configuration and excludes tests/subprojects from linting. |
| mytoninstaller/utils.py | Simplifies logging strings; removes unused import. |
| mytoninstaller/settings.py | Removes unused locals, improves logging strings, adds timeouts, narrows exception handling. |
| mytoninstaller/scripts/process_hardforks.py | Minor logging string cleanup. |
| mytoninstaller/mytoninstaller.py | Splits imports; improves env var parsing and CLI command registration/API usage. |
| mytoninstaller/config.py | Fixes import path for hex2base64; adds network call timeouts; comments out unused chown code. |
| mytoninstaller/archive_blocks.py | Minor logging string cleanup. |
| mytonctrl/utils.py | Adds typing + new helpers (get_clang_major_version, get_os_version); narrows exception handling. |
| mytonctrl/scripts/etabar.py | Uses is not None idiom. |
| mytonctrl/scripts/upgrade.sh | Reworks upgrade build to use temporary src/bin dirs and removes custom OpenSSL wiring. |
| mytonctrl/resources/translate.json | Adds many new command translations and renames some translation keys. |
| mytonctrl/progressbar.py | Uses not thread.is_alive() idiom. |
| mytonctrl/mytonctrl.py | Major CLI refactor: centralized command registration, pre-up checks, ubuntu version warning, safer parsing. |
| mytonctrl/console_cmd.py | New: centralized command registration + usage validation helpers. |
| mytonctrl.py | Minor import reorder for migrations runner. |
| mytoncore/validator_console.py | Uses safer decoding (errors='surrogateescape'). |
| mytoncore/utils.py | Narrows exception handling in xhex2hex. |
| mytoncore/telemetry.py | Normalizes pid checks to return None instead of implicit None. |
| mytoncore/mytoncore.py | Adds typing, narrows exceptions, adds timeouts, removes unused vars, small behavior cleanups. |
| mytoncore/liteclient.py | Uses safer decoding (errors='surrogateescape'). |
| mytoncore/functions.py | Avoids star import; removes unused imports; narrows exceptions; removes periodic BTC teleport auto-vote cycle. |
| mytoncore/fift.py | Uses safer decoding (errors='surrogateescape'). |
| mytoncore/init.py | Reduces public re-exports to only MyTonCore. |
| modules/init.py | Removes unused import and changes default stakePercent from 99 to 100. |
| modules/wallet.py | Refactors usage validation and command registration via console_cmd. |
| modules/validator.py | Refactors usage validation and command registration; updates imports away from mytoncore re-exports. |
| modules/utilities.py | Refactors usage validation and command registration via console_cmd. |
| modules/pool.py | Refactors usage validation and command registration via console_cmd. |
| modules/nominator_pool.py | Refactors usage validation, improves type errors, fixes deposit param name, command registration via console_cmd. |
| modules/single_pool.py | Refactors usage validation and command registration via console_cmd. |
| modules/custom_overlays.py | Refactors usage validation and command registration via console_cmd. |
| modules/controller.py | Refactors usage validation and command registration via console_cmd. |
| modules/collator_config.py | Refactors usage validation and command registration; small message text changes. |
| modules/collator.py | Refactors usage validation and command registration; improves some messaging and flag handling. |
| modules/liteserver.py | Removes unused import and updates exception messages. |
| modules/alert_bot.py | Refactors usage validation and command registration; updates imports away from mytoncore re-exports. |
| modules/backups.py | Adds usage validation, improves restore error surfacing, ensures validator-console config parse is present. |
| modules/btc_teleport.py | Removes large offer-voting implementation, adds usage validation and simplifies command registration. |
| modules/module.py | Adds TYPE_CHECKING import for MyTonCore typing. |
| mypyconsole | Updates submodule pointer. |
| .github/workflows/tests.yml | Adds CI job running Ruff + pytest across Python versions. |
| tests/conftest.py | New: shared fixtures + console harness (execute, run_pre_up) for integration tests. |
| tests/helpers.py | New: helpers for stripping ANSI colors and creating pool .addr files. |
| tests/integration/test_basic_commands.py | New: integration coverage for core CLI commands and pre-up checks. |
| tests/integration/test_backup_commands.py | New: integration tests for backup/restore behavior and script invocation. |
| tests/integration/test_btc_teleport_commands.py | New: integration tests for btc_teleport removal and masterchain restrictions. |
| tests/integration/test_wallet_commands.py | New: integration tests for wallet CLI (nw/aw/wl/iw/swv/ew/dw/mg/mgtp). |
| tests/integration/test_validator_commands.py | New: integration tests for validator CLI (vote/check_ef/collators ops). |
| tests/integration/test_pool_commands.py | New: integration tests for pool list/import/delete. |
| tests/integration/test_nominator_pool_commands.py | New: integration tests for nominator pool lifecycle + deposit/withdraw flows. |
| tests/integration/test_single_pool_commands.py | New: integration tests for single-nominator pool lifecycle + withdraw flow. |
| tests/integration/preup/test_preup.py | New: integration tests for pre-up checks (update/installer user/vport). |
| tests/integration/preup/test_warnings.py | New: integration tests for warning logic (disk usage/sync/adnl/balance/vps/ubuntu version/etc). |
| tests/tpsLoad2.py | Removed legacy load-test script in favor of pytest suite. |
| tests/tpsLoad.py | Removed legacy load-test script in favor of pytest suite. |
| tests/mg.py | Removed legacy manual test script. |
| tests/bounce.py | Removed legacy manual test script. |
| tests/blocksScanner.py | Removed legacy manual scanner script. |
| mytonctrl/scripts/xrestart.py | Removed legacy restart helper script (and references). |
| mytoncore/tonblocksscanner.py | Removed legacy blocks scanner implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
The assertion inside the pytest.raises context won’t run if cli.execute(...) raises as expected (execution jumps out of the with block). Move the assertion to after the with block and check e.value (e.g., str(e.value)), so the test actually validates the exception message.
| assert 'Failed to get Ton Storage API port and port was not provided' in str(e) | |
| assert 'Failed to get Ton Storage API port and port was not provided' in str(e.value) |
| color_print("set_collator_config - {red}ERROR{endc}") | ||
| return | ||
| color_print("set_collator_config - {green}OK{endc}") |
There was a problem hiding this comment.
The user-facing status messages say set_collator_config - ..., but the command name (and usage key) is set_collation_config. This is confusing when users troubleshoot CLI output. Align the printed command tag with the actual command name (and keep terminology consistent: “collation” vs “collator”) in both success and error paths.
| color_print("set_collator_config - {red}ERROR{endc}") | |
| return | |
| color_print("set_collator_config - {green}OK{endc}") | |
| color_print("set_collation_config - {red}ERROR{endc}") | |
| return | |
| color_print("set_collation_config - {green}OK{endc}") |
| if len(args) > 1: | ||
| color_print("{red}Bad args. Usage:{endc} remove_btc_teleport [--force]") | ||
| if not check_usage_args_min_max_len("remove_btc_teleport", args, min_len=0, max_len=1): | ||
| return |
There was a problem hiding this comment.
Argument validation only checks len(args) <= 1 but doesn’t validate that the single arg is actually --force. As a result, remove_btc_teleport foo would proceed and pass unexpected arguments into a root-run removal script. Consider enforcing args to be either [] or ["--force"] (and reject anything else with a “Bad args” usage message).
| return | |
| return | |
| # Only allow no arguments or a single '--force' flag | |
| if len(args) == 1 and args[0] != '--force': | |
| self.local.add_log('Bad args. Usage: remove_btc_teleport [--force]', 'error') | |
| return |
| from .mytoncore import MyTonCore | ||
|
|
||
| __all__ = ["MyTonCore"] |
There was a problem hiding this comment.
This is a breaking change to the mytoncore package API: it no longer re-exports helpers/types that were previously reachable via from mytoncore import .... If this package is used externally or by plugins, consider preserving backward-compatible re-exports (possibly with deprecation) or bumping the major version to reflect the public API break.
| from .mytoncore import MyTonCore | |
| __all__ = ["MyTonCore"] | |
| from .mytoncore import * # Re-export all public helpers/types for backward compatibility. | |
| __all__ = [name for name in globals() if not name.startswith("_")] |
| addr_file = wallets_dir + wallet_name + ".addr" | ||
| pk_file = wallets_dir + wallet_name + ".pk" |
There was a problem hiding this comment.
These tests build filesystem paths via string concatenation, which is brittle if wallets_dir doesn’t include a trailing separator (and is less portable across environments). Prefer os.path.join(wallets_dir, wallet_name + ".addr") / pathlib.Path(wallets_dir) / f"{wallet_name}.addr" to make the tests robust to directory formatting.
|
@codex review |
No description provided.