Skip to content

Commit

Permalink
Add assert_matches dev-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Dec 16, 2022
1 parent 41f15fe commit 0ef23f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ name = "bdkffi"
[dependencies]
bdk = { version = "0.25", features = ["all-keys", "use-esplora-ureq", "sqlite-bundled", "rpc"] }

[dev-dependencies]
assert_matches = "1.5.0"

uniffi_macros = { version = "0.21.0", features = ["builtin-bindgen"] }
uniffi = { version = "0.21.0", features = ["builtin-bindgen"] }

Expand Down
10 changes: 6 additions & 4 deletions bdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,12 +1373,17 @@ uniffi::deps::static_assertions::assert_impl_all!(Wallet: Sync, Send);
// These tests should not be used to verify `bdk` behavior that is already tested in the `bdk`
// crate.
#[cfg(test)]
extern crate assert_matches;

mod test {
use assert_matches::assert_matches;
use crate::*;
use bdk::bitcoin::Address;
use bdk::wallet::get_funded_wallet;
use std::str::FromStr;
use std::sync::Mutex;
use bdk::descriptor::DescriptorError::Key;
use bdk::keys::KeyError::InvalidNetwork;

#[test]
fn test_drain_wallet() {
Expand Down Expand Up @@ -1739,9 +1744,6 @@ 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)))
}
}

0 comments on commit 0ef23f6

Please sign in to comment.