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
4 changes: 3 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ jobs:
-DPython3_FIND_REGISTRY=NEVER
cmake --build .
mkdir -p ../dist
cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
cp *.pyd ../dist/monero.pyd
cd ../dist
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
cp "$(cygpath -u "$line")" ../dist/
cp "$(cygpath -u "$line")" .
done

- name: Upload artifacts
Expand Down
65 changes: 32 additions & 33 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,39 @@ jobs:
language: c
coverage-reports: coverage.info

# TODO build docker monero image for windows
# report-coverage-windows:
# if: github.repository == 'everoddandeven/monero-python'
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
report-coverage-windows:
if: github.repository == 'everoddandeven/monero-python'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Download coverage report
# uses: actions/download-artifact@v4
# with:
# name: coverage-reports-windows
# github-token: ${{ secrets.API_GITHUB }}
# run-id: ${{ github.event.workflow_run.id }}
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-reports-windows
github-token: ${{ secrets.API_GITHUB }}
run-id: ${{ github.event.workflow_run.id }}

# - name: Report python coverage
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# language: python
# coverage-reports: coverage.xml
- name: Report python coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
language: python
coverage-reports: coverage.xml

# - name: Report c++ coverage
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# language: cpp
# coverage-reports: coverage.info
- name: Report c++ coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
language: cpp
coverage-reports: coverage.info

# - name: Report c coverage
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# language: c
# coverage-reports: coverage.info
- name: Report c coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
language: c
coverage-reports: coverage.info
46 changes: 24 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Install pytest
shell: bash
run: |
python -m pip install pytest pytest-rerunfailures pytest-cov gcovr
python -m pip install pytest pytest-rerunfailures pytest-cov gcovr typing_extensions

- name: Setup MSYS2 MINGW64
uses: msys2/setup-msys2@v2
Expand Down Expand Up @@ -227,9 +227,11 @@ jobs:
-DPython3_FIND_REGISTRY=NEVER
cmake --build .
mkdir -p ../dist
cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
cp *.pyd ../dist/monero.pyd
cd ../dist
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
cp "$(cygpath -u "$line")" ../dist/
cp "$(cygpath -u "$line")" .
done
cd ..

Expand All @@ -239,29 +241,29 @@ jobs:
# run: |
# docker compose -f tests/docker-compose.yml up -d node_1 node_2 xmr_wallet_1 xmr_wallet_2

# - name: Run tests
# shell: bash
# env:
# IN_CONTAINER: "true"
# PYTHONPATH: ${{ github.workspace }}/dist
# PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH"
# run: |
# python -m pytest --cov=tests --cov-report=xml
- name: Run tests
shell: bash
env:
IN_CONTAINER: "true"
PYTHONPATH: ${{ github.workspace }}/dist
PATH: "${{ github.workspace }}/dist:/usr/bin:$PATH"
run: |
python -m pytest --cov=tests --cov-report=xml

# - name: Cleanup test environment
# if: always()
# shell: bash
# run: docker compose -f tests/docker-compose.yml down -v

# - name: Generate coverage report
# shell: bash
# run: |
# gcovr -r . --filter src/ --lcov coverage.info

# - name: Upload coverage report
# uses: actions/upload-artifact@v4
# with:
# name: coverage-reports-windows
# path: |
# coverage.info
# coverage.xml
- name: Generate coverage report
shell: bash
run: |
gcovr -r . --filter src/ --lcov coverage.info

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-reports-windows
path: |
coverage.info
coverage.xml
15 changes: 11 additions & 4 deletions tests/test_monero_daemon_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@
MoneroHardForkInfo, MoneroAltChain, MoneroTx, MoneroSubmitTxResult,
MoneroTxPoolStats, MoneroBan, MoneroTxConfig, MoneroDestination
)
from utils import TestUtils as Utils, TestContext, BinaryBlockContext, MiningUtils
from utils import (
TestUtils as Utils, TestContext,
BinaryBlockContext, MiningUtils,
OsUtils
)

logger: logging.Logger = logging.getLogger("TestMoneroDaemonRpc")


@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
class TestMoneroDaemonRpc:
_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()
_wallet: MoneroWallet = Utils.get_wallet_rpc()
_wallet: MoneroWallet = Utils.get_wallet_rpc() # type: ignore
BINARY_BLOCK_CTX: BinaryBlockContext = BinaryBlockContext()

#region Fixtures

@pytest.fixture(scope="class", autouse=True)
def before_all(self):
MiningUtils.wait_until_blockchain_ready()
MiningUtils.try_stop_mining()
# TODO setup test environment for windows
if not OsUtils.is_windows():
MiningUtils.wait_until_blockchain_ready()
MiningUtils.try_stop_mining()

@pytest.fixture(autouse=True)
def before_each(self, request: pytest.FixtureRequest):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_monero_rpc_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import logging

from monero import MoneroRpcConnection
from utils import TestUtils as Utils
from utils import TestUtils as Utils, OsUtils

logger: logging.Logger = logging.getLogger("TestMoneroRpcConnection")


@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
class TestMoneroRpcConnection:

@pytest.fixture(autouse=True)
Expand Down
8 changes: 5 additions & 3 deletions tests/test_monero_wallet_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
MoneroTxConfig, MoneroDestination, MoneroRpcConnection, MoneroError,
MoneroKeyImage, MoneroTxQuery, MoneroUtils, MoneroWalletFull
)
from utils import TestUtils, WalletEqualityUtils, MiningUtils
from utils import TestUtils, WalletEqualityUtils, MiningUtils, OsUtils

logger: logging.Logger = logging.getLogger("TestMoneroWalletCommon")

Expand Down Expand Up @@ -86,8 +86,10 @@ def test_config(self) -> BaseTestMoneroWallet.Config:

@pytest.fixture(scope="class", autouse=True)
def before_all(self):
MiningUtils.wait_until_blockchain_ready()
MiningUtils.try_stop_mining()
# TODO setup test environment for windows
if not OsUtils.is_windows():
MiningUtils.wait_until_blockchain_ready()
MiningUtils.try_stop_mining()

@pytest.fixture(autouse=True)
def before_each(self, request: pytest.FixtureRequest):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_monero_wallet_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
MoneroSubaddress, MoneroDaemonRpc, MoneroWallet
)

from utils import TestUtils as Utils
from utils import TestUtils as Utils, OsUtils
from test_monero_wallet_common import BaseTestMoneroWallet

logger: logging.Logger = logging.getLogger("TestMoneroWalletFull")


@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
class TestMoneroWalletFull(BaseTestMoneroWallet):

_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_monero_wallet_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def before_each(self, request: pytest.FixtureRequest):
yield
logger.info(f"After test {request.node.name}") # type: ignore

@pytest.fixture(scope="class", autouse=True)
@override
def before_all(self):
pass

#region Overrides

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion tests/test_monero_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from monero import MoneroWallet, MoneroWalletConfig, MoneroDaemonRpc, MoneroWalletRpc

from typing_extensions import override
from utils import TestUtils as Utils
from utils import TestUtils as Utils, OsUtils
from test_monero_wallet_common import BaseTestMoneroWallet

logger: logging.Logger = logging.getLogger("TestMoneroWalletRpc")


@pytest.mark.skipif(OsUtils.is_windows(), reason="TODO setup test environment for windows")
class TestMoneroWalletRpc(BaseTestMoneroWallet):

_daemon: MoneroDaemonRpc = Utils.get_daemon_rpc()
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .test_utils import TestUtils
from .mining_utils import MiningUtils
from .os_utils import OsUtils
from .wallet_sync_printer import WalletSyncPrinter
from .connection_change_collector import ConnectionChangeCollector
from .address_book import AddressBook
Expand All @@ -16,6 +17,7 @@
__all__ = [
'TestUtils',
'MiningUtils',
'OsUtils',
'WalletSyncPrinter',
'ConnectionChangeCollector',
'AddressBook',
Expand Down
9 changes: 9 additions & 0 deletions tests/utils/os_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
from abc import ABC


class OsUtils(ABC):

@classmethod
def is_windows(cls) -> bool:
return sys.platform == 'win32'
10 changes: 10 additions & 0 deletions tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .test_context import TestContext
from .tx_context import TxContext
from .binary_block_context import BinaryBlockContext
from .os_utils import OsUtils

logger: logging.Logger = logging.getLogger("TestUtils")

Expand Down Expand Up @@ -300,6 +301,9 @@ def create_test_wallets_dir(cls) -> None:

@classmethod
def get_daemon_rpc(cls) -> MoneroDaemonRpc:
if OsUtils.is_windows(): # TODO enable windows integration test env
return None # type: ignore

if cls._DAEMON_RPC is None:
cls._DAEMON_RPC = MoneroDaemonRpc(cls.DAEMON_RPC_URI, cls.DAEMON_RPC_USERNAME, cls.DAEMON_RPC_PASSWORD)

Expand Down Expand Up @@ -334,6 +338,9 @@ def get_wallet_full_config(cls, daemon_connection: MoneroRpcConnection) -> Moner

@classmethod
def get_wallet_full(cls) -> MoneroWalletFull:
if OsUtils.is_windows(): # TODO enable windows integration test env
return None # type: ignore

if cls._WALLET_FULL is None:
# create wallet from seed if it doesn't exist
if not MoneroWalletFull.wallet_exists(cls.WALLET_FULL_PATH):
Expand Down Expand Up @@ -371,6 +378,9 @@ def get_wallet_full(cls) -> MoneroWalletFull:

@classmethod
def get_wallet_rpc(cls) -> MoneroWalletRpc:
if OsUtils.is_windows(): # TODO enable windows integration test env
return None # type: ignore

if cls._WALLET_RPC is None:

# construct wallet rpc instance with daemon connection
Expand Down
Loading