testing/p2wsh: add missing test case coverage
This commit is contained in:
parent
275b872c7e
commit
14d9636b6e
4 changed files with 51 additions and 6 deletions
|
@ -119,9 +119,9 @@ function p2wsh (a, opts) {
|
|||
if (opts.validate) {
|
||||
let hash
|
||||
if (a.address) {
|
||||
if (_address().prefix !== network.bech32) throw new TypeError('Network mismatch')
|
||||
if (_address().version !== 0x00) throw new TypeError('Invalid version')
|
||||
if (_address().data.length !== 32) throw new TypeError('Invalid data')
|
||||
if (_address().prefix !== network.bech32) throw new TypeError('Invalid prefix or Network mismatch')
|
||||
if (_address().version !== 0x00) throw new TypeError('Invalid address version')
|
||||
if (_address().data.length !== 32) throw new TypeError('Invalid address data')
|
||||
else hash = _address().data
|
||||
}
|
||||
|
||||
|
|
10
test/fixtures/p2wpkh.json
vendored
10
test/fixtures/p2wpkh.json
vendored
|
@ -119,13 +119,19 @@
|
|||
{
|
||||
"exception": "Invalid prefix or Network mismatch",
|
||||
"arguments": {
|
||||
"address": "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7"
|
||||
"address": "foo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqs30dvv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Invalid address version",
|
||||
"arguments": {
|
||||
"address": "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx"
|
||||
"address": "bc1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq5us4ke"
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Invalid address data",
|
||||
"arguments": {
|
||||
"address": "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
39
test/fixtures/p2wsh.json
vendored
39
test/fixtures/p2wsh.json
vendored
|
@ -268,6 +268,45 @@
|
|||
"02ffff"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Ambiguous witness source",
|
||||
"arguments": {
|
||||
"redeem": {
|
||||
"output": "OP_TRUE",
|
||||
"input": "01",
|
||||
"witness": [
|
||||
"01"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Network mismatch",
|
||||
"arguments": {
|
||||
"network": "bitcoin",
|
||||
"redeem": {
|
||||
"network": "testnet"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Invalid prefix or Network mismatch",
|
||||
"arguments": {
|
||||
"address": "foo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqs30dvv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Invalid address version",
|
||||
"arguments": {
|
||||
"address": "bc1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq5us4ke"
|
||||
}
|
||||
},
|
||||
{
|
||||
"exception": "Invalid address data",
|
||||
"arguments": {
|
||||
"address": "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8"
|
||||
}
|
||||
}
|
||||
],
|
||||
"dynamic": {
|
||||
|
|
|
@ -99,7 +99,7 @@ function preform (x) {
|
|||
if (typeof x.redeem.input === 'string') x.redeem.input = asmToBuffer(x.redeem.input)
|
||||
if (typeof x.redeem.output === 'string') x.redeem.output = asmToBuffer(x.redeem.output)
|
||||
if (Array.isArray(x.redeem.witness)) x.redeem.witness = x.redeem.witness.map(fromHex)
|
||||
x.redeem.network = bnetworks[x.redeem.network] || x.network || bnetworks.bitcoin
|
||||
if (x.redeem.network) x.redeem.network = bnetworks[x.redeem.network]
|
||||
}
|
||||
|
||||
return x
|
||||
|
|
Loading…
Add table
Reference in a new issue