@@ -190,25 +190,23 @@ describe('Bitcoin-core', function () {
190190 // reverse because test data is big-endian
191191 var expectedHash = bufferutils . reverse ( new Buffer ( f [ 4 ] , 'hex' ) )
192192
193- it ( 'should hash ' + txHex + ' correctly' , function ( ) {
193+ var hashTypes = [ ]
194+ if ( ( hashType & 0x1f ) === Transaction . SIGHASH_NONE ) hashTypes . push ( 'SIGHASH_NONE' )
195+ else if ( ( hashType & 0x1f ) === Transaction . SIGHASH_SINGLE ) hashTypes . push ( 'SIGHASH_SINGLE' )
196+ else hashTypes . push ( 'SIGHASH_ALL' )
197+ if ( hashType & Transaction . SIGHASH_ANYONECANPAY ) hashTypes . push ( 'SIGHASH_ANYONECANPAY' )
198+
199+ var hashTypeName = hashTypes . join ( ' | ' )
200+
201+ it ( 'should hash ' + txHex . slice ( 0 , 40 ) + '... (' + hashTypeName + ')' , function ( ) {
194202 var transaction = Transaction . fromHex ( txHex )
195203 assert . equal ( transaction . toHex ( ) , txHex )
196204
197205 var script = Script . fromHex ( scriptHex )
198206 assert . equal ( script . toHex ( ) , scriptHex )
199207
200- var actualHash
201- try {
202- actualHash = transaction . hashForSignature ( inIndex , script , hashType )
203- } catch ( e ) {
204- // don't fail if we don't support it yet, TODO
205- if ( ! e . message . match ( / n o t y e t s u p p o r t e d / ) )
206- throw e
207- }
208-
209- if ( actualHash !== undefined ) {
210- assert . deepEqual ( actualHash , expectedHash )
211- }
208+ var hash = transaction . hashForSignature ( inIndex , script , hashType )
209+ assert . deepEqual ( hash , expectedHash )
212210 } )
213211 } )
214212 } )
0 commit comments