Fix Wallet::descriptor_checksum to actually return the checksum

This commit is contained in:
志宇 2022-09-27 21:56:25 +08:00
parent b14e4ee3a0
commit af0b3698c6
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8

View File

@ -1842,7 +1842,7 @@ where
.to_string()
.split_once('#')
.unwrap()
.0
.1
.to_string()
}
}
@ -1938,6 +1938,22 @@ pub(crate) mod test {
// OP_PUSH.
const P2WPKH_FAKE_WITNESS_SIZE: usize = 106;
#[test]
fn test_descriptor_checksum() {
let (wallet, _, _) = get_funded_wallet(get_test_wpkh());
let checksum = wallet.descriptor_checksum(KeychainKind::External);
assert_eq!(checksum.len(), 8);
let raw_descriptor = wallet
.descriptor
.to_string()
.split_once('#')
.unwrap()
.0
.to_string();
assert_eq!(get_checksum(&raw_descriptor).unwrap(), checksum);
}
#[test]
fn test_get_funded_wallet_balance() {
let (wallet, _, _) = get_funded_wallet(get_test_wpkh());