tests: add example non-standard scripthash
This commit is contained in:
parent
b6622b4cff
commit
4333217bdd
2 changed files with 30 additions and 10 deletions
6
test/fixtures/scripts.json
vendored
6
test/fixtures/scripts.json
vendored
|
@ -98,6 +98,12 @@
|
|||
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
||||
"redeemScriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801",
|
||||
"scriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae"
|
||||
},
|
||||
{
|
||||
"type": "scripthash",
|
||||
"redeemScript": "OP_0",
|
||||
"redeemScriptSig": "OP_0",
|
||||
"scriptSigHex": "000100"
|
||||
}
|
||||
],
|
||||
"invalid": {
|
||||
|
|
|
@ -64,9 +64,15 @@ describe('Scripts', function () {
|
|||
var expected = type.toLowerCase() === f.type
|
||||
|
||||
if (inputFn && f.scriptSig) {
|
||||
it('returns ' + expected + ' for ' + f.scriptSig, function () {
|
||||
var script = Script.fromASM(f.scriptSig)
|
||||
var script
|
||||
|
||||
if (f.scriptSig) {
|
||||
script = Script.fromASM(f.scriptSig)
|
||||
} else {
|
||||
script = Script.fromHex(f.scriptSigHex)
|
||||
}
|
||||
|
||||
it('returns ' + expected + ' for ' + f.scriptSig, function () {
|
||||
assert.equal(inputFn(script), expected)
|
||||
})
|
||||
|
||||
|
@ -74,8 +80,6 @@ describe('Scripts', function () {
|
|||
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)
|
||||
})
|
||||
}
|
||||
|
@ -85,9 +89,15 @@ describe('Scripts', function () {
|
|||
if (!(inputFnName in fixtures.invalid)) return
|
||||
|
||||
fixtures.invalid[inputFnName].forEach(function (f) {
|
||||
if (inputFn && f.scriptSig) {
|
||||
it('returns false for ' + f.description + ' (' + f.scriptSig + ')', function () {
|
||||
var script = Script.fromASM(f.scriptSig)
|
||||
if (inputFn && (f.scriptSig || f.scriptSigHex)) {
|
||||
it('returns false for ' + f.description + ' (' + (f.scriptSig || f.scriptSigHex) + ')', function () {
|
||||
var script
|
||||
|
||||
if (f.scriptSig) {
|
||||
script = Script.fromASM(f.scriptSig)
|
||||
} else {
|
||||
script = Script.fromHex(f.scriptSigHex)
|
||||
}
|
||||
|
||||
assert.equal(inputFn(script), false)
|
||||
})
|
||||
|
@ -240,7 +250,11 @@ describe('Scripts', function () {
|
|||
it('returns ' + f.scriptSig, function () {
|
||||
var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript)
|
||||
|
||||
assert.equal(scriptSig.toASM(), f.scriptSig)
|
||||
if (f.scriptSig) {
|
||||
assert.equal(scriptSig.toASM(), f.scriptSig)
|
||||
} else {
|
||||
assert.equal(scriptSig.toHex(), f.scriptSigHex)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -248,10 +262,10 @@ describe('Scripts', function () {
|
|||
describe('scriptHashOutput', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
if (f.type !== 'scripthash') return
|
||||
|
||||
var redeemScript = Script.fromASM(f.redeemScript)
|
||||
if (!f.scriptPubKey) return
|
||||
|
||||
it('returns ' + f.scriptPubKey, function () {
|
||||
var redeemScript = Script.fromASM(f.redeemScript)
|
||||
var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash())
|
||||
|
||||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey)
|
||||
|
|
Loading…
Add table
Reference in a new issue