tests: replace monotonic

This commit is contained in:
tobtoht
2026-05-20 20:00:19 +02:00
parent 551b1ff13d
commit d1eaf54ed1
3 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ Functional tests are located under the `tests/functional_tests` directory.
Building all the tests requires installing the following dependencies: Building all the tests requires installing the following dependencies:
```bash ```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: First, run a regtest daemon in the offline mode and with a fixed difficulty:
+2 -2
View File
@@ -68,7 +68,7 @@ monero_add_minimal_executable(cpu_power_test cpu_power_test.cpp)
find_package(Python3 REQUIRED) 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") if (REQUESTS_OUTPUT STREQUAL "OK")
add_test( add_test(
NAME functional_tests_rpc NAME functional_tests_rpc
@@ -77,7 +77,7 @@ if (REQUESTS_OUTPUT STREQUAL "OK")
NAME check_missing_rpc_methods NAME check_missing_rpc_methods
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}") COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}")
else() 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) set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc check_missing_rpc_methods)
if (EXPECT_FUNCTIONAL_TESTS) if (EXPECT_FUNCTIONAL_TESTS)
message(FATAL_ERROR "Functional tests are expected") message(FATAL_ERROR "Functional tests are expected")
+3 -4
View File
@@ -32,7 +32,6 @@
import time import time
import os import os
import math import math
import monotonic
import util_resources import util_resources
import multiprocessing import multiprocessing
import string 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. # 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 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() daemon = Daemon()
wallet = Wallet() wallet = Wallet()
@@ -165,7 +164,7 @@ class MiningTest():
seen_height = height seen_height = height
for _ in range(int(math.ceil(timeout))): for _ in range(int(math.ceil(timeout))):
time.sleep(1) time.sleep(1)
seconds_passed = monotonic.monotonic() - start seconds_passed = time.monotonic() - start
height = daemon.get_info().height height = daemon.get_info().height
if height > seen_height: if height > seen_height:
break break
@@ -272,7 +271,7 @@ class MiningTest():
def print_time_taken(self, start, msg_context): def print_time_taken(self, start, msg_context):
if self.is_mining_silent(): if self.is_mining_silent():
return return
seconds_passed = monotonic.monotonic() - start seconds_passed = time.monotonic() - start
print("Time taken for", msg_context, "=", round(seconds_passed, 1), "s.") print("Time taken for", msg_context, "=", round(seconds_passed, 1), "s.")
def test_randomx(self): def test_randomx(self):