Browse Source

script: add fromASM failing test case and fix

hk-custom-address
Daniel Cousens 8 years ago
committed by Daniel Cousens
parent
commit
a86e905611
  1. 1
      src/script.js
  2. 6
      test/fixtures/script.json
  3. 8
      test/script.js

1
src/script.js

@ -145,6 +145,7 @@ function fromASM (asm) {
return compile(asm.split(' ').map(function (chunkStr) {
// opcode?
if (OPS[chunkStr] !== undefined) return OPS[chunkStr]
typeforce(types.Hex, chunkStr)
// data!
return new Buffer(chunkStr, 'hex')

6
test/fixtures/script.json

@ -189,6 +189,12 @@
"description": "Not enough data: OP_PUSHDATA4 0xffffffff",
"script": "4effffffff01"
}
],
"fromASM": [
{
"description": "Expected Hex, got String \"0xff\"",
"script": "0xff OP_CHECKSIG"
}
]
}
}

8
test/script.js

@ -28,6 +28,14 @@ describe('script', function () {
assert.strictEqual(bscript.toASM(scriptSig), f.asm)
})
})
fixtures.invalid.fromASM.forEach(function (f) {
it('throws ' + f.description, function () {
assert.throws(function () {
bscript.fromASM(f.script)
}, new RegExp(f.description))
})
})
})
describe('isPushOnly', function () {

Loading…
Cancel
Save