Add tests ensuring stacks can be converted back to ASM
This commit is contained in:
parent
8552867695
commit
d0b4f0adf7
1 changed files with 8 additions and 6 deletions
|
@ -45,13 +45,15 @@ describe('script', function () {
|
||||||
fixtures.valid.forEach(function (f) {
|
fixtures.valid.forEach(function (f) {
|
||||||
it('returns ' + !!f.stack + ' for ' + f.asm, function () {
|
it('returns ' + !!f.stack + ' for ' + f.asm, function () {
|
||||||
var script = bscript.fromASM(f.asm)
|
var script = bscript.fromASM(f.asm)
|
||||||
var chunks = bscript.decompile(script)
|
|
||||||
|
|
||||||
try {
|
if (f.stack && f.asm) {
|
||||||
var stack = bscript.toStack(chunks).map(function (x) { return x.toString('hex') })
|
try {
|
||||||
assert.deepEqual(stack, f.stack)
|
var stack = bscript.toStack(script)
|
||||||
} catch (e) {
|
assert.deepEqual(stack.map(function (x) { return x.toString('hex') }), f.stack)
|
||||||
assert.strictEqual(f.stack, undefined)
|
assert.equal(bscript.toASM(bscript.compile(stack)), f.asm, 'should rebuild same script from stack')
|
||||||
|
} catch (e) {
|
||||||
|
assert.strictEqual(f.stack, undefined)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue