Coverage for tests/wallet/test_mining.py: 96%

27 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-22 19:49 +0000

1from __future__ import annotations 

2 

3import logging 

4 

5import pytest 

6from monero import MoneroDaemonRpc, MoneroMiningStatus, MoneroWallet 

7from typing_extensions import override 

8 

9from utils import TestUtils 

10from .base_test_monero_wallet import BaseTestMoneroWallet 

11from .wallet_support import FullWalletSupport, RpcWalletSupport, KeysWalletSupport 

12 

13logger: logging.Logger = logging.getLogger("TestMoneroWalletMining") 

14 

15 

16class BaseTestMoneroWalletMining(BaseTestMoneroWallet): 

17 """Common wallet mining tests.""" 

18 

19 # Can start and stop mining 

20 @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") 

21 def test_mining(self, daemon: MoneroDaemonRpc, wallet: MoneroWallet) -> None: 

22 status: MoneroMiningStatus = daemon.get_mining_status() 

23 if status.is_active: 

24 wallet.stop_mining() 

25 wallet.start_mining(1, False, True) 

26 wallet.stop_mining() 

27 

28 

29@pytest.mark.integration 

30class TestMoneroWalletFullMining(FullWalletSupport, BaseTestMoneroWalletMining): 

31 """Full wallet mining integration tests.""" 

32 

33 

34@pytest.mark.integration 

35class TestMoneroWalletRpcMining(RpcWalletSupport, BaseTestMoneroWalletMining): 

36 """Rpc wallet mining integration tests.""" 

37 

38 

39@pytest.mark.unit 

40class TestMoneroWalletKeysMining(KeysWalletSupport, BaseTestMoneroWalletMining): 

41 """Keys-only wallet mining unit tests.""" 

42 

43 @pytest.mark.not_supported 

44 @override 

45 def test_mining(self, daemon: MoneroDaemonRpc, wallet: MoneroWallet) -> None: 

46 return super().test_mining(daemon, wallet)