Skip to content

Commit c849093

Browse files
integration tests: test wallet rpc get subaddress
1 parent 5142a34 commit c849093

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎tests/test_monero_wallet_rpc.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from monero import (
55
MoneroWallet, MoneroWalletConfig, MoneroWalletRpc,
66
MoneroAccount, MoneroError, MoneroDaemonRpc,
7-
MoneroTxWallet, MoneroUtils
7+
MoneroTxWallet, MoneroUtils, MoneroSubaddress
88
)
99

1010
from typing_extensions import override
1111
from utils import (
1212
TestUtils as Utils, StringUtils, WalletType,
13-
WalletNotificationCollector, WalletErrorUtils
13+
WalletNotificationCollector, WalletErrorUtils, WalletUtils, AssertUtils
1414
)
1515
from test_monero_wallet_common import BaseTestMoneroWallet
1616

@@ -114,6 +114,23 @@ def test_set_poll_period_in_ms(self, wallet: MoneroWalletRpc) -> None:
114114
# restore the configured period so later tests poll at the expected rate
115115
wallet.set_poll_period_in_ms(Utils.SYNC_PERIOD_IN_MS)
116116

117+
# Can get a subaddress via monero_wallet_rpc's
118+
@pytest.mark.skipif(Utils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled")
119+
def test_get_subaddress_rpc(self, wallet: MoneroWalletRpc) -> None:
120+
account_idx: int = 0
121+
subaddress_idx: int = 0
122+
123+
subaddress: MoneroSubaddress = wallet.get_subaddress(account_idx, subaddress_idx)
124+
WalletUtils.test_subaddress(subaddress)
125+
assert subaddress.account_index == account_idx
126+
assert subaddress.index == subaddress_idx
127+
128+
plural: list[MoneroSubaddress] = wallet.get_subaddresses(account_idx, [subaddress_idx])
129+
assert len(plural) == 1
130+
AssertUtils.assert_equals(subaddress, plural[0])
131+
132+
assert subaddress.address == wallet.get_address(account_idx, subaddress_idx)
133+
117134
@pytest.mark.skipif(Utils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled")
118135
@override
119136
def test_get_subaddress_address_out_of_range(self, wallet: MoneroWallet) -> None:

0 commit comments

Comments
 (0)