@@ -146,13 +146,19 @@ describe('script-templates', function () {
146146
147147 var signature = Buffer . from ( f . signature , 'hex' )
148148 var input = bscript . pubKey . input . encode ( signature )
149+ var inputStack = bscript . pubKey . input . encodeStack ( signature )
149150
150151 it ( 'encodes to ' + f . input , function ( ) {
151152 assert . strictEqual ( bscript . toASM ( input ) , f . input )
153+ assert . strictEqual ( bscript . toASM ( inputStack ) , f . input )
152154 } )
153155
154156 it ( 'decodes to ' + f . signature , function ( ) {
155- assert . deepEqual ( bscript . pubKey . input . decode ( input ) , signature )
157+ var unpack = bscript . pubKey . input . decode ( input )
158+ assert . deepEqual ( unpack , signature )
159+
160+ unpack = bscript . pubKey . input . decodeStack ( inputStack )
161+ assert . deepEqual ( unpack , signature )
156162 } )
157163 } )
158164 } )
@@ -181,13 +187,22 @@ describe('script-templates', function () {
181187 var pubKey = Buffer . from ( f . pubKey , 'hex' )
182188 var signature = Buffer . from ( f . signature , 'hex' )
183189 var input = bscript . pubKeyHash . input . encode ( signature , pubKey )
190+ var inputStack = bscript . pubKeyHash . input . encodeStack ( signature , pubKey )
184191
185192 it ( 'encodes to ' + f . input , function ( ) {
186193 assert . strictEqual ( bscript . toASM ( input ) , f . input )
194+ assert . strictEqual ( bscript . toASM ( inputStack ) , f . input )
187195 } )
188196
189197 it ( 'decodes to original arguments' , function ( ) {
190- assert . deepEqual ( bscript . pubKeyHash . input . decode ( input ) , {
198+ var unpack = bscript . pubKeyHash . input . decode ( input )
199+ assert . deepEqual ( unpack , {
200+ signature : signature ,
201+ pubKey : pubKey
202+ } )
203+
204+ unpack = bscript . pubKeyHash . input . decodeStack ( inputStack )
205+ assert . deepEqual ( unpack , {
191206 signature : signature ,
192207 pubKey : pubKey
193208 } )
@@ -234,13 +249,16 @@ describe('script-templates', function () {
234249 } )
235250
236251 var input = bscript . multisig . input . encode ( signatures )
252+ var inputStack = bscript . multisig . input . encodeStack ( signatures )
237253
238254 it ( 'encodes to ' + f . input , function ( ) {
239255 assert . strictEqual ( bscript . toASM ( input ) , f . input )
256+ assert . strictEqual ( bscript . toASM ( inputStack ) , f . input )
240257 } )
241258
242259 it ( 'decodes to ' + signatures . map ( function ( x ) { return x === ops . OP_0 ? 'OP_0' : x . toString ( 'hex' ) } ) , function ( ) {
243260 assert . deepEqual ( bscript . multisig . input . decode ( input , allowIncomplete ) , signatures )
261+ assert . deepEqual ( bscript . multisig . input . decodeStack ( inputStack , allowIncomplete ) , signatures )
244262 } )
245263 } )
246264
@@ -302,8 +320,9 @@ describe('script-templates', function () {
302320 var redeemScript = bscript . fromASM ( f . redeemScript )
303321 var redeemScriptSig = bscript . fromASM ( f . redeemScriptSig )
304322 var input = bscript . scriptHash . input . encode ( redeemScriptSig , redeemScript )
323+ var inputStack = bscript . scriptHash . input . encodeStack ( redeemScriptSig , redeemScript )
305324
306- it ( 'encodes to ' + f . output , function ( ) {
325+ it ( 'encodes to ' + f . input , function ( ) {
307326 if ( f . input ) {
308327 assert . strictEqual ( bscript . toASM ( input ) , f . input )
309328 } else {
@@ -316,6 +335,11 @@ describe('script-templates', function () {
316335 redeemScriptSig : redeemScriptSig ,
317336 redeemScript : redeemScript
318337 } )
338+
339+ assert . deepEqual ( bscript . scriptHash . input . decodeStack ( inputStack ) , {
340+ redeemScriptSig : redeemScriptSig ,
341+ redeemScript : redeemScript
342+ } )
319343 } )
320344 } )
321345 } )
0 commit comments