Skip to content

Commit 0683fb3

Browse files
committed
test(wallet): update to use new SignerWrapper util
- updates the existing tests that uses the `Wallet::sign` API, to gethe signer implementation from test utilities, either: `get_wallet_signer_single` or `get_wallet_signer`. - there are a few tests which needs further refactoring, as they rely on the use of `Wallet::finalize_psbt`. - FIXME: there is one test that's being ignored: `test_sign_single_xprv_no_hd_keypaths` which is currently failing to finalized the PSBT.
1 parent 017dad1 commit 0683fb3

File tree

2 files changed

+303
-226
lines changed

2 files changed

+303
-226
lines changed

wallet/src/test_utils.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ impl GetKey for SignerWrapper {
4343
secp: &bitcoin::key::Secp256k1<C>,
4444
) -> Result<Option<bitcoin::PrivateKey>, Self::Error> {
4545
for (descriptor_pk, descriptor_sk) in self.key_map.iter() {
46-
match (descriptor_sk, key_request) {
46+
match (descriptor_sk, key_request.clone()) {
4747
(DescriptorSecretKey::Single(single_priv), key_request) => {
4848
let private_key = single_priv.key;
4949
let public_key = private_key.public_key(secp);
5050
let keys = BTreeMap::from([(public_key, private_key)]);
51-
return keys.get_key(key_request, secp);
51+
match keys.get_key(key_request, secp) {
52+
Ok(Some(pk)) => return Ok(Some(pk)),
53+
Ok(None) => continue,
54+
Err(e) => return Err(e),
55+
}
5256
}
5357
(DescriptorSecretKey::XPrv(descriptor_xkey), KeyRequest::Pubkey(public_key)) => {
5458
match descriptor_pk {
@@ -63,7 +67,7 @@ impl GetKey for SignerWrapper {
6367
.to_priv(),
6468
))
6569
}
66-
false => return Ok(None),
70+
false => continue,
6771
}
6872
}
6973
_ => unreachable!(),
@@ -99,7 +103,7 @@ impl GetKey for SignerWrapper {
99103
));
100104
}
101105
},
102-
None => return Ok(None),
106+
None => continue,
103107
},
104108
Err(e) => return Err(e),
105109
}

0 commit comments

Comments
 (0)