Skip to content

Commit

Permalink
test: test getting keychain for a script
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirfomene committed Nov 9, 2023
1 parent b3d40e5 commit a6433a1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/bdk/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ fn receive_output_in_latest_block(wallet: &mut Wallet, value: u64) -> OutPoint {
// OP_PUSH.
const P2WPKH_FAKE_WITNESS_SIZE: usize = 106;

#[test]
fn test_which_keychain_derived_script() {
let (segwit_wallet, _) = get_funded_wallet(get_test_wpkh());
let addr = segwit_wallet.get_address(New);
let script = addr.script_pubkey();
let keychain = segwit_wallet
.which_keychain_derived_script(&script)
.unwrap();
assert_eq!(keychain.0, KeychainKind::External);

let (taproot_wallet, _) = get_funded_wallet(get_test_tr_single_sig());
let addr = segwit_wallet.get_address(New);
let script = addr.script_pubkey();
let keychain = segwit_wallet.which_keychain_derived_script(&script);
assert!(keychain.is_none());
}

#[test]
fn test_descriptor_checksum() {
let (wallet, _) = get_funded_wallet(get_test_wpkh());
Expand Down

0 comments on commit a6433a1

Please sign in to comment.