@@ -33,21 +33,27 @@ describe('script', function () {
33
33
} )
34
34
} )
35
35
36
- describe ( 'compile' , function ( ) {
36
+ describe ( 'compile (via fromASM) ' , function ( ) {
37
37
fixtures . valid . forEach ( function ( f ) {
38
38
if ( f . scriptSig ) {
39
39
it ( '(' + f . type + ') compiles ' + f . scriptSig , function ( ) {
40
40
var scriptSig = bscript . fromASM ( f . scriptSig )
41
41
42
- assert . strictEqual ( bscript . compile ( scriptSig ) . toString ( 'hex' ) , f . scriptSigHex )
42
+ assert . strictEqual ( scriptSig . toString ( 'hex' ) , f . scriptSigHex )
43
+
44
+ if ( f . nonstandard ) {
45
+ var scriptSigNS = bscript . fromASM ( f . nonstandard . scriptSig )
46
+
47
+ assert . strictEqual ( scriptSigNS . toString ( 'hex' ) , f . scriptSigHex )
48
+ }
43
49
} )
44
50
}
45
51
46
52
if ( f . scriptPubKey ) {
47
53
it ( '(' + f . type + ') compiles ' + f . scriptPubKey , function ( ) {
48
54
var scriptPubKey = bscript . fromASM ( f . scriptPubKey )
49
55
50
- assert . strictEqual ( bscript . compile ( scriptPubKey ) . toString ( 'hex' ) , f . scriptPubKeyHex )
56
+ assert . strictEqual ( scriptPubKey . toString ( 'hex' ) , f . scriptPubKeyHex )
51
57
} )
52
58
}
53
59
} )
@@ -59,14 +65,25 @@ describe('script', function () {
59
65
it ( 'decompiles ' + f . scriptSig , function ( ) {
60
66
var chunks = bscript . decompile ( new Buffer ( f . scriptSigHex , 'hex' ) )
61
67
68
+ assert . strictEqual ( bscript . compile ( chunks ) . toString ( 'hex' ) , f . scriptSigHex )
62
69
assert . strictEqual ( bscript . toASM ( chunks ) , f . scriptSig )
70
+
71
+ if ( f . nonstandard ) {
72
+ var chunksNS = bscript . decompile ( new Buffer ( f . nonstandard . scriptSigHex , 'hex' ) )
73
+
74
+ assert . strictEqual ( bscript . compile ( chunksNS ) . toString ( 'hex' ) , f . scriptSigHex )
75
+
76
+ // toASM converts verbatim, only `compile` transforms the script to a minimalpush compliant script
77
+ assert . strictEqual ( bscript . toASM ( chunksNS ) , f . nonstandard . scriptSig )
78
+ }
63
79
} )
64
80
}
65
81
66
82
if ( f . scriptPubKeyHex ) {
67
83
it ( 'decompiles ' + f . scriptPubKey , function ( ) {
68
84
var chunks = bscript . decompile ( new Buffer ( f . scriptPubKeyHex , 'hex' ) )
69
85
86
+ assert . strictEqual ( bscript . compile ( chunks ) . toString ( 'hex' ) , f . scriptPubKeyHex )
70
87
assert . strictEqual ( bscript . toASM ( chunks ) , f . scriptPubKey )
71
88
} )
72
89
}
@@ -466,7 +483,7 @@ describe('script', function () {
466
483
var buffer = new Buffer ( i )
467
484
var script = bscript . compile ( [ buffer ] )
468
485
469
- assert ( minimalData ( script ) , 'Failed for ' + i + ' length script' )
486
+ assert ( minimalData ( script ) , 'Failed for ' + i + ' length script: ' + script . toString ( 'hex' ) )
470
487
} )
471
488
}
472
489
0 commit comments