Merge rust-bitcoin/rust-bitcoin#2026: Use valid Psbt for serde regression test

95b7a95fc2 test: correct psbt used for regression test (Subhradeep Chakraborty)

Pull request description:

  The `unknown` key used in the `Psbt` (in `serde_regression_psbt` test) is not really unknown. Also the `preimages` in the `Input` don't seem to be valid. Though they don't affect the tests because of the `serde::serialize`, the `Psbt` itself is invalid and hence this PR.

ACKs for top commit:
  tcharding:
    ACK 95b7a95fc2
  apoelstra:
    ACK 95b7a95fc2

Tree-SHA512: 275320bb273163364640351e55a3f16c34c1eef06e9dde79b72bf40187d313f037edb5e4544f4dce32fb8a7cc552504aa2e4d22a646c89a3dec022f917539219
This commit is contained in:
Andrew Poelstra 2023-09-21 18:13:17 +00:00
commit c32c7d1611
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 9 additions and 5 deletions

View File

@ -245,7 +245,7 @@ fn serde_regression_psbt() {
}],
};
let unknown: BTreeMap<raw::Key, Vec<u8>> =
vec![(raw::Key { type_value: 1, key: vec![0, 1] }, vec![3, 4, 5])].into_iter().collect();
vec![(raw::Key { type_value: 9, key: vec![0, 1] }, vec![3, 4, 5])].into_iter().collect();
let key_source = ("deadbeef".parse().unwrap(), "m/0'/1".parse().unwrap());
let keypaths: BTreeMap<secp256k1::PublicKey, KeySource> = vec![(
"0339880dc92394b7355e3d0439fa283c31de7590812ea011c4245c0674a685e883".parse().unwrap(),
@ -296,10 +296,10 @@ fn serde_regression_psbt() {
)].into_iter().collect(),
bip32_derivation: keypaths.clone().into_iter().collect(),
final_script_witness: Some(Witness::from_slice(&[vec![1, 3], vec![5]])),
ripemd160_preimages: vec![(ripemd160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
sha256_preimages: vec![(sha256::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
hash160_preimages: vec![(hash160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
hash256_preimages: vec![(sha256d::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
ripemd160_preimages: vec![(ripemd160::Hash::hash(&[1, 2]), vec![1, 2])].into_iter().collect(),
sha256_preimages: vec![(sha256::Hash::hash(&[1, 2]), vec![1, 2])].into_iter().collect(),
hash160_preimages: vec![(hash160::Hash::hash(&[1, 2]), vec![1, 2])].into_iter().collect(),
hash256_preimages: vec![(sha256d::Hash::hash(&[1, 2]), vec![1, 2])].into_iter().collect(),
proprietary: proprietary.clone(),
unknown: unknown.clone(),
..Default::default()
@ -312,6 +312,10 @@ fn serde_regression_psbt() {
}],
};
// Sanity, check we can roundtrip BIP-174 serialize.
let serialized = psbt.serialize();
Psbt::deserialize(&serialized).unwrap();
let got = serialize(&psbt).unwrap();
let want = include_bytes!("data/serde/psbt_bincode") as &[_];
assert_eq!(got, want)