@@ -24,12 +24,13 @@ fn test_single_byte_opcodes() {
2424 ( opcode:: NOP , Instruction :: Nop ) ,
2525 ( opcode:: NOT , Instruction :: Not ) ,
2626 ( opcode:: EQ , Instruction :: Eq ) ,
27- ( opcode:: JMP , Instruction :: Jmp ) ,
2827 ( opcode:: POP , Instruction :: Pop ) ,
2928 ( opcode:: DUP , Instruction :: Dup ) ,
3029 ( opcode:: SWAP , Instruction :: Swap ) ,
31- ( opcode:: BLAKE256 , Instruction :: Blake256 ) ,
3230 ( opcode:: CHKSIG , Instruction :: ChkSig ) ,
31+ ( opcode:: BLAKE256 , Instruction :: Blake256 ) ,
32+ ( opcode:: SHA256 , Instruction :: Sha256 ) ,
33+ ( opcode:: RIPEMD160 , Instruction :: Ripemd160 ) ,
3334 ] ;
3435 for & ( ref byte, ref code) in target. into_iter ( ) {
3536 let script = decode ( & [ byte. clone ( ) , byte. clone ( ) , byte. clone ( ) ] ) ;
@@ -43,6 +44,36 @@ fn push() {
4344 assert_eq ! ( decode( & [ opcode:: PUSH , 0 , opcode:: PUSH ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
4445}
4546
47+ #[ test]
48+ fn copy ( ) {
49+ assert_eq ! ( decode( & [ opcode:: COPY , 0 , opcode:: COPY , 10 ] ) , Ok ( vec![ Instruction :: Copy ( 0 ) , Instruction :: Copy ( 10 ) ] ) ) ;
50+ assert_eq ! ( decode( & [ opcode:: COPY , 0 , opcode:: COPY ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
51+ }
52+
53+ #[ test]
54+ fn drop ( ) {
55+ assert_eq ! ( decode( & [ opcode:: DROP , 0 , opcode:: DROP , 10 ] ) , Ok ( vec![ Instruction :: Drop ( 0 ) , Instruction :: Drop ( 10 ) ] ) ) ;
56+ assert_eq ! ( decode( & [ opcode:: DROP , 0 , opcode:: DROP ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
57+ }
58+
59+ #[ test]
60+ fn jmp ( ) {
61+ assert_eq ! ( decode( & [ opcode:: JMP , 0 , opcode:: JMP , 10 ] ) , Ok ( vec![ Instruction :: Jmp ( 0 ) , Instruction :: Jmp ( 10 ) ] ) ) ;
62+ assert_eq ! ( decode( & [ opcode:: JMP , 0 , opcode:: JMP ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
63+ }
64+
65+ #[ test]
66+ fn jnz ( ) {
67+ assert_eq ! ( decode( & [ opcode:: JNZ , 0 , opcode:: JNZ , 10 ] ) , Ok ( vec![ Instruction :: Jnz ( 0 ) , Instruction :: Jnz ( 10 ) ] ) ) ;
68+ assert_eq ! ( decode( & [ opcode:: JNZ , 0 , opcode:: JNZ ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
69+ }
70+
71+ #[ test]
72+ fn jz ( ) {
73+ assert_eq ! ( decode( & [ opcode:: JZ , 0 , opcode:: JZ , 10 ] ) , Ok ( vec![ Instruction :: Jz ( 0 ) , Instruction :: Jz ( 10 ) ] ) ) ;
74+ assert_eq ! ( decode( & [ opcode:: JZ , 0 , opcode:: JZ ] ) , Err ( DecoderError :: ScriptTooShort ) ) ;
75+ }
76+
4677#[ test]
4778fn pushb ( ) {
4879 let blobs: Vec < & [ u8 ] > = vec ! [ & [ 0xed , 0x11 , 0xe7 ] , & [ 0x8b , 0x0c , 0x92 , 0x24 , 0x3f ] ] ;
0 commit comments