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: ACKfe8d559d69
apoelstra: ACKfe8d559d69
Tree-SHA512: 723027e0ad9944a4763fba1e12398d7bcacdef691a40168f0be7cecdb170936f7e0c3690c4de911d086b8c5d42f5a25784f53fe096404f5cf69d6fc75c645d6e
This commit is contained in:
commit
ff51619c79
|
@ -1745,6 +1745,17 @@ mod tests {
|
||||||
assert_eq!(realtx.base_size(), tx_bytes.len());
|
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]
|
#[test]
|
||||||
fn segwit_transaction() {
|
fn segwit_transaction() {
|
||||||
let tx_bytes = hex!(
|
let tx_bytes = hex!(
|
||||||
|
|
Loading…
Reference in New Issue