Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 python3-pytest python3-pytest-rerunfailures python3-pytest-cov lcov python3-scikit-build-core
pip3 install pybind11-stubgen pytest pyproject-metadata --break-system-packages
sudo apt install -y build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz git curl autoconf libtool gperf nettle-dev libevent-dev debhelper python3-all python3-pip python3-pybind11 lcov python3-scikit-build-core
pip3 install pybind11-stubgen pytest pytest-rerunfailures pytest-cov pytest-timeout pyproject-metadata --break-system-packages

- name: Install expat
run: |
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
- name: Install pytest and dependencies
shell: bash
run: |
python -m pip install pytest pytest-rerunfailures typing_extensions scikit-build-core
python -m pip install pytest pytest-rerunfailures pytest-timeout pytest-cov typing_extensions scikit-build-core

- name: Setup MSYS2 MINGW64
uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
HOMEBREW_NO_AUTO_UPDATE=1 brew install python boost@1.85 hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound
brew unlink boost || true
brew link boost@1.85 --force
pip3 install pytest pytest-rerunfailures pytest-cov setuptools wheel scikit-build-core --break-system-packages
pip3 install pytest pytest-rerunfailures pytest-timeout pytest-cov setuptools wheel scikit-build-core --break-system-packages

- name: Install pybind11 v2.13.6
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_wallets
.github/instructions/codacy.instructions.md
.idea
.codacy
coverage/
coverage*
.coverage
.cache
monero.log
Expand Down
1 change: 1 addition & 0 deletions bin/cleanup_test_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# remove docker containers
sudo docker compose -f tests/docker-compose.yml down -v
rm -rf test_wallets
rm monero_tests_*
18 changes: 16 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import pytest

from os.path import splitext
from tests.utils.gen_utils import GenUtils


def pytest_configure(config: pytest.Config) -> None:
# inject current date/time into the configured log file name
log_file: str = config.getini("log_file") # type: ignore

if not log_file:
return

name, ext = splitext(log_file)
config.option.log_file = f"{name}_{GenUtils.current_date_time_str()}{ext}"


def pytest_runtest_call(item: pytest.Item):
# get not_supported marker
Expand All @@ -18,9 +32,9 @@ def pytest_runtest_call(item: pytest.Item):
try:
# run test
item.runtest()
except RuntimeError as e:
except Exception as e:
e_str = str(e).lower()
if "not supported" in e_str or "does not support" in e_str:
if "not supported" in e_str or "does not support" in e_str or "doesn't support" in e_str:
# Ok
pytest.xfail(str(e))
if not_implemented and "not implemented" in e_str:
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ authors = [
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"pybind11>=2.12"
]
dependencies = []

[build-system]
requires = [
Expand Down
7 changes: 6 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[pytest]
minversion = 6.0
addopts = -v --reruns 5 --reruns-delay 10 --only-rerun "BUSY"
required_plugins = pytest-rerunfailures pytest-timeout pytest-cov
addopts = -s -v --reruns 5 --reruns-delay 10 --only-rerun "BUSY"
log_level = INFO
log_cli = True
log_cli_level = INFO
console_output_style = progress
log_file = monero_tests_python.log
log_file_level = DEBUG
log_file_format = %(asctime)s %(levelname)-8s %(name)s:%(lineno)s %(message)s
log_file_date_format = %Y-%m-%d %H:%M:%S
testpaths =
tests
markers =
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/common/py_monero_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ rapidjson::Value PyMoneroRequestParams::to_rapidjson_val(rapidjson::Document::Al
std::string json = PyGenUtils::serialize(m_py_params.get());
rapidjson::Document doc;
doc.Parse(json.c_str());
root.Swap(doc);
root.CopyFrom(doc, allocator);

return root;
}
8 changes: 7 additions & 1 deletion src/cpp/common/py_monero_common_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ void py_monero_bind_common(py::module_& m, PyMoneroTypes& t) {
// monero_rpc_payment_info
t.py_monero_rpc_payment_info
.def(py::init<>())
.def_static("deserialize", [](const std::string& json) {
MONERO_CATCH_AND_RETHROW(py_monero_deserialize<monero_rpc_payment_info>(json));
}, py::arg("json"))
.def_readwrite("credits", &monero_rpc_payment_info::m_credits)
.def_readwrite("top_block_hash", &monero_rpc_payment_info::m_top_block_hash);

Expand All @@ -253,6 +256,9 @@ void py_monero_bind_common(py::module_& m, PyMoneroTypes& t) {
.def_static("compare", [](int p1, int p2) {
MONERO_CATCH_AND_RETHROW(monero_rpc_connection::compare(p1, p2));
}, py::arg("p1"), py::arg("p2"))
.def_static("deserialize", [](const std::string& json) {
MONERO_CATCH_AND_RETHROW(py_monero_deserialize_rpc_connection(json));
}, py::arg("json"))
.def_property("uri",
[](const monero_rpc_connection& self) { return self.m_uri; },
[](monero_rpc_connection& self, const boost::optional<std::string>& val) {
Expand Down Expand Up @@ -322,7 +328,7 @@ void py_monero_bind_common(py::module_& m, PyMoneroTypes& t) {
return res;
}, py::arg("method"), py::arg("parameters") = py::none())
.def("send_path_request", [](monero_rpc_connection& self, const std::string &method, const boost::optional<py::object>& parameters) {
monero_rpc_request request(method, std::make_shared<PyMoneroRequestParams>(parameters));
monero_rpc_request request(method, std::make_shared<PyMoneroRequestParams>(parameters), false);
auto response = self.send_path_request(request);
boost::optional<py::object> res;
if (response.m_response != boost::none) res = PyGenUtils::ptree_to_pyobject(*response.m_response);
Expand Down
Loading
Loading