Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Nov 1, 2024
1 parent 512c9b6 commit d8c2b7b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ tests/skale-data/contracts_info/schain_ima_abi.json
temp_*

.DS_Store
.coverage*
.coverage*

.env
9 changes: 8 additions & 1 deletion tests/routes/node_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import socket
import datetime
import glob
import shutil
import socket

import pytest
import mock
Expand All @@ -15,6 +17,7 @@
from core.node import Node, NodeStatus
from core.node_config import NodeConfig
from core.schains.config.file_manager import ConfigFileManager
from tools.configs.schains import SCHAINS_DIR_PATH
from tools.configs.tg import TG_API_KEY, TG_CHAT_ID
from web.routes.node import node_bp
from web.helper import get_api_url
Expand Down Expand Up @@ -259,6 +262,10 @@ def test_exit_maintenance(skale_bp, node_config_in_maintenance):


def test_update_safe(skale, schain_on_contracts, schain_config, upstreams, skale_bp):
for path in glob.glob(f'{SCHAINS_DIR_PATH}/*'):
if not path.endswith(schain_on_contracts):
shutil.rmtree(path)

data = get_bp_data(
skale_bp,
get_api_url(BLUEPRINT_NAME, 'update-safe'),
Expand Down
2 changes: 1 addition & 1 deletion tests/routes/schains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_get_schain(
'id': schain_id,
'mainnet_owner': skale.wallet.address,
'part_of_node': 1, 'dkg_status': 1, 'is_deleted': False,
'first_run': True, 'repair_mode': False
'first_run': True, 'repair_ts': int(r.repair_date.timestamp())
}
}

Expand Down
15 changes: 6 additions & 9 deletions web/routes/schains.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import logging
from dataclasses import asdict

from flask import Blueprint, g, request

Expand Down Expand Up @@ -89,15 +90,11 @@ def schains_list():
node_id = g.config.id
if node_id is None:
return construct_err_response(msg='No node installed')
schains_list = list(
filter(
lambda s: s,
map(
lambda s: s.name,
g.skale.schains.get_schains_for_node(node_id)
)
)
)
schains_list = [
asdict(s)
for s in g.skale.schains.get_schains_for_node(node_id)
if s and s.name != ''
]
return construct_ok_response(schains_list)


Expand Down

0 comments on commit d8c2b7b

Please sign in to comment.