test(wallet): ensure checks work when loading wallet

This commit is contained in:
志宇
2024-07-18 06:47:34 +00:00
parent af4ee0fa4b
commit 3aed4cf179
6 changed files with 107 additions and 6 deletions

View File

@@ -13,7 +13,7 @@
use core::fmt;
/// Errors related to the parsing and usage of descriptors
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum Error {
/// Invalid HD Key path, such as having a wildcard but a length != 1
InvalidHdKeyPath,

View File

@@ -935,7 +935,7 @@ impl<Ctx: ScriptContext> IntoDescriptorKey<Ctx> for PrivateKey {
}
/// Errors thrown while working with [`keys`](crate::keys)
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum KeyError {
/// The key cannot exist in the given script context
InvalidScriptContext,

View File

@@ -184,7 +184,7 @@ impl fmt::Display for AddressInfo {
}
/// The error type when loading a [`Wallet`] from a [`ChangeSet`].
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum LoadError {
/// There was a problem with the passed-in descriptor(s).
Descriptor(crate::descriptor::DescriptorError),
@@ -216,7 +216,7 @@ impl fmt::Display for LoadError {
impl std::error::Error for LoadError {}
/// Represents a mismatch with what is loaded and what is expected from [`LoadParams`].
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum LoadMismatch {
/// Network does not match.
Network {
@@ -243,6 +243,18 @@ pub enum LoadMismatch {
},
}
impl From<LoadMismatch> for LoadError {
fn from(mismatch: LoadMismatch) -> Self {
Self::Mismatch(mismatch)
}
}
impl<E> From<LoadMismatch> for LoadWithPersistError<E> {
fn from(mismatch: LoadMismatch) -> Self {
Self::InvalidChangeSet(LoadError::Mismatch(mismatch))
}
}
/// An error that may occur when applying a block to [`Wallet`].
#[derive(Debug)]
pub enum ApplyBlockError {

View File

@@ -138,7 +138,7 @@ impl chain::PersistWith<bdk_file_store::Store<crate::ChangeSet>> for Wallet {
}
/// Error type for [`PersistedWallet::load`].
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum LoadWithPersistError<E> {
/// Error from persistence.
Persist(E),