Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Oct 18, 2023
1 parent 5761a9c commit d272fe1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion skale/utils/contracts_provision/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

def _skip_evm_time(web3: Web3, seconds: int, mine: bool = True) -> int:
"""For test purposes only, works only with hardhat node"""
res = web3.provider.make_request('evm_increaseTime', [seconds * 1000])
res = web3.provider.make_request('evm_increaseTime', [seconds])
web3.provider.make_request("evm_mine", [])
return int(res['result'])

Expand Down
8 changes: 3 additions & 5 deletions tests/manager/delegation/delegation_controller_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
""" Tests for contracts/delegation/delegation_controller.py """

from datetime import date

import pytest

from skale.contracts.manager.delegation.delegation_controller import FIELDS
Expand Down Expand Up @@ -36,7 +34,7 @@ def _delegate_and_activate(skale, validator_id=D_VALIDATOR_ID):
delegations[-1]['id'],
wait_for=True
)
_skip_evm_time(skale.web3, MONTH_IN_SECONDS)
_skip_evm_time(skale.web3, MONTH_IN_SECONDS, mine=False)


def _get_number_of_delegations(skale, validator_id=D_VALIDATOR_ID):
Expand Down Expand Up @@ -98,10 +96,10 @@ def test_delegate(skale, validator):
assert delegated_now_after == delegated_now_before + D_DELEGATION_AMOUNT
assert delegated_amount_after == delegated_amount_before + D_DELEGATION_AMOUNT

month = date.fromtimestamp(skale.web3.eth.get_block('latest')['timestamp']).month
month = skale.time_helpers_with_debug.get_current_month()
res = skale.delegation_controller.get_delegated_to_validator(
validator_id,
month * 100
month
)
assert isinstance(res, int)

Expand Down
3 changes: 2 additions & 1 deletion tests/manager/delegation/validator_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def test_set_validator_description(skale):


def test_revert_reason(skale):
no_validator_revert = "VM Exception while processing transaction: reverted with reason string 'Validator with such address already exists'" # noqa
try:
skale.validator_service.register_validator(
name=D_VALIDATOR_NAME,
Expand All @@ -402,7 +403,7 @@ def test_revert_reason(skale):
wait_for=True
)
except RevertError as e:
assert e.message == "{'code': -32603, 'message': \"Error: VM Exception while processing transaction: reverted with reason string 'Validator with such address already exists'\"}" # noqa
assert no_validator_revert in e.message


def test_get_use_whitelist(skale):
Expand Down
2 changes: 0 additions & 2 deletions tests/manager/node_rotation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ def four_node_schain(skale, validator):


def test_is_rotation_active(skale, four_node_schain):
# cleanup_nodes_schains(skale)
nodes, skale_instances, name = four_node_schain
# add_test4_schain_type(skale)
group_index = skale.web3.keccak(text=name)

run_dkg(nodes, skale_instances, group_index)
Expand Down
6 changes: 4 additions & 2 deletions tests/manager/sync_manager_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from web3.exceptions import ContractLogicError

from skale.transactions.exceptions import RevertError

import pytest
Expand Down Expand Up @@ -50,9 +52,9 @@ def test_remove_range_bad_params(skale, sync_manager_permissions, block_in_secon
def test_get_range_bad_params(skale, sync_manager_permissions, block_in_second):
num = skale.sync_manager.get_ip_ranges_number()
# TODO: Make dry run handle revert that has empty reason properly
with pytest.raises(ValueError):
with pytest.raises(ContractLogicError):
r = skale.sync_manager.get_ip_range_by_index(num)
with pytest.raises(ValueError):
with pytest.raises(ContractLogicError):
r = skale.sync_manager.get_ip_range_by_index(0)
r = skale.sync_manager.get_ip_range_by_name('phantom')
assert r.start_ip == '0.0.0.0' and r.end_ip == '0.0.0.0'

0 comments on commit d272fe1

Please sign in to comment.