Coverage for tests/utils/wallet_send_utils.py: 100%
38 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 19:49 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 19:49 +0000
2from abc import ABC
3from typing import Optional
5from monero import MoneroWallet, MoneroTxConfig, MoneroDaemon
7from .single_tx_sender import SingleTxSender
8from .from_multiple_tx_sender import FromMultipleTxSender
9from .to_multiple_tx_sender import ToMultipleTxSender
10from .wallet_sweeper import WalletSweeper
11from .send_and_update_txs_tester import SendAndUpdateTxsTester
12from .sync_with_pool_submit_tester import SyncWithPoolSubmitTester
15class WalletSendUtils(ABC):
17 # Convenience method for single tx send tests
18 @classmethod
19 def test_send_to_single(cls, wallet: MoneroWallet, can_split: bool, relay: Optional[bool] = None, payment_id: Optional[str] = None) -> None:
20 """Test creating transaction and sending to single destination.
22 :param MoneroWallet wallet: wallet to send funds from.
23 :param bool can_split: Can split transactions.
24 :param bool | None relay: Relay created transaction(s).
25 :param str | None payment_id: Transaction payment id.
26 """
27 config: MoneroTxConfig = MoneroTxConfig()
28 config.can_split = can_split
29 config.relay = relay
30 config.payment_id = payment_id
31 sender: SingleTxSender = SingleTxSender(wallet, config)
32 sender.send()
34 # Convenience method for sending funds from multiple sources
35 @classmethod
36 def test_send_from_multiple(cls, wallet: MoneroWallet, can_split: bool | None) -> None:
37 """Test send multiple txs from wallet.
39 :param MoneroWallet wallet: test wallet to send txs from.
40 :param bool can_split: can split wallet txs.
41 """
42 sender: FromMultipleTxSender = FromMultipleTxSender(wallet, can_split)
43 sender.send()
45 # Convenience method for multiple tx send tests
46 @classmethod
47 def test_send_to_multiple(
48 cls,
49 wallet: MoneroWallet,
50 num_accounts: int,
51 num_subaddresses_per_account: int,
52 can_split: bool,
53 send_amount_per_subaddress: Optional[int] = None,
54 subtract_fee_from_destinations: bool = False
55 ) -> None:
56 """Test send multiple txs from wallet to multiple accounts and subaddresses.
58 :param MoneroWallet wallet: test wallet to send txs from.
59 :param int num_accounts: number of accounts to send to.
60 :param int num_subaddresses_per_account: number of subaddresses per account to send to.
61 :param bool can_split: can split wallet txs.
62 :param int | None send_amount_per_subaddress: amount to send to each subaddress, or
63 `None` to compute it from the account's unlocked balance (default `None`).
64 :param bool subtract_fee_from_destinations: subtract the tx fee from destination amounts
65 instead of the sender's balance (default `False`).
66 """
67 sender: ToMultipleTxSender = ToMultipleTxSender(
68 wallet, num_accounts, num_subaddresses_per_account,
69 can_split, send_amount_per_subaddress, subtract_fee_from_destinations)
70 sender.send()
72 @classmethod
73 def test_sweep_wallet(cls, wallet: MoneroWallet, sweep_each_subaddress: Optional[bool]) -> None:
74 """Test creating sweep wallet transaction.
76 :param MoneroWallet wallet: test wallet to sweep.
77 :param bool | None sweep_each_subaddress: sweep each wallet subaddresses.
78 """
79 sweeper: WalletSweeper = WalletSweeper(wallet, sweep_each_subaddress)
80 sweeper.sweep()
82 @classmethod
83 def test_send_and_update_txs(cls, daemon: MoneroDaemon, wallet: MoneroWallet, config: MoneroTxConfig) -> None:
84 """Test sending a tx and observing its status update as it confirms.
86 :param MoneroDaemon daemon: daemon to test against.
87 :param MoneroWallet wallet: test wallet to send the tx from.
88 :param MoneroTxConfig config: tx configuration to send with.
89 """
90 tester: SendAndUpdateTxsTester = SendAndUpdateTxsTester(daemon, wallet, config)
91 tester.test()
93 @classmethod
94 def test_sync_with_pool_submit(cls, daemon: MoneroDaemon, wallet: MoneroWallet, config: MoneroTxConfig) -> None:
95 """Test that syncing with the pool detects a tx submitted directly to the daemon.
97 :param MoneroDaemon daemon: daemon to test against.
98 :param MoneroWallet wallet: test wallet to sync and submit the tx with.
99 :param MoneroTxConfig config: tx configuration to send with.
100 """
101 tester: SyncWithPoolSubmitTester = SyncWithPoolSubmitTester(daemon, wallet, config)
102 tester.test()