Add assert_matches dev-dependency

This commit is contained in:
thunderbiscuit 2022-12-15 09:39:59 -05:00
parent 41f15fe80f
commit bada9b82e0
No known key found for this signature in database
GPG Key ID: 88253696EB836462
3 changed files with 20 additions and 8 deletions

7
Cargo.lock generated
View File

@ -73,6 +73,12 @@ dependencies = [
"toml", "toml",
] ]
[[package]]
name = "assert_matches"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
[[package]] [[package]]
name = "async-trait" name = "async-trait"
version = "0.1.59" version = "0.1.59"
@ -146,6 +152,7 @@ dependencies = [
name = "bdk-ffi" name = "bdk-ffi"
version = "0.25.0" version = "0.25.0"
dependencies = [ dependencies = [
"assert_matches",
"bdk", "bdk",
"uniffi", "uniffi",
"uniffi_build", "uniffi_build",

View File

@ -11,9 +11,11 @@ name = "bdkffi"
[dependencies] [dependencies]
bdk = { version = "0.25", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] } bdk = { version = "0.25", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] }
uniffi_macros = { version = "0.21.0", features = ["builtin-bindgen"] } uniffi_macros = { version = "0.21.0", features = ["builtin-bindgen"] }
uniffi = { version = "0.21.0", features = ["builtin-bindgen"] } uniffi = { version = "0.21.0", features = ["builtin-bindgen"] }
[build-dependencies] [build-dependencies]
uniffi_build = { version = "0.21.0", features = ["builtin-bindgen"] } uniffi_build = { version = "0.21.0", features = ["builtin-bindgen"] }
[dev-dependencies]
assert_matches = "1.5.0"

View File

@ -1375,7 +1375,10 @@ uniffi::deps::static_assertions::assert_impl_all!(Wallet: Sync, Send);
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::*; use crate::*;
use assert_matches::assert_matches;
use bdk::bitcoin::Address; use bdk::bitcoin::Address;
use bdk::descriptor::DescriptorError::Key;
use bdk::keys::KeyError::InvalidNetwork;
use bdk::wallet::get_funded_wallet; use bdk::wallet::get_funded_wallet;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Mutex; 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 // Creating a Descriptor using an extended key that doesn't match the network provided will throw and InvalidNetwork Error
assert!(descriptor1.is_ok()); assert!(descriptor1.is_ok());
assert_eq!( assert_matches!(
descriptor2.unwrap_err().to_string(), descriptor2.unwrap_err(),
"Descriptor(Key(InvalidNetwork))" 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 // 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!(wallet1.is_ok());
assert_eq!( assert_matches!(
wallet2.unwrap_err().to_string(), wallet2.unwrap_err(),
"Descriptor(Key(InvalidNetwork))" bdk::Error::Descriptor(Key(InvalidNetwork))
); )
} }
} }