Point taken that this is about backups and not assumeutxo primarily, so I have added another test for this inwallet_backup.py
.
It would be beneficial to have this in a separate test method so that we can add more test cases cleanly without associating it with the assume UTXO test.
I don’t fully get this comment though. I don’t know how I could make a method that would make this code reusable. The code in wallet_assumeutxo.py
is spread across the test and pretty specific to the assumeutxo context. I don’t know how that would have help me in the other test I added.
For example, we can test https://github.com/furszy/bitcoin-core/commit/5b618f1b024f16640a2a05f1e269f61b33b86577 by creating a non-descriptor wallet, migrating it, and attempt to restore it.
I don’t know how to do this or rather I think it’s much more complicated than you make it sound. There needs to be a way for the blocks close to the backup height to be missing in order to hit this issue. This can happen because we are using assumeutxo, which was my initial use case for this, and in the new test I added, I achieved this with pruning. But in the walletmigration context, both wallets (before and after migration) are on the same node and the backup is created as part of the process but without any actual user interaction in that part of the process. So to hit this case we would make the wallet migration fail after the backup is created, mine a few more blocks, then prune the node to the height where the migration failed, and then try to use the backup from the failed migration.
Maybe I am missing something because I am not super familiar with the walletmigration code though.