Skip to content

Commit d0b4f0a

Browse files
afk11dcousens
authored andcommitted
Add tests ensuring stacks can be converted back to ASM
1 parent 8552867 commit d0b4f0a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/script.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ describe('script', function () {
4545
fixtures.valid.forEach(function (f) {
4646
it('returns ' + !!f.stack + ' for ' + f.asm, function () {
4747
var script = bscript.fromASM(f.asm)
48-
var chunks = bscript.decompile(script)
4948

50-
try {
51-
var stack = bscript.toStack(chunks).map(function (x) { return x.toString('hex') })
52-
assert.deepEqual(stack, f.stack)
53-
} catch (e) {
54-
assert.strictEqual(f.stack, undefined)
49+
if (f.stack && f.asm) {
50+
try {
51+
var stack = bscript.toStack(script)
52+
assert.deepEqual(stack.map(function (x) { return x.toString('hex') }), f.stack)
53+
assert.equal(bscript.toASM(bscript.compile(stack)), f.asm, 'should rebuild same script from stack')
54+
} catch (e) {
55+
assert.strictEqual(f.stack, undefined)
56+
}
5557
}
5658
})
5759
})

0 commit comments

Comments
 (0)