diff --git a/Cargo.lock b/Cargo.lock index 4a8d953..65ee924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,6 +73,12 @@ dependencies = [ "toml", ] +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-trait" version = "0.1.59" @@ -146,6 +152,7 @@ dependencies = [ name = "bdk-ffi" version = "0.25.0" dependencies = [ + "assert_matches", "bdk", "uniffi", "uniffi_build", diff --git a/bdk-ffi/Cargo.toml b/bdk-ffi/Cargo.toml index 501de9d..99f46ec 100644 --- a/bdk-ffi/Cargo.toml +++ b/bdk-ffi/Cargo.toml @@ -11,9 +11,11 @@ name = "bdkffi" [dependencies] bdk = { version = "0.25", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] } - uniffi_macros = { version = "0.21.0", features = ["builtin-bindgen"] } uniffi = { version = "0.21.0", features = ["builtin-bindgen"] } [build-dependencies] uniffi_build = { version = "0.21.0", features = ["builtin-bindgen"] } + +[dev-dependencies] +assert_matches = "1.5.0" diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index c84c2ec..ddaeb51 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -1375,7 +1375,10 @@ uniffi::deps::static_assertions::assert_impl_all!(Wallet: Sync, Send); #[cfg(test)] mod test { use crate::*; + use assert_matches::assert_matches; use bdk::bitcoin::Address; + use bdk::descriptor::DescriptorError::Key; + use bdk::keys::KeyError::InvalidNetwork; use bdk::wallet::get_funded_wallet; use std::str::FromStr; use std::sync::Mutex; @@ -1713,9 +1716,9 @@ mod test { // Creating a Descriptor using an extended key that doesn't match the network provided will throw and InvalidNetwork Error assert!(descriptor1.is_ok()); - assert_eq!( - descriptor2.unwrap_err().to_string(), - "Descriptor(Key(InvalidNetwork))" + assert_matches!( + descriptor2.unwrap_err(), + bdk::Error::Descriptor(Key(InvalidNetwork)) ) } @@ -1739,9 +1742,9 @@ mod test { // Creating a wallet using a Descriptor with an extended key that doesn't match the network provided in the wallet constructor will throw and InvalidNetwork Error assert!(wallet1.is_ok()); - assert_eq!( - wallet2.unwrap_err().to_string(), - "Descriptor(Key(InvalidNetwork))" - ); + assert_matches!( + wallet2.unwrap_err(), + bdk::Error::Descriptor(Key(InvalidNetwork)) + ) } }