What changed, and why it matters
This is a routine test-code cleanup. The change swaps a third-party Python package called 'monotonic' for Python's built-in 'time.monotonic()' in the test suite. It does not touch the Monero wallet, daemon, consensus, cryptography, or network code, and it does not fix or introduce any security vulnerability.
No security action needed. This is a normal dependency cleanup in test infrastructure.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes the ‘monotonic’ dependency from the functional test requirements and CMake check, and replaces three calls to monotonic.monotonic() with time.monotonic() in tests/functional_tests/mining.py. time.monotonic() has been available since Python 3.3/3.5 and provides the same clock behavior, making the external package redundant. No runtime Monero code is affected.
Changed components
tests/functional_tests/mining.pytests/functional_tests/CMakeLists.txttests/README.mdInspect captured patch +6 / −7
diff --git a/tests/README.md b/tests/README.md
index 51b0e48..d2bea14 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 1ba3743..64613fc 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 08b4703..d49176b 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):
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.