Skip to content

Commit

Permalink
Allow keeping wallet database files.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira Emma Hopwood <[email protected]>
  • Loading branch information
daira committed Sep 12, 2023
1 parent ffe3474 commit c4ac0f1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zcash_client_sqlite/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c4ac0f1

Please sign in to comment.