Script: use fromChunks internally for all Script templates

This commit is contained in:
Daniel Cousens 2014-06-12 12:54:13 +10:00
parent 9a72c7437b
commit 4e04eea436
2 changed files with 95 additions and 145 deletions

View file

@ -14,16 +14,17 @@ function h2b(h) { return new Buffer(h, 'hex') }
describe('Script', function() {
describe('constructor', function() {
it('works for a byte array', function() {
assert.ok(new Script([]))
})
it('accepts valid parameters', function() {
var buffer = new Buffer([1])
var chunks = [1]
var script = new Script(buffer, chunks)
it('works when nothing is passed in', function() {
assert.ok(new Script())
assert.equal(script.buffer, buffer)
assert.equal(script.chunks, chunks)
})
it('throws an error when input is not an array', function() {
assert.throws(function(){ new Script({}) }, /Expected Array, got/)
assert.throws(function(){ new Script({}) }, /Expected Buffer, got/)
})
})