Add unit test for deserialize non-standard sighash

It is possible, although not immediately obvious, that it is possible to
create a `PsbtSigHashType` with a non-standard value.

Add a unit test to show this and also catch any regressions if we
accidental change this logic.
This commit is contained in:
Tobin Harding 2022-02-25 10:07:49 +00:00
parent e05776f176
commit 8e2422f92b
1 changed files with 12 additions and 0 deletions

View File

@ -367,3 +367,15 @@ impl Deserialize for TapTree {
fn key_source_len(key_source: &KeySource) -> usize {
4 + 4 * (key_source.1).as_ref().len()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn can_deserialize_non_standard_psbt_sig_hash_type() {
let non_standard_sighash = [222u8, 0u8, 0u8, 0u8]; // 32 byte value.
let sighash = PsbtSigHashType::deserialize(&non_standard_sighash);
assert!(sighash.is_ok())
}
}