From 3f6e098d989e1e9e83ddb998c84a12a62aca096e Mon Sep 17 00:00:00 2001 From: Daira Emma Hopwood Date: Wed, 6 Sep 2023 19:31:07 +0100 Subject: [PATCH] Allow keeping wallet database files. Signed-off-by: Daira Emma Hopwood --- zcash_client_sqlite/src/testing.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/zcash_client_sqlite/src/testing.rs b/zcash_client_sqlite/src/testing.rs index 7ab9a0587b..d6be23368b 100644 --- a/zcash_client_sqlite/src/testing.rs +++ b/zcash_client_sqlite/src/testing.rs @@ -320,18 +320,20 @@ where ) } - /// Reset the wallet using a new wallet database, but with the same cache of blocks. + /// Resets the wallet using a new wallet database but with the same cache of blocks, + /// and returns the old wallet database file. /// /// This does not recreate accounts, nor does it rescan the cached blocks. /// The resulting wallet has no test account. /// Before using any `generate_*` method on the reset state, call `reset_latest_cached_block()`. - pub(crate) fn reset(&mut self) { + pub(crate) fn reset(&mut self) -> NamedTempFile { let network = self.network(); self.latest_cached_block = None; - self._data_file = NamedTempFile::new().unwrap(); + let tf = std::mem::replace(&mut self._data_file, NamedTempFile::new().unwrap()); self.db_data = WalletDb::for_path(self._data_file.path(), network).unwrap(); self.test_account = None; init_wallet_db(&mut self.db_data, None).unwrap(); + tf } /// Reset the latest cached block to the most recent one in the cache database.