diff options
| author | tobtoht <tob@featherwallet.org> | 2025-07-10 12:19:42 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2025-07-10 12:19:42 +0000 |
| commit | 8b4f0a6258af26b978b85a1fa1bd0ee8244de3de (patch) | |
| tree | 6d4fa72191edfdd028228d04e5f2688648757b03 /tests/functional_tests | |
| parent | f1ffcc5c497c8b5475eab4a9ff53b21e21f58d50 (diff) | |
| parent | 1da19dac545bb5c0521949a212af42a7f351776e (diff) | |
| download | monzero-core-8b4f0a6258af26b978b85a1fa1bd0ee8244de3de.tar.gz monzero-core-8b4f0a6258af26b978b85a1fa1bd0ee8244de3de.tar.xz monzero-core-8b4f0a6258af26b978b85a1fa1bd0ee8244de3de.zip | |
Merge pull request #9954
1da19da wallet: refactor subaddress expansion & add to transfer test (jeffro256)
e23d51b wallet: improve lookahead logic & make rpc persistent (Justin Berman)
678f5da wallet: create set_subaddress_lookahead wallet rpc endpoint (benevanoff)
8f5a7b0 wallet: ensure subaddress keys table is at least size of requested lookahead (benevanoff)
Diffstat (limited to 'tests/functional_tests')
| -rwxr-xr-x | tests/functional_tests/transfer.py | 43 | ||||
| -rwxr-xr-x | tests/functional_tests/wallet.py | 15 |
2 files changed, 58 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() diff --git a/tests/functional_tests/wallet.py b/tests/functional_tests/wallet.py index 8182cecb2..1cbe4ee68 100755 --- a/tests/functional_tests/wallet.py +++ b/tests/functional_tests/wallet.py @@ -47,6 +47,7 @@ class WalletTest(): self.check_keys() self.create_subaddresses() self.tags() + self.update_lookahead() self.attributes() self.open_close() self.languages() @@ -164,6 +165,20 @@ class WalletTest(): res = wallet.label_account(0, "main") + def update_lookahead(self): + print('Updating subaddress lookahead') + wallet = Wallet() + 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 + wallet.get_address_index(address_0_999) + 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 + wallet.set_subaddress_lookahead(50, 1000) + r = wallet.get_address_index(address_0_999) + assert r['index']['major'] == 0 + assert r['index']['minor'] == 999 + def tags(self): print('Testing tags') wallet = Wallet() |
