scripts: adds tests for *HashOutput
This commit is contained in:
parent
ab1215adc1
commit
706f5d7a9c
4 changed files with 35 additions and 3 deletions
|
@ -4,7 +4,7 @@ var typeforce = require('typeforce')
|
||||||
|
|
||||||
function nBuffer (value, n) {
|
function nBuffer (value, n) {
|
||||||
if (!Buffer.isBuffer(value)) return false
|
if (!Buffer.isBuffer(value)) return false
|
||||||
if (value.length !== n) throw new Error('Expected ' + (n * 8) + '-bit Buffer, got ' + (value.length * 8) + '-bit')
|
if (value.length !== n) throw new Error('Expected ' + (n * 8) + '-bit Buffer, got ' + (value.length * 8) + '-bit Buffer')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
test/fixtures/scripts.json
vendored
12
test/fixtures/scripts.json
vendored
|
@ -265,6 +265,18 @@
|
||||||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
|
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"pubKeyHashOutput": [
|
||||||
|
{
|
||||||
|
"exception": "Expected 160-bit Buffer, got 16-bit Buffer",
|
||||||
|
"hash": "ffff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scriptHashOutput": [
|
||||||
|
{
|
||||||
|
"exception": "Expected 160-bit Buffer, got 24-bit Buffer",
|
||||||
|
"hash": "ffffff"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
test/fixtures/transaction.json
vendored
4
test/fixtures/transaction.json
vendored
|
@ -229,12 +229,12 @@
|
||||||
"invalid": {
|
"invalid": {
|
||||||
"addInput": [
|
"addInput": [
|
||||||
{
|
{
|
||||||
"exception": "Expected 256-bit Buffer, got 240-bit",
|
"exception": "Expected 256-bit Buffer, got 240-bit Buffer",
|
||||||
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816d",
|
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816d",
|
||||||
"index": 0
|
"index": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"exception": "Expected 256-bit Buffer, got 272-bit",
|
"exception": "Expected 256-bit Buffer, got 272-bit Buffer",
|
||||||
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816da9b0ffff",
|
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816da9b0ffff",
|
||||||
"index": 0
|
"index": 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,16 @@ describe('scripts', function () {
|
||||||
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
|
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fixtures.invalid.pubKeyHashOutput.forEach(function (f) {
|
||||||
|
var hash = new Buffer(f.hash, 'hex')
|
||||||
|
|
||||||
|
it('throws on ' + f.exception, function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
scripts.pubKeyHashOutput(hash)
|
||||||
|
}, new RegExp(f.exception))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('multisigInput', function () {
|
describe('multisigInput', function () {
|
||||||
|
@ -333,6 +343,16 @@ describe('scripts', function () {
|
||||||
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
|
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fixtures.invalid.scriptHashOutput.forEach(function (f) {
|
||||||
|
var hash = new Buffer(f.hash, 'hex')
|
||||||
|
|
||||||
|
it('throws on ' + f.exception, function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
scripts.scriptHashOutput(hash)
|
||||||
|
}, new RegExp(f.exception))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('nullDataOutput', function () {
|
describe('nullDataOutput', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue