scripts: break tests down from type structure
This commit is contained in:
parent
d93623e2b1
commit
62b6a407a6
2 changed files with 59 additions and 54 deletions
97
test/fixtures/scripts.json
vendored
97
test/fixtures/scripts.json
vendored
|
@ -1,54 +1,51 @@
|
|||
{
|
||||
"valid": {
|
||||
"pubKey": [
|
||||
{
|
||||
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"scriptPubKey": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac",
|
||||
"scriptSig": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
|
||||
}
|
||||
],
|
||||
"pubKeyHash": [
|
||||
{
|
||||
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"scriptPubKey": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac",
|
||||
"scriptSig": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1"
|
||||
}
|
||||
],
|
||||
"multisig": [
|
||||
{
|
||||
"pubKeys": [
|
||||
"02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a"
|
||||
],
|
||||
"signatures": [
|
||||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
|
||||
],
|
||||
"scriptPubKey": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"scriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
|
||||
},
|
||||
{
|
||||
"pubKeys": [
|
||||
"02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f",
|
||||
"02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f",
|
||||
"036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19"
|
||||
],
|
||||
"signatures": [],
|
||||
"scriptPubKey": "532102ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f2102fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f21036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e1953ae",
|
||||
"scriptSig": ""
|
||||
}
|
||||
],
|
||||
"scripthash": [
|
||||
{
|
||||
"redeemScript": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"redeemScriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501",
|
||||
"scriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"scriptPubKey": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87"
|
||||
}
|
||||
]
|
||||
},
|
||||
"valid": [
|
||||
{
|
||||
"type": "pubkey",
|
||||
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"scriptPubKey": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac",
|
||||
"scriptSig": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
|
||||
},
|
||||
{
|
||||
"type": "pubkeyhash",
|
||||
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"scriptPubKey": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac",
|
||||
"scriptSig": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1"
|
||||
},
|
||||
{
|
||||
"type": "multisig",
|
||||
"pubKeys": [
|
||||
"02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
|
||||
"0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a"
|
||||
],
|
||||
"signatures": [
|
||||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
|
||||
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
|
||||
],
|
||||
"scriptPubKey": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"scriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
|
||||
},
|
||||
{
|
||||
"type": "multisig",
|
||||
"pubKeys": [
|
||||
"02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f",
|
||||
"02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f",
|
||||
"036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19"
|
||||
],
|
||||
"signatures": [],
|
||||
"scriptPubKey": "532102ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f2102fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f21036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e1953ae",
|
||||
"scriptSig": ""
|
||||
},
|
||||
{
|
||||
"type": "scripthash",
|
||||
"redeemScript": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"redeemScriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501",
|
||||
"scriptSig": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
|
||||
"scriptPubKey": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87"
|
||||
}
|
||||
],
|
||||
"invalid": {
|
||||
"multisig": [
|
||||
{
|
||||
|
|
|
@ -36,7 +36,9 @@ describe('Scripts', function() {
|
|||
})
|
||||
|
||||
describe('pubKey', function() {
|
||||
fixtures2.valid.pubKey.forEach(function(f) {
|
||||
fixtures2.valid.forEach(function(f) {
|
||||
if (f.type !== 'pubkey') return
|
||||
|
||||
describe('input script', function() {
|
||||
it('is generated correctly for ' + f.pubKey, function() {
|
||||
var signature = new Buffer(f.signature, 'hex')
|
||||
|
@ -58,7 +60,9 @@ describe('Scripts', function() {
|
|||
})
|
||||
|
||||
describe('pubKeyHash', function() {
|
||||
fixtures2.valid.pubKeyHash.forEach(function(f) {
|
||||
fixtures2.valid.forEach(function(f) {
|
||||
if (f.type !== 'pubkeyhash') return
|
||||
|
||||
var pubKey = ECPubKey.fromHex(f.pubKey)
|
||||
var address = pubKey.getAddress()
|
||||
|
||||
|
@ -81,7 +85,9 @@ describe('Scripts', function() {
|
|||
})
|
||||
|
||||
describe('multisig', function() {
|
||||
fixtures2.valid.multisig.forEach(function(f) {
|
||||
fixtures2.valid.forEach(function(f) {
|
||||
if (f.type !== 'multisig') return
|
||||
|
||||
var pubKeys = f.pubKeys.map(ECPubKey.fromHex)
|
||||
var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys)
|
||||
|
||||
|
@ -135,7 +141,9 @@ describe('Scripts', function() {
|
|||
})
|
||||
|
||||
describe('scripthash', function() {
|
||||
fixtures2.valid.scripthash.forEach(function(f) {
|
||||
fixtures2.valid.forEach(function(f) {
|
||||
if (f.type !== 'scripthash') return
|
||||
|
||||
var redeemScript = Script.fromHex(f.redeemScript)
|
||||
var redeemScriptSig = Script.fromHex(f.redeemScriptSig)
|
||||
|
||||
|
|
Loading…
Reference in a new issue