From d1eaf54ed173fa644b37e64d051aeb832f790473 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 20 May 2026 20:00:19 +0200 Subject: [PATCH] tests: replace monotonic --- tests/README.md | 2 +- tests/functional_tests/CMakeLists.txt | 4 ++-- tests/functional_tests/mining.py | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/README.md b/tests/README.md index 51b0e4847..d2bea14d5 100644 --- a/tests/README.md +++ b/tests/README.md @@ -50,7 +50,7 @@ Functional tests are located under the `tests/functional_tests` directory. Building all the tests requires installing the following dependencies: ```bash -pip install requests psutil monotonic zmq deepdiff +pip install requests psutil zmq deepdiff ``` First, run a regtest daemon in the offline mode and with a fixed difficulty: diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt index 1ba3743ae..64613fc65 100644 --- a/tests/functional_tests/CMakeLists.txt +++ b/tests/functional_tests/CMakeLists.txt @@ -68,7 +68,7 @@ monero_add_minimal_executable(cpu_power_test cpu_power_test.cpp) find_package(Python3 REQUIRED) -execute_process(COMMAND ${Python3_EXECUTABLE} "-c" "import requests; import psutil; import monotonic; import zmq; import deepdiff; print('OK')" OUTPUT_VARIABLE REQUESTS_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND ${Python3_EXECUTABLE} "-c" "import requests; import psutil; import zmq; import deepdiff; print('OK')" OUTPUT_VARIABLE REQUESTS_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE) if (REQUESTS_OUTPUT STREQUAL "OK") add_test( NAME functional_tests_rpc @@ -77,7 +77,7 @@ if (REQUESTS_OUTPUT STREQUAL "OK") NAME check_missing_rpc_methods COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}") else() - message(WARNING "functional_tests_rpc and check_missing_rpc_methods skipped, needs the 'requests', 'psutil', 'monotonic', 'zmq', and 'deepdiff' python modules") + message(WARNING "functional_tests_rpc and check_missing_rpc_methods skipped, needs the 'requests', 'psutil', 'zmq', and 'deepdiff' python modules") set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc check_missing_rpc_methods) if (EXPECT_FUNCTIONAL_TESTS) message(FATAL_ERROR "Functional tests are expected") diff --git a/tests/functional_tests/mining.py b/tests/functional_tests/mining.py index 08b470364..d49176bdf 100755 --- a/tests/functional_tests/mining.py +++ b/tests/functional_tests/mining.py @@ -32,7 +32,6 @@ import time import os import math -import monotonic import util_resources import multiprocessing import string @@ -95,7 +94,7 @@ class MiningTest(): # This is the last measurement, since it takes very little time and can be placed timewise-closer to the mining itself. available_ram = self.get_available_ram() # So far no ideas how to use this var, other than printing it - start = monotonic.monotonic() + start = time.monotonic() daemon = Daemon() wallet = Wallet() @@ -165,7 +164,7 @@ class MiningTest(): seen_height = height for _ in range(int(math.ceil(timeout))): time.sleep(1) - seconds_passed = monotonic.monotonic() - start + seconds_passed = time.monotonic() - start height = daemon.get_info().height if height > seen_height: break @@ -272,7 +271,7 @@ class MiningTest(): def print_time_taken(self, start, msg_context): if self.is_mining_silent(): return - seconds_passed = monotonic.monotonic() - start + seconds_passed = time.monotonic() - start print("Time taken for", msg_context, "=", round(seconds_passed, 1), "s.") def test_randomx(self):