From ce28ad6e10563589b5f42d1e36800dca9250ec79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kudela?= Date: Tue, 3 Oct 2023 10:28:14 +0200 Subject: [PATCH] Add tests for modify `HIVE_OWNER_UPDATE_LIMIT` --- .../test_modify_hive_owner_update_limit.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/python/functional/foundation_layer_tests/test_modify_hive_owner_update_limit.py diff --git a/tests/python/functional/foundation_layer_tests/test_modify_hive_owner_update_limit.py b/tests/python/functional/foundation_layer_tests/test_modify_hive_owner_update_limit.py new file mode 100644 index 0000000000..7a241836a2 --- /dev/null +++ b/tests/python/functional/foundation_layer_tests/test_modify_hive_owner_update_limit.py @@ -0,0 +1,40 @@ +import pytest + +import test_tools as tt +from hive_local_tools.constants import ALTERNATE_CHAIN_JSON_FILENAME +from hive_local_tools.functional.python import change_hive_owner_update_limit + + +@pytest.mark.testnet +@pytest.mark.parametrize("limit", [6, 15, 30, 45, 90, 180, 360, 720]) +def test_modify_hive_owner_update_limit(limit): + change_hive_owner_update_limit(seconds_limit=limit) + + node = tt.InitNode() + node.run( + arguments=["--alternate-chain-spec", str(tt.context.get_current_directory() / ALTERNATE_CHAIN_JSON_FILENAME)] + ) + + limit_in_microseconds = node.api.database.get_config()["HIVE_OWNER_UPDATE_LIMIT"] + assert limit_in_microseconds / 1_000_000 == limit, "The `HIVE_OWNER_UPDATE_LIMIT` was not updated correctly." + + +@pytest.mark.testnet +@pytest.mark.parametrize( + "limit", + [ + 5, # the limit cannot be less than default (6 second), + 7, # the limit must be divisible by 3, + ], +) +def test_invalid_hive_owner_update_limit_modification(limit): + change_hive_owner_update_limit(seconds_limit=limit) + + node = tt.InitNode() + with pytest.raises(TimeoutError): + node.run( + arguments=[ + "--alternate-chain-spec", + str(tt.context.get_current_directory() / ALTERNATE_CHAIN_JSON_FILENAME), + ] + )