@@ -47,7 +47,7 @@ describe('Bitcoin-core', function () {
4747 } )
4848
4949 // base58_keys_valid
50- describe ( 'Address' , function ( ) {
50+ describe ( 'Address.formBase58Check ' , function ( ) {
5151 var typeMap = {
5252 'pubkey' : 'pubKeyHash' ,
5353 'script' : 'scriptHash'
@@ -74,7 +74,7 @@ describe('Bitcoin-core', function () {
7474 } )
7575
7676 // base58_keys_invalid
77- describe ( 'Address' , function ( ) {
77+ describe ( 'Address.fromBase58Check ' , function ( ) {
7878 var allowedNetworks = [
7979 networks . bitcoin . pubkeyhash ,
8080 networks . bitcoin . scripthash ,
@@ -105,19 +105,19 @@ describe('Bitcoin-core', function () {
105105 if ( ! params . isPrivkey ) return
106106 var keyPair = ECPair . fromWIF ( string )
107107
108- it ( 'imports ' + string , function ( ) {
108+ it ( 'fromWIF imports ' + string , function ( ) {
109109 assert . strictEqual ( keyPair . d . toHex ( ) , hex )
110110 assert . strictEqual ( keyPair . compressed , params . isCompressed )
111111 } )
112112
113- it ( 'exports ' + hex + ' to ' + string , function ( ) {
113+ it ( 'toWIF exports ' + hex + ' to ' + string , function ( ) {
114114 assert . strictEqual ( keyPair . toWIF ( ) , string )
115115 } )
116116 } )
117117 } )
118118
119119 // base58_keys_invalid
120- describe ( 'ECPair' , function ( ) {
120+ describe ( 'ECPair.fromWIF ' , function ( ) {
121121 var allowedNetworks = [
122122 networks . bitcoin ,
123123 networks . testnet
@@ -136,9 +136,9 @@ describe('Bitcoin-core', function () {
136136 } )
137137 } )
138138
139- describe ( 'Block' , function ( ) {
139+ describe ( 'Block.fromHex ' , function ( ) {
140140 blocks_valid . forEach ( function ( f ) {
141- it ( 'fromHex can parse ' + f . id , function ( ) {
141+ it ( 'can parse ' + f . id , function ( ) {
142142 var block = Block . fromHex ( f . hex )
143143
144144 assert . strictEqual ( block . getId ( ) , f . id )
@@ -148,7 +148,7 @@ describe('Bitcoin-core', function () {
148148 } )
149149
150150 // tx_valid
151- describe ( 'Transaction' , function ( ) {
151+ describe ( 'Transaction.fromHex ' , function ( ) {
152152 tx_valid . forEach ( function ( f ) {
153153 // Objects that are only a single string are ignored
154154 if ( f . length === 1 ) return
@@ -166,7 +166,6 @@ describe('Bitcoin-core', function () {
166166 // reverse because test data is big-endian
167167 var prevOutHash = bufferutils . reverse ( new Buffer ( input [ 0 ] , 'hex' ) )
168168 var prevOutIndex = input [ 1 ]
169- // var prevOutScriptPubKey = input[2] // TODO: we don't have a ASM parser
170169
171170 assert . deepEqual ( txIn . hash , prevOutHash )
172171
@@ -177,6 +176,35 @@ describe('Bitcoin-core', function () {
177176 } )
178177 } )
179178
179+ describe ( 'Script.fromASM' , function ( ) {
180+ tx_valid . forEach ( function ( f ) {
181+ // Objects that are only a single string are ignored
182+ if ( f . length === 1 ) return
183+
184+ var inputs = f [ 0 ]
185+
186+ inputs . forEach ( function ( input ) {
187+ var prevOutScriptPubKey = input [ 2 ]
188+ . replace ( / ( ^ | ) ( [ 0 - 9 ] ) ( | $ ) / g, 'OP_$2 ' )
189+ . replace ( / 0 x [ a - f 0 - 9 ] + 0 x ( [ a - f 0 - 9 ] + ) / , '$1' )
190+ . replace ( / D U P / g, 'OP_DUP' )
191+ . replace ( / N O T / g, 'OP_NOT' )
192+ . replace ( / H A S H 1 6 0 / g, 'OP_HASH160' )
193+ . replace ( / E Q U A L V E R I F Y / g, 'OP_EQUALVERIFY' )
194+ . replace ( / E Q U A L ( | $ ) / g, 'OP_EQUAL ' )
195+ . replace ( / C H E C K S I G / g, 'OP_CHECKSIG' )
196+ . replace ( / C H E C K M U L T I S I G / g, ' OP_CHECKMULTISIG' )
197+ . replace ( / C O D E S E P A R A T O R / g, 'OP_CODESEPARATOR' )
198+ . replace ( / C H E C K S I G V E R I F Y / g, 'OP_CHECKSIGVERIFY' )
199+
200+ it ( 'can parse ' + prevOutScriptPubKey , function ( ) {
201+ // TODO: we can probably do better validation than this
202+ Script . fromASM ( prevOutScriptPubKey )
203+ } )
204+ } )
205+ } )
206+ } )
207+
180208 // sighash
181209 describe ( 'Transaction' , function ( ) {
182210 sighash . forEach ( function ( f ) {
@@ -212,7 +240,7 @@ describe('Bitcoin-core', function () {
212240 } )
213241 } )
214242
215- describe ( 'ECSignature' , function ( ) {
243+ describe ( 'ECSignature.parseScriptSignature ' , function ( ) {
216244 sig_canonical . forEach ( function ( hex ) {
217245 var buffer = new Buffer ( hex , 'hex' )
218246
0 commit comments