scripts: add allowIncomplete for multisig scripts
This commit is contained in:
parent
abf870fb37
commit
c35d4b46c5
4 changed files with 118 additions and 23 deletions
test
|
@ -1,4 +1,5 @@
|
|||
var assert = require('assert')
|
||||
var ops = require('../src/opcodes')
|
||||
var scripts = require('../src/scripts')
|
||||
|
||||
var ECPubKey = require('../src/ecpubkey')
|
||||
|
@ -22,6 +23,18 @@ describe('Scripts', function() {
|
|||
assert.equal(type, f.type)
|
||||
})
|
||||
})
|
||||
|
||||
fixtures.valid.forEach(function(f) {
|
||||
if (!f.scriptSig) return
|
||||
if (!f.typeIncomplete) return
|
||||
|
||||
it('classifies incomplete ' + f.scriptSig + ' as ' + f.typeIncomplete, function() {
|
||||
var script = Script.fromASM(f.scriptSig)
|
||||
var type = scripts.classifyInput(script, true)
|
||||
|
||||
assert.equal(type, f.typeIncomplete)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('classifyOutput', function() {
|
||||
|
@ -51,6 +64,16 @@ describe('Scripts', function() {
|
|||
|
||||
assert.equal(inputFn(script), expected)
|
||||
})
|
||||
|
||||
if (f.typeIncomplete) {
|
||||
var expectedIncomplete = type.toLowerCase() === f.typeIncomplete
|
||||
|
||||
it('returns ' + expected + ' for ' + f.scriptSig, function() {
|
||||
var script = Script.fromASM(f.scriptSig)
|
||||
|
||||
assert.equal(inputFn(script, true), expectedIncomplete)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -131,7 +154,7 @@ describe('Scripts', function() {
|
|||
|
||||
it('returns ' + f.scriptSig, function() {
|
||||
var signatures = f.signatures.map(function(signature) {
|
||||
return new Buffer(signature, 'hex')
|
||||
return signature ? new Buffer(signature, 'hex') : ops.OP_0
|
||||
})
|
||||
|
||||
var scriptSig = scripts.multisigInput(signatures)
|
||||
|
@ -145,7 +168,7 @@ describe('Scripts', function() {
|
|||
|
||||
it('throws on ' + f.exception, function() {
|
||||
var signatures = f.signatures.map(function(signature) {
|
||||
return new Buffer(signature, 'hex')
|
||||
return signature ? new Buffer(signature, 'hex') : ops.OP_0
|
||||
})
|
||||
|
||||
assert.throws(function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue