From 84614d9997a69bac249f3e8ac3b90240b38ca747 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 16 Aug 2023 16:03:33 +1000 Subject: [PATCH] Unit test debug print of witness with empty instruction We recently fixed a bug that causes a panic if a `Witness` contains an empty instruction. Add a unit test to verify it. --- bitcoin/src/blockdata/witness.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs index 3d10a0a0..43e69d69 100644 --- a/bitcoin/src/blockdata/witness.rs +++ b/bitcoin/src/blockdata/witness.rs @@ -535,6 +535,16 @@ mod test { v } + #[test] + fn witness_debug_can_display_empty_instruction() { + let witness = Witness { + witness_elements: 1, + content: append_u32_vec(vec![], &[0]), + indices_start: 2, + }; + println!("{:?}", witness); + } + #[test] fn test_push() { let mut witness = Witness::default();