Merge rust-bitcoin/rust-bitcoin#2364: Test: add invalid segwit transaction test

fe8d559d69 test: add invalid segwit transaction test (startup-dreamer)

Pull request description:

  Tries to close #2183

  Added the test for invalid segwit transaction (witness flag is set but no witness is present) using [This suggested hex](https://github.com/rust-bitcoin/rust-bitcoin/issues/2183#issuecomment-1901207149) by Kixunil

ACKs for top commit:
  Kixunil:
    ACK fe8d559d69
  apoelstra:
    ACK fe8d559d69

Tree-SHA512: 723027e0ad9944a4763fba1e12398d7bcacdef691a40168f0be7cecdb170936f7e0c3690c4de911d086b8c5d42f5a25784f53fe096404f5cf69d6fc75c645d6e
This commit is contained in:
Andrew Poelstra 2024-01-21 14:43:01 +00:00
commit ff51619c79
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 11 additions and 0 deletions

View File

@ -1745,6 +1745,17 @@ mod tests {
assert_eq!(realtx.base_size(), tx_bytes.len());
}
#[test]
fn segwit_invalid_transaction() {
let tx_bytes = hex!("0000fd000001021921212121212121212121f8b372b0239cc1dff600000000004f4f4f4f4f4f4f4f000000000000000000000000000000333732343133380d000000000000000000000000000000ff000000000009000dff000000000000000800000000000000000d");
let tx: Result<Transaction, _> = deserialize(&tx_bytes);
assert!(tx.is_err());
assert!(tx
.unwrap_err()
.to_string()
.contains("witness flag set but no witnesses present"));
}
#[test]
fn segwit_transaction() {
let tx_bytes = hex!(