Add test for previous commit

If this test is added before the previous commit it will fail. It passes
now demonstrating the bug got fixed.
This commit is contained in:
Martin Habovstiak 2022-12-22 23:49:37 +01:00
parent a7f3458c27
commit 920599da94
1 changed files with 44 additions and 0 deletions

View File

@ -2594,6 +2594,50 @@ mod test {
assert!(instructions.next().is_none());
}
#[test]
fn script_extend() {
fn cmp_scripts(new_script: &Script, orig_script: &[Instruction<'_>]) {
let mut new_instr = new_script.instructions();
let mut orig_instr = orig_script.iter().cloned();
for (new, orig) in new_instr.by_ref().zip(orig_instr.by_ref()) {
assert_eq!(new.unwrap(), orig);
}
assert!(new_instr.next().is_none() && orig_instr.next().is_none())
}
let script_5_items = [
Instruction::Op(OP_DUP),
Instruction::Op(OP_HASH160),
Instruction::PushBytes(&[42; 20]),
Instruction::Op(OP_EQUALVERIFY),
Instruction::Op(OP_CHECKSIG),
];
let new_script = script_5_items.iter().cloned().collect::<ScriptBuf>();
cmp_scripts(&new_script, &script_5_items);
let script_6_items = [
Instruction::Op(OP_DUP),
Instruction::Op(OP_HASH160),
Instruction::PushBytes(&[42; 20]),
Instruction::Op(OP_EQUALVERIFY),
Instruction::Op(OP_CHECKSIG),
Instruction::Op(OP_NOP),
];
let new_script = script_6_items.iter().cloned().collect::<ScriptBuf>();
cmp_scripts(&new_script, &script_6_items);
let script_7_items = [
Instruction::Op(OP_DUP),
Instruction::Op(OP_HASH160),
Instruction::PushBytes(&[42; 20]),
Instruction::Op(OP_EQUALVERIFY),
Instruction::Op(OP_CHECKSIG),
Instruction::Op(OP_NOP),
];
let new_script = script_7_items.iter().cloned().collect::<ScriptBuf>();
cmp_scripts(&new_script, &script_7_items);
}
#[test]
fn read_scriptbool_zero_is_false() {
let v: Vec<u8> = vec![0x00, 0x00, 0x00, 0x00];