diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 66ce48e..6e5ce16 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -1,20 +1,20 @@
name: Docs
-# Builds the API site from the stubs of src/python and publishes it to GitHub Pages from main. Pull
+# Builds the API site from the stubs of src/monero and publishes it to GitHub Pages from main. Pull
# requests only build it, to see that it still builds. The site is not kept in the repository.
on:
push:
branches: [ main ]
paths:
- 'docs/mkdocs/**'
- - 'src/python/**'
+ - 'src/monero/**'
- 'docs/architecture.png'
- '.github/workflows/docs.yml'
pull_request:
branches: [ main ]
paths:
- 'docs/mkdocs/**'
- - 'src/python/**'
+ - 'src/monero/**'
- 'docs/architecture.png'
- '.github/workflows/docs.yml'
workflow_dispatch:
@@ -48,14 +48,6 @@ jobs:
- name: Install mkdocs and its plugins
run: pip install -r docs/mkdocs/requirements.in
- # mkdocstrings reads the stubs without importing anything, so the module does not have to be
- # built, but it looks for them in a folder named monero
- - name: Lay the stubs out as the monero package
- run: |
- mkdir -p "$RUNNER_TEMP/stubs"
- cp -r src/python "$RUNNER_TEMP/stubs/monero"
- echo "MONERO_STUBS=$RUNNER_TEMP/stubs" >> "$GITHUB_ENV"
-
# strict, so that a docstring or a reference that does not resolve fails the build
- name: Build the site
working-directory: docs/mkdocs
diff --git a/.gitignore b/.gitignore
index 91def4d..9ce1e6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,16 @@
-.vscode
+# the shared VS Code configuration is committed, the rest of the folder is personal
+.vscode/*
+!.vscode/settings.json
+!.vscode/launch.json
+!.vscode/tasks.json
+!.vscode/extensions.json
+!.vscode/.env
+/.env
+# made by bin/generate_typings.sh
+typings
build/*
+# the module for the debugger of C++, see .vscode/tasks.json
+build-debug
dist
__pycache__
.pytest_cache
diff --git a/.vscode/.env b/.vscode/.env
new file mode 100644
index 0000000..7ab6a51
--- /dev/null
+++ b/.vscode/.env
@@ -0,0 +1,2 @@
+# read by VS Code (python.envFile): the module that cmake builds in build/, for the tests and the processes that they start
+PYTHONPATH=build
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..909941a
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,13 @@
+{
+ "recommendations": [
+ "ms-python.python",
+ "ms-python.debugpy",
+ "ms-python.vscode-pylance",
+ "ms-vscode.cpptools",
+ "ms-vscode.cmake-tools",
+ "ms-azuretools.vscode-containers",
+ "github.vscode-github-actions",
+ "timonwong.shellcheck",
+ "ryanluker.vscode-coverage-gutters"
+ ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..78e29c6
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,96 @@
+{
+ // the reruns and the timeout of pytest.ini would rerun a failed test and stop one that waits at a breakpoint; the module
+ // is built before, so that the tests do not run with an old one
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "pytest: current file",
+ "presentation": { "group": "1-pytest", "order": 1 },
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pytest",
+ "args": ["${file}", "--reruns", "0", "--timeout", "0", "--no-cov"],
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "justMyCode": false,
+ "preLaunchTask": "build: monero-python module"
+ },
+ {
+ "name": "pytest: unit tests",
+ "presentation": { "group": "1-pytest", "order": 2 },
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pytest",
+ "args": ["-m", "unit", "--reruns", "0", "--timeout", "0", "--no-cov"],
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "justMyCode": false,
+ "preLaunchTask": "build: monero-python module"
+ },
+ {
+ "name": "pytest: integration tests (docker)",
+ "presentation": { "group": "1-pytest", "order": 3 },
+ "type": "debugpy",
+ "request": "launch",
+ "module": "pytest",
+ "args": ["-m", "integration", "--reruns", "0", "--timeout", "0", "--no-cov"],
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "justMyCode": false,
+ "preLaunchTask": "tests: build and start docker environment"
+ },
+ {
+ // the one of the Testing panel, when it debugs a test: it gives the test to run, so it is hidden from the list of Run and Debug
+ "name": "pytest: debug test (Testing panel)",
+ "type": "debugpy",
+ "request": "launch",
+ "purpose": ["debug-test"],
+ "presentation": { "hidden": true },
+ "env": { "PYTEST_ADDOPTS": "--reruns 0 --timeout 0 --no-cov" },
+ "console": "integratedTerminal",
+ "justMyCode": false,
+ "preLaunchTask": "build: monero-python module"
+ },
+ {
+ // gdb starts python, so the breakpoints of src/cpp stop in the module of build-debug; it needs gdb (apt install gdb)
+ "name": "C++: pytest current file (gdb)",
+ "presentation": { "group": "2-cpp", "order": 1 },
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${command:python.interpreterPath}",
+ "args": ["-m", "pytest", "${file}", "--reruns", "0", "--timeout", "0", "--no-cov"],
+ "cwd": "${workspaceFolder}",
+ "environment": [{ "name": "PYTHONPATH", "value": "${workspaceFolder}/build-debug" }],
+ "MIMode": "gdb",
+ "setupCommands": [
+ { "description": "pretty printing of the types of the standard library", "text": "-enable-pretty-printing", "ignoreFailures": true }
+ ],
+ "preLaunchTask": "build: monero-python module (debug)"
+ },
+ {
+ // gdb on a python that already runs, as one that waits at a breakpoint of debugpy: attaching to a process that gdb did
+ // not start needs kernel.yama.ptrace_scope=0, or gdb as root
+ "name": "C++: attach to a python process (gdb)",
+ "presentation": { "group": "2-cpp", "order": 2 },
+ "type": "cppdbg",
+ "request": "attach",
+ "program": "${command:python.interpreterPath}",
+ "processId": "${command:pickProcess}",
+ "MIMode": "gdb",
+ "setupCommands": [
+ { "description": "pretty printing of the types of the standard library", "text": "-enable-pretty-printing", "ignoreFailures": true }
+ ]
+ },
+ {
+ "name": "python: current file",
+ "presentation": { "group": "3-python", "order": 1 },
+ "type": "debugpy",
+ "request": "launch",
+ "program": "${file}",
+ "env": { "PYTHONPATH": "${workspaceFolder}/build" },
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "justMyCode": false
+ }
+ ]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..18da8ad
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,76 @@
+{
+ "github-actions.workflows.pinned.workflows": [
+ ".github/workflows/build-deb.yml",
+ ".github/workflows/build-linux.yml",
+ ".github/workflows/build-macos.yml",
+ ".github/workflows/build-windows.yml",
+ ".github/workflows/ci.yml"
+ ],
+
+ // the module is not installed, it is the one that cmake builds in build/: .env gives its folder to the tests, also to
+ // the python processes that some of them start
+ "python.envFile": "${workspaceFolder}/.vscode/.env",
+ // no interpreter path: VS Code picks the .venv of the task "setup: venv" on its own, and a path to one that is not there yet
+ // would be a warning until it is made
+
+ // tests/ as well: the tests import their helpers as utils, pytest puts tests/ in the path
+ "python.analysis.extraPaths": ["${workspaceFolder}/build", "${workspaceFolder}/tests"],
+ // the stubs of src/monero, the package that they describe: without them the types of the compiled module are unknown
+ "python.analysis.stubPath": "src",
+ // the tests, the scripts and the stubs pass it: a new error is one of the change that brings it
+ "python.analysis.typeCheckingMode": "strict",
+ // more than strict: the code passes these too
+ "python.analysis.diagnosticSeverityOverrides": {
+ "reportImplicitOverride": "error",
+ "reportUnnecessaryTypeIgnoreComment": "error",
+ "reportPropertyTypeMismatch": "error",
+ "reportShadowedImports": "error",
+ "reportImportCycles": "error",
+ "reportCallInDefaultInitializer": "error"
+ },
+ // the errors of every file in Problems, not only of the open ones; not of the submodules, the builds and what is generated
+ "python.analysis.diagnosticMode": "workspace",
+ "python.analysis.exclude": ["external", "build", "build-debug", ".cache", ".venv", "docs/mkdocs/public", "test_wallets"],
+ "terminal.integrated.env.linux": { "PYTHONPATH": "${workspaceFolder}/build" },
+ "terminal.integrated.env.osx": { "PYTHONPATH": "${workspaceFolder}/build" },
+
+ "python.testing.pytestEnabled": true,
+ "python.testing.unittestEnabled": false,
+ "python.testing.pytestArgs": ["tests"],
+
+ // CMake Tools builds the module, with few jobs: a compiler of monero takes up to 1.5 GB of memory
+ "cmake.buildDirectory": "${workspaceFolder}/build",
+ "cmake.configureOnOpen": false,
+ "cmake.parallelJobs": 3,
+ "cmake.exportCompileCommandsFile": true,
+ "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
+ "C_Cpp.default.cppStandard": "c++17",
+
+ // monero-project, the builds and the test wallets have too many files to watch and to index
+ "files.watcherExclude": {
+ "**/external/**": true,
+ "**/build/**": true,
+ "**/build-debug/**": true,
+ "**/.ccache/**": true,
+ "**/test_wallets/**": true
+ },
+ "search.exclude": {
+ "**/external/monero-cpp/external/**": true,
+ "**/build/**": true,
+ "**/build-debug/**": true,
+ "**/.ccache/**": true,
+ "**/test_wallets/**": true
+ },
+ "C_Cpp.files.exclude": {
+ "**/external/monero-cpp/external/**/build/**": true,
+ "**/.ccache/**": true
+ },
+
+ // the project has no formatter, a format on save would rewrite whole files
+ "[python]": { "editor.formatOnSave": false },
+ "[cpp]": { "editor.formatOnSave": false },
+ "[c]": { "editor.formatOnSave": false },
+
+ "files.trimTrailingWhitespace": true,
+ "files.insertFinalNewline": true
+}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..ce81a9a
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,106 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ // the packages of apt of the build, on Ubuntu and Debian; sudo asks the password in the terminal of the task
+ "label": "setup: system dependencies",
+ "type": "shell",
+ "command": "./bin/install_dependencies_linux.sh",
+ "problemMatcher": []
+ },
+ {
+ // the virtual environment of the README, with the versions that the CI tests and builds with
+ "label": "setup: venv",
+ "type": "shell",
+ "command": "python3 -m venv .venv && .venv/bin/pip install -r tests/requirements.txt -r requirements-build.txt",
+ "problemMatcher": []
+ },
+ {
+ // monero-project and monero-cpp, once and after an update of the submodules; JOBS=3 because a compiler of monero
+ // takes up to 1.5 GB of memory
+ "label": "build: monero-cpp",
+ "type": "shell",
+ "command": "./bin/build_monero_cpp.sh",
+ "options": { "env": { "JOBS": "3" } },
+ "problemMatcher": ["$gcc"]
+ },
+ {
+ "label": "build: monero-python module",
+ "type": "shell",
+ "command": "cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Dpybind11_DIR=\"$(python3 -m pybind11 --cmakedir)\" && cmake --build build -j3",
+ "group": { "kind": "build", "isDefault": true },
+ "problemMatcher": ["$gcc"]
+ },
+ {
+ // the module with the symbols and no optimization, for the debugger of C++, in a folder of its own
+ "label": "build: monero-python module (debug)",
+ "type": "shell",
+ "command": "cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Dpybind11_DIR=\"$(python3 -m pybind11 --cmakedir)\" && cmake --build build-debug -j3",
+ "problemMatcher": ["$gcc"]
+ },
+ {
+ // monero-cpp again, optimized but with the symbols, so the debugger steps into it too; the module links it at the next
+ // build. The type stays in the cache of that build, also for bin/build_monero_cpp.sh: -DCMAKE_BUILD_TYPE= goes back
+ "label": "build: monero-cpp with debug info",
+ "type": "shell",
+ "command": "cmake -S external/monero-cpp -B external/monero-cpp/build -DCMAKE_BUILD_TYPE=RelWithDebInfo && cmake --build external/monero-cpp/build -j3",
+ "problemMatcher": ["$gcc"]
+ },
+ {
+ "label": "tests: start docker environment",
+ "type": "shell",
+ "command": "docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2 xmr_wallet_3",
+ "problemMatcher": []
+ },
+ {
+ "label": "tests: build and start docker environment",
+ "dependsOn": ["build: monero-python module", "tests: start docker environment"],
+ "dependsOrder": "sequence",
+ "problemMatcher": []
+ },
+ {
+ "label": "tests: stop docker environment",
+ "type": "shell",
+ "command": "docker compose -f tests/docker-compose.yml down -v",
+ "problemMatcher": []
+ },
+ {
+ "label": "tests: unit",
+ "type": "shell",
+ "command": "${command:python.interpreterPath} -m pytest -m unit",
+ "options": { "env": { "PYTHONPATH": "${workspaceFolder}/build" } },
+ "group": "test",
+ "problemMatcher": []
+ },
+ {
+ // as in CI, the coverage of the python of the tests; Coverage Gutters shows coverage.xml in the editor
+ "label": "tests: unit with coverage",
+ "type": "shell",
+ "command": "${command:python.interpreterPath} -m pytest -m unit --cov=tests --cov-report=xml:coverage.xml --cov-report=term:skip-covered",
+ "options": { "env": { "PYTHONPATH": "${workspaceFolder}/build" } },
+ "group": "test",
+ "problemMatcher": []
+ },
+ {
+ // actionlint and zizmor, with the versions of .github/workflows/lint-workflows.yml
+ "label": "lint: workflows",
+ "type": "shell",
+ "command": "./bin/lint_workflows.sh",
+ "problemMatcher": []
+ },
+ {
+ "label": "docs: serve",
+ "type": "shell",
+ "command": "./bin/docs.sh serve",
+ "isBackground": true,
+ "problemMatcher": []
+ },
+ {
+ // strict, as in CI
+ "label": "docs: build",
+ "type": "shell",
+ "command": "./bin/docs.sh build",
+ "problemMatcher": []
+ }
+ ]
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a6ed02..cfb39b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -133,7 +133,7 @@ set_target_properties(net PROPERTIES IMPORTED_LOCATION
add_library(hardforks STATIC IMPORTED)
set_target_properties(hardforks PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/hardforks/libhardforks.a)
-
+
add_library(easylogging STATIC IMPORTED)
set_target_properties(easylogging PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/external/easylogging++/libeasylogging.a)
@@ -149,7 +149,7 @@ set_target_properties(cryptonote_protocol PROPERTIES IMPORTED_LOCATION
add_library(cryptonote_basic STATIC IMPORTED)
set_target_properties(cryptonote_basic PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_basic.a)
-
+
add_library(cryptonote_format_utils_basic STATIC IMPORTED)
set_target_properties(cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_format_utils_basic.a)
@@ -189,7 +189,7 @@ set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION
add_library(device STATIC IMPORTED)
set_target_properties(device PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/device/libdevice.a)
-
+
add_library(device_trezor STATIC IMPORTED)
set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/device_trezor/libdevice_trezor.a)
@@ -201,7 +201,7 @@ set_target_properties(multisig PROPERTIES IMPORTED_LOCATION
add_library(version STATIC IMPORTED)
set_target_properties(version PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/src/libversion.a)
-
+
add_library(randomx STATIC IMPORTED)
set_target_properties(randomx PROPERTIES IMPORTED_LOCATION
${MONERO_PROJECT_BUILD}/external/randomx/librandomx.a)
@@ -229,13 +229,24 @@ find_package(pybind11 REQUIRED)
# Boost
############
-set(Boost_NO_BOOST_CMAKE 1)
+# The CMake config that Boost installs since 1.70 (BoostConfig.cmake), which gives imported targets that bring their headers. An older
+# Boost has none: the FindBoost module of CMake finds it, which newer CMake versions deprecate (CMP0167), and only there.
set(Boost_USE_MULTITHREADED ON)
-set(BOOST_COMPONENTS thread serialization filesystem program_options)
+set(BOOST_COMPONENTS thread chrono atomic serialization filesystem program_options)
# Find Boost headers
set(BOOST_MIN_VER 1.62)
-find_package(Boost ${BOOST_MIN_VER} QUIET REQUIRED)
+find_package(Boost ${BOOST_MIN_VER} CONFIG QUIET)
+if (Boost_FOUND)
+ set(BOOST_FIND_MODE CONFIG)
+else()
+ if (POLICY CMP0167)
+ cmake_policy(SET CMP0167 OLD)
+ endif()
+ set(BOOST_FIND_MODE MODULE)
+ set(Boost_NO_BOOST_CMAKE ON)
+ find_package(Boost ${BOOST_MIN_VER} MODULE QUIET REQUIRED)
+endif()
# Boost System is header-only since 1.69
if (Boost_VERSION_STRING VERSION_LESS 1.69.0)
@@ -247,9 +258,9 @@ if (Boost_VERSION_STRING VERSION_LESS 1.84.0)
list(APPEND BOOST_COMPONENTS regex)
endif()
-find_package(Boost ${BOOST_MIN_VER} QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS})
-message(STATUS "Boost components: ${BOOST_COMPONENTS}")
-message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIR}")
+find_package(Boost ${BOOST_MIN_VER} ${BOOST_FIND_MODE} QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS})
+message(STATUS "Boost ${Boost_VERSION_STRING} (${BOOST_FIND_MODE}) components: ${BOOST_COMPONENTS}")
+message(STATUS "Using Boost include dirs at ${Boost_INCLUDE_DIRS}")
############
# OpenSSL
@@ -342,20 +353,24 @@ endif()
target_include_directories(monero PRIVATE
src/cpp
"${MONERO_CPP_SRC}/"
- "${MONERO_PROJECT_SRC}/"
- "${MONERO_PROJECT}/contrib/epee/include"
- "${MONERO_PROJECT}/external"
- "${MONERO_PROJECT}/external/easylogging++"
- "${MONERO_PROJECT}/external/rapidjson/include"
${pybind11_INCLUDE_DIR}
- ${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${HIDAPI_INCLUDE_DIR}
${Protobuf_INCLUDE_DIR}
${UNBOUND_INCLUDE_DIR}
)
-set(MONERO_PYTHON_LINK_LIBS
+# the headers of monero-project as the ones of the system: the warnings of its code, deadline_timer that newer boost versions deprecate
+# for one, are not the ones of the module. The compiler looks in them after the directories above
+target_include_directories(monero SYSTEM PRIVATE
+ "${MONERO_PROJECT_SRC}/"
+ "${MONERO_PROJECT}/contrib/epee/include"
+ "${MONERO_PROJECT}/external"
+ "${MONERO_PROJECT}/external/easylogging++"
+ "${MONERO_PROJECT}/external/rapidjson/include"
+)
+
+set(MONERO_PYTHON_LINK_LIBS
monero-cpp
wallet
rpc_base
@@ -384,12 +399,14 @@ set(MONERO_PYTHON_LINK_LIBS
${wallet_crypto}
Threads::Threads
+ Boost::headers
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${Protobuf_LIBRARY}
- ${LibUSB_LIBRARIES}
${SODIUM_LIBRARY}
+ # after hidapi, which uses it: with --as-needed the linker keeps a shared library only for what comes before it
${HIDAPI_LIBRARIES}
+ ${LibUSB_LIBRARIES}
${UNBOUND_LIBRARIES}
)
@@ -412,3 +429,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
install(TARGETS monero DESTINATION .)
+# the stubs, as the package monero next to the module: python imports the module, a folder with no __init__.py does not come first,
+# and the type checkers read the stubs (mypy with py.typed)
+install(DIRECTORY src/monero DESTINATION .)
diff --git a/README.md b/README.md
index 559d409..242d168 100644
--- a/README.md
+++ b/README.md
@@ -115,21 +115,19 @@ On anything else, build it from source.
### Linux and macOS
-1. Install build dependencies:
+1. Clone the project repository:
```bash
- # Ubuntu/Debian
-
- sudo apt install -y python3-all python3-pip python3-pybind11
+ git clone --recurse-submodules https://github.com/libmonero/monero-python.git
```
-
-2. Clone the project repository:
+2. Install the build dependencies, on Ubuntu and Debian with the script that CI uses (the packages of apt for monero-project, monero-cpp and the module, and `python3-venv` for the virtual environment of the tests):
```bash
- git clone --recurse-submodules https://github.com/libmonero/monero-python.git
+ cd monero-python
+ ./bin/install_dependencies_linux.sh
```
-3. Build the monero-cpp submodule (located at `./external/monero-cpp`) as a native library by following [instructions](https://github.com/woodser/monero-cpp#using-monero-cpp-in-your-project) for your system.
+ On other systems, follow the [instructions](https://github.com/woodser/monero-cpp#using-monero-cpp-in-your-project) of monero-cpp.
+3. Build monero-project and the monero-cpp submodule (located at `./external/monero-cpp`): `./bin/build_monero_cpp.sh`. It runs 3 jobs, a compiler of monero takes up to 1.5 GB of memory: set `JOBS` for more or fewer.
4. Build monero-python to `./build/`:
```bash
- cd monero-python
mkdir -p build
cd build
cmake ..
@@ -141,6 +139,8 @@ On anything else, build it from source.
```
6. Or run build script: `./bin/build_libmonero_python.sh`
+> **VS Code:** the repository has a configuration in [.vscode](.vscode): the tasks build monero-cpp and the module, start the docker test environment, run the tests with coverage, lint the workflows (`bin/lint_workflows.sh`, with the actionlint and zizmor of CI) and build or serve the docs (`bin/docs.sh`), the launch configurations debug the tests, in python and in the C++ of the module (with gdb, on a debug build in `build-debug/`), and the Testing panel finds the module in `build/` ([.vscode/.env](.vscode/.env)). It recommends the extensions that it uses.
+
> **Faster rebuilds:** if [ccache](https://ccache.dev/) is installed it is used automatically for monero and monero-python (pass `-DUSE_CCACHE=OFF` to cmake to disable it). To use it for monero-cpp as well, build that with `-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache`.
### Debian package
diff --git a/bin/cleanup_test_environment.sh b/bin/cleanup_test_environment.sh
index bd09b32..9ec2e70 100755
--- a/bin/cleanup_test_environment.sh
+++ b/bin/cleanup_test_environment.sh
@@ -1,10 +1,15 @@
#!/usr/bin/env bash
+# Removes the docker containers of the tests with their volumes, and what the tests leave: the wallets, the logs, the cache of pytest
+# and the __pycache__ folders of the project. Not the ones of .venv, of the submodules and of .cache, which are not of the tests.
+set -uo pipefail
+
+root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+cd "$root" || exit 1
# remove docker containers
-sudo docker compose -f tests/docker-compose.yml down -v
-rm -rf test_wallets 2>&1
-rm monero_tests_* 2>&1
-rm -rf .pytest_cache 2>&1
-rm -rf __pycache__ 2>&1
-rm -rf tests/__pycache__ 2>&1
-rm -rf tests/utils/__pycache__ 2>&1
+docker compose -f tests/docker-compose.yml down -v
+
+rm -rf test_wallets .pytest_cache
+rm -f monero_tests_*.log
+find . \( -path ./.venv -o -path ./external -o -path ./.git -o -path ./.cache \) -prune \
+ -o -type d -name __pycache__ -prune -exec rm -rf {} +
diff --git a/bin/docs.sh b/bin/docs.sh
new file mode 100755
index 0000000..4207436
--- /dev/null
+++ b/bin/docs.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# Builds or serves the site of docs/mkdocs as .github/workflows/docs.yml does, with the versions of docs/mkdocs/requirements.in.
+# They are installed in .cache, again when the requirements change.
+#
+# ./bin/docs.sh serve the site at http://127.0.0.1:8000, rebuilt at every change
+# ./bin/docs.sh build the site in docs/mkdocs/public, strict as in CI: a docstring or a reference that does not resolve fails
+set -euo pipefail
+
+root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+requirements="$root/docs/mkdocs/requirements.in"
+
+case "${1:-serve}" in
+ serve) args=(serve);;
+ build) args=(build --strict);;
+ *) echo "usage: $0 [serve|build]" >&2; exit 1;;
+esac
+
+# in a folder of its own, not in a virtual environment: Debian and Ubuntu need python3-venv for one
+packages="$root/.cache/mkdocs-$(sha256sum "$requirements" | cut -c1-12)"
+if [ ! -f "$packages/.installed" ]; then
+ rm -rf "$packages"
+ python3 -m pip install --quiet --disable-pip-version-check --target "$packages" -r "$requirements"
+ touch "$packages/.installed"
+fi
+
+cd "$root/docs/mkdocs"
+PYTHONPATH="$packages" python3 -m mkdocs "${args[@]}"
diff --git a/bin/install_dependencies_linux.sh b/bin/install_dependencies_linux.sh
index 7d8fbeb..64cccf8 100755
--- a/bin/install_dependencies_linux.sh
+++ b/bin/install_dependencies_linux.sh
@@ -47,4 +47,6 @@ sudo apt install -y \
debhelper \
python3-all \
python3-pip \
+ python3-venv \
+ python3-pybind11 \
lcov
diff --git a/bin/lint_bindings.py b/bin/lint_bindings.py
index 156012a..53f6f5c 100755
--- a/bin/lint_bindings.py
+++ b/bin/lint_bindings.py
@@ -22,11 +22,11 @@
from pathlib import Path
-def unnamed_parameters(tree):
+def unnamed_parameters(tree: ast.AST) -> list[str]:
"""The public functions of a stub that have parameters named by pybind11: ['Class.function(arg0)', ...]"""
- found = []
+ found: list[str] = []
- def visit(node, owner):
+ def visit(node: ast.AST, owner: str) -> None:
for child in ast.iter_child_nodes(node):
if isinstance(child, ast.ClassDef):
visit(child, child.name)
@@ -45,7 +45,7 @@ def visit(node, owner):
return sorted(set(found))
-def main():
+def main() -> int:
module = sys.argv[1] if len(sys.argv) > 1 else 'monero'
ok = True
with tempfile.TemporaryDirectory() as out:
@@ -62,7 +62,7 @@ def main():
# no stubs are written when stubgen finds errors
stubs = sorted(Path(out).rglob('*.pyi'))
- offenders = []
+ offenders: list[str] = []
for stub in stubs:
offenders += unnamed_parameters(ast.parse(stub.read_text()))
if offenders:
diff --git a/bin/lint_workflows.sh b/bin/lint_workflows.sh
new file mode 100755
index 0000000..1f781b7
--- /dev/null
+++ b/bin/lint_workflows.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+# Lints the workflows as .github/workflows/lint-workflows.yml does, with the same actionlint and zizmor: their versions,
+# and the sha256 of actionlint, are read from that workflow, so they stay those of the CI. They are kept in .cache.
+#
+# GH_TOKEN a token for the audits of zizmor that ask GitHub, they are skipped without it
+set -euo pipefail
+
+root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+workflow="$root/.github/workflows/lint-workflows.yml"
+cache="$root/.cache/lint-workflows"
+
+actionlint_version=$(sed -n 's/^ *ACTIONLINT_VERSION: *//p' "$workflow")
+actionlint_sha256=$(sed -n 's/^ *ACTIONLINT_SHA256: *//p' "$workflow")
+zizmor_version=$(sed -n 's/.*zizmor==\([0-9.]*\).*/\1/p' "$workflow")
+if [ -z "$actionlint_version" ] || [ -z "$actionlint_sha256" ] || [ -z "$zizmor_version" ]; then
+ echo "Could not read the versions of actionlint and zizmor from $workflow" >&2
+ exit 1
+fi
+
+case "$(uname -s)_$(uname -m)" in
+ Linux_x86_64) platform=linux_amd64;;
+ Linux_aarch64) platform=linux_arm64;;
+ *) echo "actionlint is downloaded only for Linux x86_64 and arm64 here" >&2; exit 1;;
+esac
+
+# the sha256 of the workflow is the one of linux_amd64, the other archives are checked against the checksums of the release
+actionlint="$cache/actionlint-$actionlint_version"
+if [ ! -x "$actionlint" ]; then
+ mkdir -p "$cache"
+ tmp=$(mktemp -d)
+ trap 'rm -rf "$tmp"' EXIT
+ url="https://github.com/rhysd/actionlint/releases/download/v${actionlint_version}"
+ curl --retry 5 --retry-delay 5 -fsSLo "$tmp/actionlint.tar.gz" "$url/actionlint_${actionlint_version}_${platform}.tar.gz"
+ if [ "$platform" = linux_amd64 ]; then
+ echo "$actionlint_sha256 $tmp/actionlint.tar.gz" | sha256sum -c -
+ else
+ curl --retry 5 --retry-delay 5 -fsSLo "$tmp/checksums.txt" "$url/actionlint_${actionlint_version}_checksums.txt"
+ expected=$(grep " actionlint_${actionlint_version}_${platform}.tar.gz\$" "$tmp/checksums.txt" | cut -d' ' -f1)
+ echo "$expected $tmp/actionlint.tar.gz" | sha256sum -c -
+ fi
+ tar -xzf "$tmp/actionlint.tar.gz" -C "$tmp" actionlint
+ mv "$tmp/actionlint" "$actionlint"
+fi
+
+# in a folder of its own, not in a virtual environment: Debian and Ubuntu need python3-venv for one
+zizmor="$cache/zizmor-$zizmor_version"
+if [ ! -x "$zizmor/bin/zizmor" ]; then
+ rm -rf "$zizmor"
+ python3 -m pip install --quiet --disable-pip-version-check --target "$zizmor" "zizmor==$zizmor_version"
+fi
+
+cd "$root"
+status=0
+echo "actionlint $actionlint_version"
+"$actionlint" -color || status=1
+echo "zizmor $zizmor_version"
+"$zizmor/bin/zizmor" .github || status=1
+exit $status
diff --git a/bin/setup_test_environment.sh b/bin/setup_test_environment.sh
index 3b23543..5bf3d5e 100755
--- a/bin/setup_test_environment.sh
+++ b/bin/setup_test_environment.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# start docker containers
-sudo docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2 xmr_wallet_3
+docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2 xmr_wallet_3
diff --git a/conftest.py b/conftest.py
index 45ccd68..99434a5 100644
--- a/conftest.py
+++ b/conftest.py
@@ -2,13 +2,14 @@
import logging
-from os import environ
+from os import devnull, environ
from os.path import splitext
from typing import TYPE_CHECKING, Generator, Optional, cast
import pytest
from tests.utils.gen_utils import GenUtils
+from tests.utils.test_utils import TestUtils
if TYPE_CHECKING:
from pluggy import Result # runtime-optional (pluggy < 1.2), only needed for typing
@@ -37,6 +38,15 @@ def pytest_configure(config: pytest.Config) -> None:
config.option.log_level = "DEBUG"
config.option.log_cli_level = "DEBUG"
+ # the Testing panel of an IDE collects the tests at every change, a log for each of them would only be noise
+ if config.option.collectonly:
+ config.option.log_file = devnull
+ return
+
+ # the log of monero-cpp, timestamped as the one of the tests
+ TestUtils.configure_logging()
+ TestUtils.initialize_test_wallet_dir()
+
# timestamp the log file so each run keeps its own
log_file: str = cast(str, config.getini("log_file"))
if not log_file:
diff --git a/debian/rules b/debian/rules
index 9383ea6..bfec531 100755
--- a/debian/rules
+++ b/debian/rules
@@ -32,7 +32,6 @@ override_dh_auto_build:
# the module is built here by scikit-build-core, which finds what the step above built
override_dh_auto_install:
$(LINUX32) pip3 install -vvv . --no-build-isolation --target $(SITE_PACKAGES)
- cp -R src/python $(SITE_PACKAGES)/monero
rm -rf $(SITE_PACKAGES)/pybind11* $(SITE_PACKAGES)/bin
-ccache --show-stats
diff --git a/docs/mkdocs/mkdocs.yml b/docs/mkdocs/mkdocs.yml
index 2e9ad14..370dcb8 100644
--- a/docs/mkdocs/mkdocs.yml
+++ b/docs/mkdocs/mkdocs.yml
@@ -140,9 +140,9 @@ plugins:
- mkdocstrings:
handlers:
python:
- # the stubs have to sit in a folder named monero, as the package they describe. CI lays them out
- # in a temporary folder and gives it as MONERO_STUBS, there is no need to install the module
- paths: [!ENV [MONERO_STUBS, ../../src/python]]
+ # the stubs of src/monero, the package that they describe: mkdocstrings reads them without
+ # importing anything, there is no need to build or install the module
+ paths: [../../src]
options:
show_source: false
show_root_heading: true
diff --git a/src/cpp/common/py_monero_common.cpp b/src/cpp/common/py_monero_common.cpp
index 80b7468..c68de50 100644
--- a/src/cpp/common/py_monero_common.cpp
+++ b/src/cpp/common/py_monero_common.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/common/py_monero_common.h b/src/cpp/common/py_monero_common.h
index 3e26fb2..df59de1 100644
--- a/src/cpp/common/py_monero_common.h
+++ b/src/cpp/common/py_monero_common.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/common/py_monero_common_bindings.cpp b/src/cpp/common/py_monero_common_bindings.cpp
index 334e7eb..fe620cb 100644
--- a/src/cpp/common/py_monero_common_bindings.cpp
+++ b/src/cpp/common/py_monero_common_bindings.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/daemon/py_monero_daemon.h b/src/cpp/daemon/py_monero_daemon.h
index 57bd172..e8491b9 100644
--- a/src/cpp/daemon/py_monero_daemon.h
+++ b/src/cpp/daemon/py_monero_daemon.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/daemon/py_monero_daemon_bindings.cpp b/src/cpp/daemon/py_monero_daemon_bindings.cpp
index d988794..56f4f1c 100644
--- a/src/cpp/daemon/py_monero_daemon_bindings.cpp
+++ b/src/cpp/daemon/py_monero_daemon_bindings.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/py_monero.cpp b/src/cpp/py_monero.cpp
index 9b1dd76..53c7286 100644
--- a/src/cpp/py_monero.cpp
+++ b/src/cpp/py_monero.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/py_monero_types.h b/src/cpp/py_monero_types.h
index 507e380..92ef271 100644
--- a/src/cpp/py_monero_types.h
+++ b/src/cpp/py_monero_types.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/utils/py_monero_utils.cpp b/src/cpp/utils/py_monero_utils.cpp
index 0835616..555727f 100644
--- a/src/cpp/utils/py_monero_utils.cpp
+++ b/src/cpp/utils/py_monero_utils.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/utils/py_monero_utils.h b/src/cpp/utils/py_monero_utils.h
index d6267ab..717ceef 100644
--- a/src/cpp/utils/py_monero_utils.h
+++ b/src/cpp/utils/py_monero_utils.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/utils/py_monero_utils_bindings.cpp b/src/cpp/utils/py_monero_utils_bindings.cpp
index c740880..fe8782e 100644
--- a/src/cpp/utils/py_monero_utils_bindings.cpp
+++ b/src/cpp/utils/py_monero_utils_bindings.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/wallet/py_monero_wallet.h b/src/cpp/wallet/py_monero_wallet.h
index b76ad1d..a60b973 100644
--- a/src/cpp/wallet/py_monero_wallet.h
+++ b/src/cpp/wallet/py_monero_wallet.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp
index 63be0d1..ca3a1a2 100644
--- a/src/cpp/wallet/py_monero_wallet_bindings.cpp
+++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) everoddandeven
+ * Copyright (c) Libmonero
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/python/__init__.pyi b/src/monero/__init__.pyi
similarity index 99%
rename from src/python/__init__.pyi
rename to src/monero/__init__.pyi
index a953b0e..5621550 100644
--- a/src/python/__init__.pyi
+++ b/src/monero/__init__.pyi
@@ -1,7 +1,7 @@
"""
Monero Python - A Python library for using Monero.
-Copyright (c) everoddandeven
+Copyright (c) Libmonero
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/python/gen_utils.pyi b/src/monero/gen_utils.pyi
similarity index 100%
rename from src/python/gen_utils.pyi
rename to src/monero/gen_utils.pyi
diff --git a/src/python/incoming_transfer_comparator.pyi b/src/monero/incoming_transfer_comparator.pyi
similarity index 100%
rename from src/python/incoming_transfer_comparator.pyi
rename to src/monero/incoming_transfer_comparator.pyi
diff --git a/src/python/monero_account.pyi b/src/monero/monero_account.pyi
similarity index 100%
rename from src/python/monero_account.pyi
rename to src/monero/monero_account.pyi
diff --git a/src/python/monero_account_tag.pyi b/src/monero/monero_account_tag.pyi
similarity index 100%
rename from src/python/monero_account_tag.pyi
rename to src/monero/monero_account_tag.pyi
diff --git a/src/python/monero_add_auxiliary_pow_result.pyi b/src/monero/monero_add_auxiliary_pow_result.pyi
similarity index 97%
rename from src/python/monero_add_auxiliary_pow_result.pyi
rename to src/monero/monero_add_auxiliary_pow_result.pyi
index 25f538c..df82d1a 100644
--- a/src/python/monero_add_auxiliary_pow_result.pyi
+++ b/src/monero/monero_add_auxiliary_pow_result.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
from .monero_auxiliary_pow import MoneroAuxiliaryPow
@@ -16,6 +17,7 @@ class MoneroAddAuxiliaryPowResult(MoneroRpcPaymentInfo):
aux_pow: list[MoneroAuxiliaryPow]
"""The (possibly reordered) auxiliary proof-of-work entries."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroAddAuxiliaryPowResult:
"""
diff --git a/src/python/monero_address_book_entry.pyi b/src/monero/monero_address_book_entry.pyi
similarity index 100%
rename from src/python/monero_address_book_entry.pyi
rename to src/monero/monero_address_book_entry.pyi
diff --git a/src/python/monero_address_type.pyi b/src/monero/monero_address_type.pyi
similarity index 100%
rename from src/python/monero_address_type.pyi
rename to src/monero/monero_address_type.pyi
diff --git a/src/python/monero_alt_chain.pyi b/src/monero/monero_alt_chain.pyi
similarity index 100%
rename from src/python/monero_alt_chain.pyi
rename to src/monero/monero_alt_chain.pyi
diff --git a/src/python/monero_auxiliary_pow.pyi b/src/monero/monero_auxiliary_pow.pyi
similarity index 100%
rename from src/python/monero_auxiliary_pow.pyi
rename to src/monero/monero_auxiliary_pow.pyi
diff --git a/src/python/monero_ban.pyi b/src/monero/monero_ban.pyi
similarity index 100%
rename from src/python/monero_ban.pyi
rename to src/monero/monero_ban.pyi
diff --git a/src/python/monero_block.pyi b/src/monero/monero_block.pyi
similarity index 98%
rename from src/python/monero_block.pyi
rename to src/monero/monero_block.pyi
index 2475ac5..5d5c3c9 100644
--- a/src/python/monero_block.pyi
+++ b/src/monero/monero_block.pyi
@@ -15,6 +15,7 @@ class MoneroBlock(MoneroBlockHeader):
txs: list[MoneroTx]
"""List of non-coinbase transactions in the block."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroBlock:
"""
diff --git a/src/python/monero_block_header.pyi b/src/monero/monero_block_header.pyi
similarity index 100%
rename from src/python/monero_block_header.pyi
rename to src/monero/monero_block_header.pyi
diff --git a/src/python/monero_block_template.pyi b/src/monero/monero_block_template.pyi
similarity index 100%
rename from src/python/monero_block_template.pyi
rename to src/monero/monero_block_template.pyi
diff --git a/src/python/monero_check.pyi b/src/monero/monero_check.pyi
similarity index 100%
rename from src/python/monero_check.pyi
rename to src/monero/monero_check.pyi
diff --git a/src/python/monero_check_reserve.pyi b/src/monero/monero_check_reserve.pyi
similarity index 95%
rename from src/python/monero_check_reserve.pyi
rename to src/monero/monero_check_reserve.pyi
index 482cb0e..6282f7e 100644
--- a/src/python/monero_check_reserve.pyi
+++ b/src/monero/monero_check_reserve.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_check import MoneroCheck
@@ -9,6 +10,7 @@ class MoneroCheckReserve(MoneroCheck):
unconfirmed_spent_amount: int | None
"""The reserve unconfirmed spent amount."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroCheckReserve:
"""
diff --git a/src/python/monero_check_tx.pyi b/src/monero/monero_check_tx.pyi
similarity index 95%
rename from src/python/monero_check_tx.pyi
rename to src/monero/monero_check_tx.pyi
index 2e742bf..0dfcc35 100644
--- a/src/python/monero_check_tx.pyi
+++ b/src/monero/monero_check_tx.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_check import MoneroCheck
@@ -11,6 +12,7 @@ class MoneroCheckTx(MoneroCheck):
received_amount: int | None
"""Amount received in the transaction."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroCheckTx:
"""
diff --git a/src/python/monero_connection_span.pyi b/src/monero/monero_connection_span.pyi
similarity index 100%
rename from src/python/monero_connection_span.pyi
rename to src/monero/monero_connection_span.pyi
diff --git a/src/python/monero_connection_type.pyi b/src/monero/monero_connection_type.pyi
similarity index 100%
rename from src/python/monero_connection_type.pyi
rename to src/monero/monero_connection_type.pyi
diff --git a/src/python/monero_daemon.pyi b/src/monero/monero_daemon.pyi
similarity index 100%
rename from src/python/monero_daemon.pyi
rename to src/monero/monero_daemon.pyi
diff --git a/src/python/monero_daemon_info.pyi b/src/monero/monero_daemon_info.pyi
similarity index 99%
rename from src/python/monero_daemon_info.pyi
rename to src/monero/monero_daemon_info.pyi
index d5f9a0b..518f6eb 100644
--- a/src/python/monero_daemon_info.pyi
+++ b/src/monero/monero_daemon_info.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_network_type import MoneroNetworkType
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
@@ -74,6 +75,7 @@ class MoneroDaemonInfo(MoneroRpcPaymentInfo):
was_bootstrap_ever_used: bool | None
"""States if a bootstrap node has ever been used since the daemon started."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroDaemonInfo:
"""
diff --git a/src/python/monero_daemon_listener.pyi b/src/monero/monero_daemon_listener.pyi
similarity index 100%
rename from src/python/monero_daemon_listener.pyi
rename to src/monero/monero_daemon_listener.pyi
diff --git a/src/python/monero_daemon_network_stats.pyi b/src/monero/monero_daemon_network_stats.pyi
similarity index 96%
rename from src/python/monero_daemon_network_stats.pyi
rename to src/monero/monero_daemon_network_stats.pyi
index efc3e39..5b17b99 100644
--- a/src/python/monero_daemon_network_stats.pyi
+++ b/src/monero/monero_daemon_network_stats.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
@@ -15,6 +16,7 @@ class MoneroDaemonNetworkStats(MoneroRpcPaymentInfo):
total_bytes_out: int | None
"""Total number of bytes sent."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroDaemonNetworkStats:
"""
diff --git a/src/python/monero_daemon_rpc.pyi b/src/monero/monero_daemon_rpc.pyi
similarity index 100%
rename from src/python/monero_daemon_rpc.pyi
rename to src/monero/monero_daemon_rpc.pyi
diff --git a/src/python/monero_daemon_sync_info.pyi b/src/monero/monero_daemon_sync_info.pyi
similarity index 97%
rename from src/python/monero_daemon_sync_info.pyi
rename to src/monero/monero_daemon_sync_info.pyi
index 55dccc0..ba11935 100644
--- a/src/python/monero_daemon_sync_info.pyi
+++ b/src/monero/monero_daemon_sync_info.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_peer import MoneroPeer
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
from .monero_connection_span import MoneroConnectionSpan
@@ -22,6 +23,7 @@ class MoneroDaemonSyncInfo(MoneroRpcPaymentInfo):
target_height: int | None
"""Target height the node is syncing from (will be 0 if node is fully synced)."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroDaemonSyncInfo:
"""
diff --git a/src/python/monero_daemon_update_check_result.pyi b/src/monero/monero_daemon_update_check_result.pyi
similarity index 100%
rename from src/python/monero_daemon_update_check_result.pyi
rename to src/monero/monero_daemon_update_check_result.pyi
diff --git a/src/python/monero_daemon_update_download_result.pyi b/src/monero/monero_daemon_update_download_result.pyi
similarity index 95%
rename from src/python/monero_daemon_update_download_result.pyi
rename to src/monero/monero_daemon_update_download_result.pyi
index cb60c29..60b1619 100644
--- a/src/python/monero_daemon_update_download_result.pyi
+++ b/src/monero/monero_daemon_update_download_result.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_daemon_update_check_result import MoneroDaemonUpdateCheckResult
@@ -7,6 +8,7 @@ class MoneroDaemonUpdateDownloadResult(MoneroDaemonUpdateCheckResult):
download_path: str | None
"""Path to download the update."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroDaemonUpdateDownloadResult:
"""
diff --git a/src/python/monero_decoded_address.pyi b/src/monero/monero_decoded_address.pyi
similarity index 100%
rename from src/python/monero_decoded_address.pyi
rename to src/monero/monero_decoded_address.pyi
diff --git a/src/python/monero_destination.pyi b/src/monero/monero_destination.pyi
similarity index 100%
rename from src/python/monero_destination.pyi
rename to src/monero/monero_destination.pyi
diff --git a/src/python/monero_error.pyi b/src/monero/monero_error.pyi
similarity index 100%
rename from src/python/monero_error.pyi
rename to src/monero/monero_error.pyi
diff --git a/src/python/monero_fee_estimate.pyi b/src/monero/monero_fee_estimate.pyi
similarity index 100%
rename from src/python/monero_fee_estimate.pyi
rename to src/monero/monero_fee_estimate.pyi
diff --git a/src/python/monero_generate_blocks_result.pyi b/src/monero/monero_generate_blocks_result.pyi
similarity index 100%
rename from src/python/monero_generate_blocks_result.pyi
rename to src/monero/monero_generate_blocks_result.pyi
diff --git a/src/python/monero_get_block_hashes_result.pyi b/src/monero/monero_get_block_hashes_result.pyi
similarity index 100%
rename from src/python/monero_get_block_hashes_result.pyi
rename to src/monero/monero_get_block_hashes_result.pyi
diff --git a/src/python/monero_get_blocks_by_hash_result.pyi b/src/monero/monero_get_blocks_by_hash_result.pyi
similarity index 100%
rename from src/python/monero_get_blocks_by_hash_result.pyi
rename to src/monero/monero_get_blocks_by_hash_result.pyi
diff --git a/src/python/monero_hard_fork_info.pyi b/src/monero/monero_hard_fork_info.pyi
similarity index 97%
rename from src/python/monero_hard_fork_info.pyi
rename to src/monero/monero_hard_fork_info.pyi
index 376c94e..c537d9f 100644
--- a/src/python/monero_hard_fork_info.pyi
+++ b/src/monero/monero_hard_fork_info.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
@@ -24,6 +25,7 @@ class MoneroHardForkInfo(MoneroRpcPaymentInfo):
window: int | None
"""Number of blocks over which current votes are cast. Default is `10080` blocks."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroHardForkInfo:
"""
diff --git a/src/python/monero_incoming_transfer.pyi b/src/monero/monero_incoming_transfer.pyi
similarity index 100%
rename from src/python/monero_incoming_transfer.pyi
rename to src/monero/monero_incoming_transfer.pyi
diff --git a/src/python/monero_integrated_address.pyi b/src/monero/monero_integrated_address.pyi
similarity index 100%
rename from src/python/monero_integrated_address.pyi
rename to src/monero/monero_integrated_address.pyi
diff --git a/src/python/monero_key_image.pyi b/src/monero/monero_key_image.pyi
similarity index 100%
rename from src/python/monero_key_image.pyi
rename to src/monero/monero_key_image.pyi
diff --git a/src/python/monero_key_image_export_result.pyi b/src/monero/monero_key_image_export_result.pyi
similarity index 100%
rename from src/python/monero_key_image_export_result.pyi
rename to src/monero/monero_key_image_export_result.pyi
diff --git a/src/python/monero_key_image_import_result.pyi b/src/monero/monero_key_image_import_result.pyi
similarity index 100%
rename from src/python/monero_key_image_import_result.pyi
rename to src/monero/monero_key_image_import_result.pyi
diff --git a/src/python/monero_key_image_spent_status.pyi b/src/monero/monero_key_image_spent_status.pyi
similarity index 100%
rename from src/python/monero_key_image_spent_status.pyi
rename to src/monero/monero_key_image_spent_status.pyi
diff --git a/src/python/monero_message_signature_result.pyi b/src/monero/monero_message_signature_result.pyi
similarity index 100%
rename from src/python/monero_message_signature_result.pyi
rename to src/monero/monero_message_signature_result.pyi
diff --git a/src/python/monero_message_signature_type.pyi b/src/monero/monero_message_signature_type.pyi
similarity index 100%
rename from src/python/monero_message_signature_type.pyi
rename to src/monero/monero_message_signature_type.pyi
diff --git a/src/python/monero_miner_data.pyi b/src/monero/monero_miner_data.pyi
similarity index 97%
rename from src/python/monero_miner_data.pyi
rename to src/monero/monero_miner_data.pyi
index 4690fd8..2df36fe 100644
--- a/src/python/monero_miner_data.pyi
+++ b/src/monero/monero_miner_data.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
from .monero_tx import MoneroTx
@@ -22,6 +23,7 @@ class MoneroMinerData(MoneroRpcPaymentInfo):
tx_pool_backlog: list[MoneroTx]
"""The transactions currently in the pool eligible for the next block."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroMinerData:
"""
diff --git a/src/python/monero_miner_tx_sum.pyi b/src/monero/monero_miner_tx_sum.pyi
similarity index 100%
rename from src/python/monero_miner_tx_sum.pyi
rename to src/monero/monero_miner_tx_sum.pyi
diff --git a/src/python/monero_mining_status.pyi b/src/monero/monero_mining_status.pyi
similarity index 100%
rename from src/python/monero_mining_status.pyi
rename to src/monero/monero_mining_status.pyi
diff --git a/src/python/monero_multisig_info.pyi b/src/monero/monero_multisig_info.pyi
similarity index 100%
rename from src/python/monero_multisig_info.pyi
rename to src/monero/monero_multisig_info.pyi
diff --git a/src/python/monero_multisig_init_result.pyi b/src/monero/monero_multisig_init_result.pyi
similarity index 100%
rename from src/python/monero_multisig_init_result.pyi
rename to src/monero/monero_multisig_init_result.pyi
diff --git a/src/python/monero_multisig_sign_result.pyi b/src/monero/monero_multisig_sign_result.pyi
similarity index 100%
rename from src/python/monero_multisig_sign_result.pyi
rename to src/monero/monero_multisig_sign_result.pyi
diff --git a/src/python/monero_network_type.pyi b/src/monero/monero_network_type.pyi
similarity index 100%
rename from src/python/monero_network_type.pyi
rename to src/monero/monero_network_type.pyi
diff --git a/src/python/monero_outgoing_transfer.pyi b/src/monero/monero_outgoing_transfer.pyi
similarity index 100%
rename from src/python/monero_outgoing_transfer.pyi
rename to src/monero/monero_outgoing_transfer.pyi
diff --git a/src/python/monero_output.pyi b/src/monero/monero_output.pyi
similarity index 100%
rename from src/python/monero_output.pyi
rename to src/monero/monero_output.pyi
diff --git a/src/python/monero_output_distribution_entry.pyi b/src/monero/monero_output_distribution_entry.pyi
similarity index 100%
rename from src/python/monero_output_distribution_entry.pyi
rename to src/monero/monero_output_distribution_entry.pyi
diff --git a/src/python/monero_output_histogram_entry.pyi b/src/monero/monero_output_histogram_entry.pyi
similarity index 100%
rename from src/python/monero_output_histogram_entry.pyi
rename to src/monero/monero_output_histogram_entry.pyi
diff --git a/src/python/monero_output_query.pyi b/src/monero/monero_output_query.pyi
similarity index 99%
rename from src/python/monero_output_query.pyi
rename to src/monero/monero_output_query.pyi
index 1214bc2..931c478 100644
--- a/src/python/monero_output_query.pyi
+++ b/src/monero/monero_output_query.pyi
@@ -34,6 +34,7 @@ class MoneroOutputQuery(MoneroOutputWallet):
"""
...
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroOutputQuery:
"""
diff --git a/src/python/monero_output_wallet.pyi b/src/monero/monero_output_wallet.pyi
similarity index 98%
rename from src/python/monero_output_wallet.pyi
rename to src/monero/monero_output_wallet.pyi
index c8ce943..30f6acb 100644
--- a/src/python/monero_output_wallet.pyi
+++ b/src/monero/monero_output_wallet.pyi
@@ -15,6 +15,7 @@ class MoneroOutputWallet(MoneroOutput):
subaddress_index: int | None
"""The index of the subaddress that owns this output."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroOutputWallet:
"""
diff --git a/src/python/monero_peer.pyi b/src/monero/monero_peer.pyi
similarity index 100%
rename from src/python/monero_peer.pyi
rename to src/monero/monero_peer.pyi
diff --git a/src/python/monero_prune_result.pyi b/src/monero/monero_prune_result.pyi
similarity index 100%
rename from src/python/monero_prune_result.pyi
rename to src/monero/monero_prune_result.pyi
diff --git a/src/python/monero_rpc_connection.pyi b/src/monero/monero_rpc_connection.pyi
similarity index 100%
rename from src/python/monero_rpc_connection.pyi
rename to src/monero/monero_rpc_connection.pyi
diff --git a/src/python/monero_rpc_error.pyi b/src/monero/monero_rpc_error.pyi
similarity index 100%
rename from src/python/monero_rpc_error.pyi
rename to src/monero/monero_rpc_error.pyi
diff --git a/src/python/monero_rpc_payment_info.pyi b/src/monero/monero_rpc_payment_info.pyi
similarity index 100%
rename from src/python/monero_rpc_payment_info.pyi
rename to src/monero/monero_rpc_payment_info.pyi
diff --git a/src/python/monero_subaddress.pyi b/src/monero/monero_subaddress.pyi
similarity index 100%
rename from src/python/monero_subaddress.pyi
rename to src/monero/monero_subaddress.pyi
diff --git a/src/python/monero_submit_tx_result.pyi b/src/monero/monero_submit_tx_result.pyi
similarity index 98%
rename from src/python/monero_submit_tx_result.pyi
rename to src/monero/monero_submit_tx_result.pyi
index 0fbb479..206df99 100644
--- a/src/python/monero_submit_tx_result.pyi
+++ b/src/monero/monero_submit_tx_result.pyi
@@ -1,3 +1,4 @@
+import typing
from .monero_rpc_payment_info import MoneroRpcPaymentInfo
class MoneroSubmitTxResult(MoneroRpcPaymentInfo):
@@ -32,6 +33,7 @@ class MoneroSubmitTxResult(MoneroRpcPaymentInfo):
sanity_check_failed: bool | None
"""Indicates if the transaction sanity check has failed."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroSubmitTxResult:
"""
diff --git a/src/python/monero_sync_result.pyi b/src/monero/monero_sync_result.pyi
similarity index 100%
rename from src/python/monero_sync_result.pyi
rename to src/monero/monero_sync_result.pyi
diff --git a/src/python/monero_transfer.pyi b/src/monero/monero_transfer.pyi
similarity index 100%
rename from src/python/monero_transfer.pyi
rename to src/monero/monero_transfer.pyi
diff --git a/src/python/monero_transfer_query.pyi b/src/monero/monero_transfer_query.pyi
similarity index 100%
rename from src/python/monero_transfer_query.pyi
rename to src/monero/monero_transfer_query.pyi
diff --git a/src/python/monero_tx.pyi b/src/monero/monero_tx.pyi
similarity index 100%
rename from src/python/monero_tx.pyi
rename to src/monero/monero_tx.pyi
diff --git a/src/python/monero_tx_backlog_entry.pyi b/src/monero/monero_tx_backlog_entry.pyi
similarity index 100%
rename from src/python/monero_tx_backlog_entry.pyi
rename to src/monero/monero_tx_backlog_entry.pyi
diff --git a/src/python/monero_tx_config.pyi b/src/monero/monero_tx_config.pyi
similarity index 100%
rename from src/python/monero_tx_config.pyi
rename to src/monero/monero_tx_config.pyi
diff --git a/src/python/monero_tx_pool_stats.pyi b/src/monero/monero_tx_pool_stats.pyi
similarity index 100%
rename from src/python/monero_tx_pool_stats.pyi
rename to src/monero/monero_tx_pool_stats.pyi
diff --git a/src/python/monero_tx_priority.pyi b/src/monero/monero_tx_priority.pyi
similarity index 100%
rename from src/python/monero_tx_priority.pyi
rename to src/monero/monero_tx_priority.pyi
diff --git a/src/python/monero_tx_query.pyi b/src/monero/monero_tx_query.pyi
similarity index 99%
rename from src/python/monero_tx_query.pyi
rename to src/monero/monero_tx_query.pyi
index f192e0e..9b7a1b7 100644
--- a/src/python/monero_tx_query.pyi
+++ b/src/monero/monero_tx_query.pyi
@@ -44,6 +44,7 @@ class MoneroTxQuery(MoneroTxWallet):
:returns MoneroTxQuery: deserialized tx query.
"""
...
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroTxQuery:
"""
diff --git a/src/python/monero_tx_set.pyi b/src/monero/monero_tx_set.pyi
similarity index 100%
rename from src/python/monero_tx_set.pyi
rename to src/monero/monero_tx_set.pyi
diff --git a/src/python/monero_tx_wallet.pyi b/src/monero/monero_tx_wallet.pyi
similarity index 99%
rename from src/python/monero_tx_wallet.pyi
rename to src/monero/monero_tx_wallet.pyi
index a6bb893..096e3e6 100644
--- a/src/python/monero_tx_wallet.pyi
+++ b/src/monero/monero_tx_wallet.pyi
@@ -37,6 +37,7 @@ class MoneroTxWallet(MoneroTx):
"""The total output amount sum originated from this transaction."""
tx_set: MoneroTxSet | None
"""Set of transactions related to current tx."""
+ @typing.override
@staticmethod
def deserialize(json: str) -> MoneroTxWallet:
"""
diff --git a/src/python/monero_utils.pyi b/src/monero/monero_utils.pyi
similarity index 100%
rename from src/python/monero_utils.pyi
rename to src/monero/monero_utils.pyi
diff --git a/src/python/monero_version.pyi b/src/monero/monero_version.pyi
similarity index 100%
rename from src/python/monero_version.pyi
rename to src/monero/monero_version.pyi
diff --git a/src/python/monero_wallet.pyi b/src/monero/monero_wallet.pyi
similarity index 100%
rename from src/python/monero_wallet.pyi
rename to src/monero/monero_wallet.pyi
diff --git a/src/python/monero_wallet_config.pyi b/src/monero/monero_wallet_config.pyi
similarity index 100%
rename from src/python/monero_wallet_config.pyi
rename to src/monero/monero_wallet_config.pyi
diff --git a/src/python/monero_wallet_full.pyi b/src/monero/monero_wallet_full.pyi
similarity index 100%
rename from src/python/monero_wallet_full.pyi
rename to src/monero/monero_wallet_full.pyi
diff --git a/src/python/monero_wallet_keys.pyi b/src/monero/monero_wallet_keys.pyi
similarity index 100%
rename from src/python/monero_wallet_keys.pyi
rename to src/monero/monero_wallet_keys.pyi
diff --git a/src/python/monero_wallet_listener.pyi b/src/monero/monero_wallet_listener.pyi
similarity index 100%
rename from src/python/monero_wallet_listener.pyi
rename to src/monero/monero_wallet_listener.pyi
diff --git a/src/python/monero_wallet_rpc.pyi b/src/monero/monero_wallet_rpc.pyi
similarity index 100%
rename from src/python/monero_wallet_rpc.pyi
rename to src/monero/monero_wallet_rpc.pyi
diff --git a/src/python/output_comparator.pyi b/src/monero/output_comparator.pyi
similarity index 100%
rename from src/python/output_comparator.pyi
rename to src/monero/output_comparator.pyi
diff --git a/src/monero/py.typed b/src/monero/py.typed
new file mode 100644
index 0000000..e69de29
diff --git a/src/python/serializable_struct.pyi b/src/monero/serializable_struct.pyi
similarity index 100%
rename from src/python/serializable_struct.pyi
rename to src/monero/serializable_struct.pyi
diff --git a/src/python/ssl_options.pyi b/src/monero/ssl_options.pyi
similarity index 100%
rename from src/python/ssl_options.pyi
rename to src/monero/ssl_options.pyi
diff --git a/src/python/tx_height_comparator.pyi b/src/monero/tx_height_comparator.pyi
similarity index 100%
rename from src/python/tx_height_comparator.pyi
rename to src/monero/tx_height_comparator.pyi
diff --git a/tests/common/test_gen_utils.py b/tests/common/test_gen_utils.py
index 61d6ef3..0e470be 100644
--- a/tests/common/test_gen_utils.py
+++ b/tests/common/test_gen_utils.py
@@ -45,7 +45,7 @@ def test_wait_for_zero_does_not_block(self) -> None:
def test_wait_for_negative_raises(self) -> None:
with pytest.raises(TypeError):
- GenUtils.wait_for(-1) # type: ignore
+ GenUtils.wait_for(-1)
def test_bool_equals(self) -> None:
assert GenUtils.bool_equals(True, True) is True
diff --git a/tests/daemon/test_listener_lifetime.py b/tests/daemon/test_listener_lifetime.py
index 3247caf..c6e0dce 100644
--- a/tests/daemon/test_listener_lifetime.py
+++ b/tests/daemon/test_listener_lifetime.py
@@ -5,7 +5,7 @@
import weakref
from time import monotonic, sleep
-from typing import override
+from typing_extensions import override
import pytest
from monero import MoneroBlockHeader, MoneroDaemonListener, MoneroDaemonRpc
diff --git a/tests/utils/assert_utils.py b/tests/utils/assert_utils.py
index 478b335..2257d24 100644
--- a/tests/utils/assert_utils.py
+++ b/tests/utils/assert_utils.py
@@ -64,7 +64,7 @@ def assert_serialization_integrity[T: SerializableStruct](cls, obj: T) -> T:
:param T obj: object to verity serialization integrity.
:return T: new deserialized object.
"""
- cls = type(obj) # type: ignore
+ cls = type(obj)
json_str: str = obj.serialize()
logger.debug(f"Serialized {cls.__name__}: {json_str}")
restored: Any = cls.deserialize(json_str) # type: ignore
diff --git a/tests/utils/base_test_class.py b/tests/utils/base_test_class.py
index 2d095cf..e35d2bf 100644
--- a/tests/utils/base_test_class.py
+++ b/tests/utils/base_test_class.py
@@ -66,7 +66,7 @@ def before_each(self, request: pytest.FixtureRequest) -> None:
:param pytest.FixtureRequest request: Request fixture.
"""
- msg: str = f"Before {request.node.name}" # type: ignore
+ msg: str = f"Before {request.node.name}"
MoneroUtils.log_info(msg)
logger.info(msg)
@@ -86,4 +86,4 @@ def after_message(self, request: pytest.FixtureRequest) -> str:
:param pytest.FixtureRequest request: Request fixture.
:returns str: `After ( ms)`.
"""
- return f"After {request.node.name} ({self._elapsed_ms:.1f} ms)" # type: ignore
+ return f"After {request.node.name} ({self._elapsed_ms:.1f} ms)"
diff --git a/tests/utils/context/test_context.py b/tests/utils/context/test_context.py
index dda5686..6c43c80 100644
--- a/tests/utils/context/test_context.py
+++ b/tests/utils/context/test_context.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from typing import Any, Optional
+from typing_extensions import override
from .serializable_context import SerializableContext
@@ -57,6 +58,7 @@ def __init__(self, ctx: Optional[TestContext] = None) -> None:
self.header_is_full = ctx.header_is_full
self.tx_context = ctx.tx_context
+ @override
def to_dict(self) -> dict[str, Any]:
"""Build the JSON object for this test context (defined fields only).
@@ -79,6 +81,7 @@ def to_dict(self) -> dict[str, Any]:
root["txContext"] = self.tx_context.to_dict()
return root
+ @override
@staticmethod
def from_dict(node: dict[str, Any], ctx: TestContext) -> None:
"""Populate ``ctx`` from a parsed JSON object.
diff --git a/tests/utils/context/tx_context.py b/tests/utils/context/tx_context.py
index be1f028..ffccf01 100644
--- a/tests/utils/context/tx_context.py
+++ b/tests/utils/context/tx_context.py
@@ -3,6 +3,7 @@
import json
from typing import Any, Optional
+from typing_extensions import override
from monero import MoneroWallet, MoneroTxConfig
from .serializable_context import SerializableContext
@@ -51,6 +52,7 @@ def __init__(self, ctx: Optional[TxContext] = None) -> None:
self.is_sweep_response = ctx.is_sweep_response
self.is_sweep_output_response = ctx.is_sweep_output_response
+ @override
def to_dict(self) -> dict[str, Any]:
"""Build the JSON object for this tx context (defined fields only).
@@ -75,6 +77,7 @@ def to_dict(self) -> dict[str, Any]:
self._put(root, "isSweepOutputResponse", self.is_sweep_output_response)
return root
+ @override
@staticmethod
def from_dict(node: dict[str, Any], ctx: TxContext) -> None:
"""Populate ``ctx`` from a parsed JSON object.
diff --git a/tests/utils/fake_daemon_rpc_server.py b/tests/utils/fake_daemon_rpc_server.py
index ae6b9ec..3f2f388 100644
--- a/tests/utils/fake_daemon_rpc_server.py
+++ b/tests/utils/fake_daemon_rpc_server.py
@@ -1,4 +1,5 @@
-from typing import Any, override
+from typing import Any
+from typing_extensions import override
from .fake_rpc_server import FakeRpcHandler, FakeRpcServer
diff --git a/tests/utils/fake_rpc_server.py b/tests/utils/fake_rpc_server.py
index 2d80505..c69f2d6 100644
--- a/tests/utils/fake_rpc_server.py
+++ b/tests/utils/fake_rpc_server.py
@@ -5,7 +5,8 @@
from time import sleep
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
-from typing import Any, override
+from typing import Any
+from typing_extensions import override
logger: logging.Logger = logging.getLogger("FakeRpcServer")
@@ -108,10 +109,12 @@ def next_height(self, method: str = "") -> int:
self._methods.append(method)
return self._height
+ @override
def __enter__(self) -> "FakeRpcServer":
self._thread.start()
return self
+ @override
def __exit__(self, *args: Any) -> None:
self.shutdown()
self.server_close()
diff --git a/tests/utils/fake_wallet_rpc_server.py b/tests/utils/fake_wallet_rpc_server.py
index 27b130b..aa06fa3 100644
--- a/tests/utils/fake_wallet_rpc_server.py
+++ b/tests/utils/fake_wallet_rpc_server.py
@@ -1,4 +1,5 @@
-from typing import Any, override
+from typing import Any
+from typing_extensions import override
from .fake_rpc_server import FakeRpcHandler, FakeRpcServer
diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py
index ee0a6b2..87960fd 100644
--- a/tests/utils/test_utils.py
+++ b/tests/utils/test_utils.py
@@ -253,9 +253,6 @@ def load_config(cls) -> None:
cls.MINING_SEED = parser.get('mining_wallet', 'seed')
cls.WALLET_TX_TRACKER = WalletTxTracker(cls.get_daemon_rpc(), cls.SYNC_PERIOD_IN_MS, cls.MINING_ADDRESS)
- # create directory for test wallets if it doesn't exist
- cls.initialize_test_wallet_dir()
-
cls._LOADED = True
@classmethod
@@ -273,18 +270,17 @@ def load(cls) -> None:
cls.SYNC_PERIOD_IN_MS
)
cls.RPC_WALLET_MANAGER.set_connection_credentials(cls.WALLET_RPC_USERNAME, cls.WALLET_RPC_PASSWORD)
- cls.configure_logging()
logger.debug("TestUtils configuration initialized")
@classmethod
def configure_logging(cls) -> None:
- """Configure internal Monero core logging."""
+ """Configure internal Monero core logging. conftest.py calls it when the tests run, not when they are only collected."""
MoneroUtils.configure_logging(f"monero_tests_cpp_{GenUtils.current_date_time_str()}.log", False)
MoneroUtils.set_log_level(cls.LOG_LEVEL)
@classmethod
def initialize_test_wallet_dir(cls) -> None:
- """Initialize test wallets directory."""
+ """Initialize test wallets directory. conftest.py calls it when the tests run, not when they are only collected."""
GenUtils.create_dir_if_not_exists(cls.TEST_WALLETS_DIR)
@classmethod
diff --git a/tests/utils/wallet_equality_utils.py b/tests/utils/wallet_equality_utils.py
index 16e596f..5a334b9 100644
--- a/tests/utils/wallet_equality_utils.py
+++ b/tests/utils/wallet_equality_utils.py
@@ -260,7 +260,7 @@ def transfer_cached_info(cls, src: MoneroTxWallet, tgt: MoneroTxWallet) -> None:
if in_transfer.account_index == src.outgoing_transfer.account_index:
tgt.incoming_transfers.append(in_transfer)
- tgt.incoming_transfers.sort() # type: ignore
+ tgt.incoming_transfers.sort()
# transfer info to outgoing transfer
if tgt.outgoing_transfer is None:
diff --git a/tests/wallet/base_test_monero_wallet.py b/tests/wallet/base_test_monero_wallet.py
index a6479d3..12a830b 100644
--- a/tests/wallet/base_test_monero_wallet.py
+++ b/tests/wallet/base_test_monero_wallet.py
@@ -205,7 +205,7 @@ def after_each(self, request: pytest.FixtureRequest) -> None:
status: MoneroMiningStatus = daemon.get_mining_status()
if status.is_active is True:
- logger.warning(f"Mining is active after test {request.node.name}") # type: ignore
+ logger.warning(f"Mining is active after test {request.node.name}")
def _test_multisig_sample(self, m: int, n: int) -> None:
"""
diff --git a/tests/wallet/test_keys_and_addresses.py b/tests/wallet/test_keys_and_addresses.py
index 1ecb084..cd09888 100644
--- a/tests/wallet/test_keys_and_addresses.py
+++ b/tests/wallet/test_keys_and_addresses.py
@@ -389,7 +389,7 @@ def test_sign_message_invalid_signature_type_base_address_raises(self) -> None:
config.network_type = Utils.NETWORK_TYPE
w: MoneroWalletKeys = MoneroWalletKeys.create_wallet_random(config)
try:
- invalid_type: MoneroMessageSignatureType = MoneroMessageSignatureType(99) # type: ignore
+ invalid_type: MoneroMessageSignatureType = MoneroMessageSignatureType(99)
with pytest.raises(RuntimeError, match="Invalid signature type requested"):
w.sign_message("hello", invalid_type, 0, 0)
finally:
@@ -401,7 +401,7 @@ def test_sign_message_invalid_signature_type_subaddress_raises(self) -> None:
config.network_type = Utils.NETWORK_TYPE
w: MoneroWalletKeys = MoneroWalletKeys.create_wallet_random(config)
try:
- invalid_type: MoneroMessageSignatureType = MoneroMessageSignatureType(99) # type: ignore
+ invalid_type: MoneroMessageSignatureType = MoneroMessageSignatureType(99)
with pytest.raises(RuntimeError, match="Invalid signature type requested"):
w.sign_message("hello", invalid_type, 1, 1)
finally:
diff --git a/tests/wallet/wallet_support.py b/tests/wallet/wallet_support.py
index 8264d55..d17271c 100644
--- a/tests/wallet/wallet_support.py
+++ b/tests/wallet/wallet_support.py
@@ -203,7 +203,7 @@ def after_all(self) -> None:
@override
def before_each(self, request: pytest.FixtureRequest) -> None:
- logger.info(f"Before {request.node.name}") # type: ignore
+ logger.info(f"Before {request.node.name}")
@override
def after_each(self, request: pytest.FixtureRequest) -> None: