Add tests ensuring stacks can be converted back to ASM

This commit is contained in:
Thomas Kerin 2016-12-15 13:04:31 +01:00 committed by Daniel Cousens
parent 8552867695
commit d0b4f0adf7

View file

@ -45,14 +45,16 @@ describe('script', function () {
fixtures.valid.forEach(function (f) {
it('returns ' + !!f.stack + ' for ' + f.asm, function () {
var script = bscript.fromASM(f.asm)
var chunks = bscript.decompile(script)
if (f.stack && f.asm) {
try {
var stack = bscript.toStack(chunks).map(function (x) { return x.toString('hex') })
assert.deepEqual(stack, f.stack)
var stack = bscript.toStack(script)
assert.deepEqual(stack.map(function (x) { return x.toString('hex') }), f.stack)
assert.equal(bscript.toASM(bscript.compile(stack)), f.asm, 'should rebuild same script from stack')
} catch (e) {
assert.strictEqual(f.stack, undefined)
}
}
})
})
})