aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjeffro256 <jeffro256@tutanota.com>2025-07-07 20:07:24 +0000
committernahuhh <50635951+nahuhh@users.noreply.github.com>2025-07-07 22:21:46 +0000
commit1da19dac545bb5c0521949a212af42a7f351776e (patch)
treee7793cde76b51823d6bcf5793c273df4d5f9ced1 /tests
parente23d51bc1683e4aa369ba0f2889b96113eeb4e3a (diff)
downloadmonzero-core-1da19dac545bb5c0521949a212af42a7f351776e.tar.gz
monzero-core-1da19dac545bb5c0521949a212af42a7f351776e.tar.xz
monzero-core-1da19dac545bb5c0521949a212af42a7f351776e.zip
wallet: refactor subaddress expansion & add to transfer test
Diffstat (limited to 'tests')
-rwxr-xr-xtests/functional_tests/transfer.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index 60eb09a10..78d16f802 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -77,6 +77,7 @@ class TransferTest():
self.check_subtract_fee_from_outputs()
self.check_background_sync()
self.check_background_sync_reorg_recovery()
+ self.check_subaddress_lookahead()
def reset(self):
print('Resetting blockchain')
@@ -1515,5 +1516,47 @@ class TransferTest():
self.wallet[0].close_wallet()
self.wallet[0].restore_deterministic_wallet(seed = seeds[0])
+ def check_subaddress_lookahead(self):
+ daemon = Daemon()
+
+ print('Testing transfers to subaddresses with large lookahead')
+
+ # From wallet 1 to wallet 0 at subaddress (0, 999)
+
+ address_0_999 = '8BQKgTSSqJjP14AKnZUBwnXWj46MuNmLvHfPTpmry52DbfNjjHVvHUk4mczU8nj8yZ57zBhksTJ8kM5xKeJXw55kCMVqyG7' # this is the address for address 999 of the main account in the test wallet
+ try: # assert address_1_999 is not in the current pubkey table
+ self.wallet[0].get_address_index(address_0_999)
+ assert False # address should not already be loaded
+ except Exception as e:
+ assert str(e) == "{'error': {'code': -2, 'message': \"Address doesn't belong to the wallet\"}, 'id': '0', 'jsonrpc': '2.0'}"
+ # update the lookahead and assert the high index address is now in the table
+ self.wallet[0].set_subaddress_lookahead(50, 1000)
+ res = self.wallet[0].get_address_index(address_0_999)
+ assert res['index']['major'] == 0
+ assert res['index']['minor'] == 999
+
+ dst = {'address': address_0_999, 'amount': 454545454545}
+
+ self.wallet[1].refresh()
+ assert self.wallet[1].get_balance().balance > dst['amount']
+ self.wallet[1].transfer([dst])
+ daemon.generateblocks('46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerK', 1)
+ self.wallet[0].refresh()
+
+ res = self.wallet[0].get_balance()
+ balance_info_0_999 = None
+ for balance_info in res['per_subaddress']:
+ if balance_info['account_index'] == 0 and balance_info['address_index'] == 999:
+ balance_info_0_999 = balance_info
+ break
+ assert balance_info_0_999 is not None, "balance info for address (0, 999) not found"
+ assert balance_info_0_999['address'] == address_0_999
+ assert balance_info_0_999['balance'] == dst['amount']
+ assert balance_info_0_999['unlocked_balance'] == 0
+ assert balance_info_0_999['label'] == ''
+ assert balance_info_0_999['num_unspent_outputs'] == 1
+ assert balance_info_0_999['blocks_to_unlock'] == 9
+ assert balance_info_0_999['time_to_unlock'] == 0
+
if __name__ == '__main__':
TransferTest().run_test()