Skip to content
Merged

Dev #507

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
627099c
do not delete ton bins until new build is successfull
yungwine Dec 4, 2025
2c61ce0
add integration tests for basic commands
yungwine Dec 8, 2025
6d0fe1f
delete unused tests
yungwine Dec 8, 2025
34cf446
fix download_archive_blocks --only-master
yungwine Dec 10, 2025
3adcc37
update requests version
yungwine Dec 10, 2025
f0448bc
Merge pull request #497 from yungwine/reqs
yungwine Dec 10, 2025
b4d6a77
Merge pull request #498 from yungwine/upgrade
yungwine Dec 10, 2025
708ac52
add github workflow for running tests
yungwine Dec 10, 2025
7c71814
Merge pull request #499 from yungwine/integration
yungwine Dec 10, 2025
b9b91ab
add backups integration tests
yungwine Dec 11, 2025
3629107
add ruff linting to mytonctrl/
yungwine Dec 12, 2025
03f2efa
upd min python version to 3.8
yungwine Dec 12, 2025
6454498
add building project to workflow, test project as package
yungwine Dec 12, 2025
023c227
rm btc teleport offer functionality
yungwine Sep 14, 2025
c58a3b2
add btc teleport tests
yungwine Dec 12, 2025
91b8bf0
improve modules/backups code
yungwine Dec 12, 2025
71ad67d
add usages to every command
yungwine Sep 22, 2025
72fa4e3
rm btc teleport offer functionality
yungwine Sep 14, 2025
d49b609
add btc teleport tests
yungwine Dec 12, 2025
ead3edd
improve modules/backups code
yungwine Dec 12, 2025
bd9882f
add validator command tests
yungwine Dec 16, 2025
03474aa
add wallet commands tests
yungwine Dec 19, 2025
7bc2e9e
add pool commands tests
yungwine Dec 19, 2025
8a952a5
add nominator pool commands tests
yungwine Dec 19, 2025
3ba9486
add single nominator pool commands tests
yungwine Dec 19, 2025
4f79bc3
fix cli fixture creation in tests
yungwine Dec 19, 2025
0b8269c
rm memory warning from tests
yungwine Dec 19, 2025
4d21162
Merge pull request #500 from yungwine/integration
yungwine Dec 22, 2025
93b00d7
fix merge
yungwine Dec 12, 2025
0a5d370
upd mypyconsole
yungwine Oct 2, 2025
21edd19
update aw command usage
yungwine Dec 22, 2025
bd7e7c9
Merge branch 'dev' into usage2
yungwine Dec 22, 2025
a6d0ca9
rm some unused imports
yungwine Dec 22, 2025
e1d654e
fix aw test
yungwine Dec 22, 2025
54bf61a
Merge pull request #501 from yungwine/usage2
yungwine Dec 22, 2025
429488a
upd min required clang version
yungwine Jan 9, 2026
ff06f76
add ubuntu version warning on console launch
yungwine Jan 9, 2026
a2e5ec5
Merge pull request #502 from yungwine/clang
yungwine Jan 9, 2026
e43c6ab
add timeout to all requests
yungwine Jan 13, 2026
61ded42
rm console in debug mode from tests
yungwine Jan 13, 2026
0a55cb2
add warnings tests
yungwine Jan 13, 2026
7d32f79
make preup function handle exceptions
yungwine Jan 13, 2026
44c8c46
add preup tests
yungwine Jan 13, 2026
5822802
Merge pull request #503 from yungwine/preup-tests
yungwine Jan 13, 2026
0422e74
add ruff check modules
yungwine Jan 16, 2026
a5d5b0e
add ruff check mytoninstaller
yungwine Jan 19, 2026
ad411db
add ruff check mytoncore
yungwine Jan 19, 2026
077514a
add ruff check for whole project
yungwine Jan 19, 2026
1ab9626
Merge pull request #504 from yungwine/lint
yungwine Jan 19, 2026
60c63f4
fix mytoncore import
yungwine Jan 19, 2026
4299f22
rm openssl compiling
yungwine Jan 31, 2026
fc525f3
Merge pull request #505 from yungwine/openssl
yungwine Jan 31, 2026
b4a367e
add try to GetOnlineValidators in status
yungwine Jan 31, 2026
7d67466
handle non utf-8 symbols in binaries output
yungwine Jan 31, 2026
4c86119
Merge pull request #506 from yungwine/status
yungwine Jan 31, 2026
f80142f
allow empty strings for port envs
yungwine Feb 3, 2026
f02903f
fix test_download_archive_blocks
yungwine Feb 9, 2026
51e11ca
bump requests version in ton_installer.sh
yungwine Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lint + Tests

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v5
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ruff pytest pytest-mock

- name: Run Ruff
run: |
ruff check

- name: Build project
run: |
pip install -U .

- name: Run pytest
run: |
pytest --import-mode=append # to test built package
3 changes: 1 addition & 2 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from modules.collator import CollatorModule
from modules.module import MtcModule
from modules.pool import PoolModule
from modules.nominator_pool import NominatorPoolModule
from modules.single_pool import SingleNominatorModule
from modules.validator import ValidatorModule
Expand Down Expand Up @@ -38,7 +37,7 @@ class Setting:

SETTINGS = {
'stake': Setting('validator', None, 'Stake amount'),
'stakePercent': Setting('validator', 99, 'Stake percent if `stake` is null'),
'stakePercent': Setting('validator', 100, 'Stake percent if `stake` is null'),
'isSlashing': Setting('validator', None, 'Create complaints to validators'),
'validatorWalletName': Setting('validator', 'wallet_001', 'Validator\'s wallet name'),
'maxFactor': Setting('validator', None, 'Param send to Elector. if null will be taken from 17 config param'),
Expand Down
27 changes: 14 additions & 13 deletions modules/alert_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from modules.module import MtcModule
from mypylib.mypylib import get_timestamp, print_table, color_print
from mytoncore import get_hostname, signed_int_to_hex64
from mytoncore.utils import get_hostname, signed_int_to_hex64
from mytonctrl.console_cmd import add_command, check_usage_one_arg, check_usage_two_args
from mytonctrl.utils import timestamp2utcdatetime


Expand Down Expand Up @@ -333,15 +334,15 @@ def _is_alert_active(self, alert_name: str) -> bool:
return self.get_alert_from_db(alert_name).get('active', False)

def enable_alert(self, args):
if len(args) != 1:
raise Exception("Usage: enable_alert <alert_name>")
if not check_usage_one_arg("enable_alert", args):
return
alert_name = args[0]
self.set_alert_enabled(alert_name, True)
color_print("enable_alert - {green}OK{endc}")

def disable_alert(self, args):
if len(args) != 1:
raise Exception("Usage: disable_alert <alert_name>")
if not check_usage_one_arg("disable_alert", args):
return
alert_name = args[0]
self.set_alert_enabled(alert_name, False)
color_print("disable_alert - {green}OK{endc}")
Expand All @@ -360,8 +361,8 @@ def test_alert(self, args):
self.send_message('Test alert')

def setup_alert_bot(self, args):
if len(args) != 2:
raise Exception("Usage: setup_alert_bot <bot_token> <chat_id>")
if not check_usage_two_args("setup_alert_bot", args):
return
self.token = args[0]
self.chat_id = args[1]
init_alerts()
Expand All @@ -373,7 +374,7 @@ def setup_alert_bot(self, args):
color_print("setup_alert_bot - {green}OK{endc}")
except Exception as e:
self.local.add_log(f"Error while sending welcome message: {e}", "error")
self.local.add_log(f"If you want the bot to write to a multi-person chat group, make sure the bot is added to that chat group. If it is not - do it and run the command `setup_alert_bot <bot_token> <chat_id>` again.", "info")
self.local.add_log("If you want the bot to write to a multi-person chat group, make sure the bot is added to that chat group. If it is not - do it and run the command `setup_alert_bot <bot_token> <chat_id>` again.", "info")
color_print("setup_alert_bot - {red}Error{endc}")

def send_welcome_message(self):
Expand Down Expand Up @@ -602,8 +603,8 @@ def check_status(self):
self.local.try_function(self.check_online_collators)

def add_console_commands(self, console):
console.AddItem("enable_alert", self.enable_alert, self.local.translate("enable_alert_cmd"))
console.AddItem("disable_alert", self.disable_alert, self.local.translate("disable_alert_cmd"))
console.AddItem("list_alerts", self.print_alerts, self.local.translate("list_alerts_cmd"))
console.AddItem("test_alert", self.test_alert, self.local.translate("test_alert_cmd"))
console.AddItem("setup_alert_bot", self.setup_alert_bot, self.local.translate("setup_alert_bot_cmd"))
add_command(self.local, console, "enable_alert", self.enable_alert)
add_command(self.local, console, "disable_alert", self.disable_alert)
add_command(self.local, console, "list_alerts", self.print_alerts)
add_command(self.local, console, "test_alert", self.test_alert)
add_command(self.local, console, "setup_alert_bot", self.setup_alert_bot)
30 changes: 15 additions & 15 deletions modules/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@
import shutil
import subprocess
import time
from typing import Optional

from modules.module import MtcModule
from mypylib.mypylib import color_print, ip2int, run_as_root, parse, MyPyClass
from mytonctrl.console_cmd import add_command, check_usage_args_min_max_len
from mypylib.mypylib import color_print, ip2int, run_as_root, parse
from mytoncore.utils import get_package_resource_path
from mytonctrl.utils import get_current_user, pop_user_from_args
from mytoninstaller.config import get_own_ip


class BackupModule(MtcModule):

def create_keyring(self, dir_name):
def create_keyring(self, dir_name: str):
keyring_dir = dir_name + '/keyring'
self.ton.validatorConsole.Run(f'exportallprivatekeys {keyring_dir}')

def create_tmp_ton_dir(self):
result = self.ton.validatorConsole.Run("getconfig")
text = parse(result, "---------", "--------")
if text is None:
raise Exception("Could not get config from validator-console")
dir_name = self.ton.tempDir + f'/ton_backup_{int(time.time() * 1000)}'
dir_name_db = dir_name + '/db'
os.makedirs(dir_name_db)
Expand All @@ -28,15 +32,14 @@ def create_tmp_ton_dir(self):
return dir_name

@staticmethod
def run_create_backup(args, user: str = None):
def run_create_backup(args, user: Optional[str] = None):
if user is None:
user = get_current_user()
with get_package_resource_path('mytonctrl', 'scripts/create_backup.sh') as backup_script_path:
return subprocess.run(["bash", backup_script_path, "-u", user] + args, timeout=5)

def create_backup(self, args):
if len(args) > 3:
color_print("{red}Bad args. Usage:{endc} create_backup [filename] [-u <user>]")
if not check_usage_args_min_max_len("create_backup", args, 0, 3):
return
tmp_dir = self.create_tmp_ton_dir()
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-t", tmp_dir]
Expand All @@ -51,23 +54,21 @@ def create_backup(self, args):
color_print("create_backup - {red}Error{endc}")
shutil.rmtree(tmp_dir)
return process.returncode
# end define

@staticmethod
def run_restore_backup(args, user: str = None):
def run_restore_backup(args, user: Optional[str] = None):
if user is None:
user = get_current_user()
with get_package_resource_path('mytonctrl', 'scripts/restore_backup.sh') as restore_script_path:
return run_as_root(["bash", restore_script_path, "-u", user] + args)

def restore_backup(self, args):
if len(args) == 0 or len(args) > 5:
color_print("{red}Bad args. Usage:{endc} restore_backup <filename> [-y] [--skip-create-backup] [-u <user>]")
if not check_usage_args_min_max_len('restore_backup', args, 1, 5):
return
user = pop_user_from_args(args)
if '-y' not in args:
res = input(
f'This action will overwrite existing configuration with contents of backup archive, please make sure that donor node is not in operation prior to this action. Proceed [y/n]')
'This action will overwrite existing configuration with contents of backup archive, please make sure that donor node is not in operation prior to this action. Proceed [y/n]')
if res.lower() != 'y':
print('aborted.')
return
Expand All @@ -79,8 +80,8 @@ def restore_backup(self, args):
print('Before proceeding, mtc will create a backup of current configuration.')
try:
self.create_backup([])
except:
color_print("{red}Could not create backup{endc}")
except Exception as e:
color_print(f"{{red}}Could not create backup: {e}{{endc}}")

ip = str(ip2int(get_own_ip()))
command_args = ["-m", self.ton.local.buffer.my_work_dir, "-n", args[0], "-i", ip]
Expand All @@ -94,8 +95,7 @@ def restore_backup(self, args):
self.local.exit()
else:
color_print("restore_backup - {red}Error{endc}")
# end define

def add_console_commands(self, console):
console.AddItem("create_backup", self.create_backup, self.local.translate("create_backup_cmd"))
console.AddItem("restore_backup", self.restore_backup, self.local.translate("restore_backup_cmd"))
add_command(self.local, console, "create_backup", self.create_backup)
add_command(self.local, console, "restore_backup", self.restore_backup)
Loading