Skip to content

Commit a2bae3b

Browse files
committed
Add test for impl Display for Script
Match arms in `impl fmt::Display for Script` were untested. Add a regression test for the `OP_PUSHDATAx` match arms.
1 parent ad40e69 commit a2bae3b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

primitives/src/script/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,21 @@ mod tests {
802802
assert!(!format!("{:?}", script).is_empty());
803803
}
804804

805+
#[test]
806+
fn script_display_pushdata() {
807+
// OP_PUSHDATA1
808+
let script = Script::from_bytes(&[0x4c, 0x02, 0xab, 0xcd]);
809+
assert_eq!(format!("{}", script), "OP_PUSHDATA1 abcd");
810+
811+
// OP_PUSHDATA2
812+
let script = Script::from_bytes(&[0x4d, 0x02, 0x00, 0x12, 0x34]);
813+
assert_eq!(format!("{}", script), "OP_PUSHDATA2 1234");
814+
815+
// OP_PUSHDATA4
816+
let script = Script::from_bytes(&[0x4e, 0x02, 0x00, 0x00, 0x00, 0x56, 0x78]);
817+
assert_eq!(format!("{}", script), "OP_PUSHDATA4 5678");
818+
}
819+
805820
#[test]
806821
fn scriptbuf_display() {
807822
let script_buf = ScriptBuf::from(vec![0x00, 0xa1, 0xb2]);

0 commit comments

Comments
 (0)