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",
]
[[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",

View File

@ -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"

View File

@ -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))
)
}
}