Skip to content

Commit 883d021

Browse files
committed
cover the case when some chunks are "minimalOP"
1 parent bc9b5ab commit 883d021

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/script.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ describe('script', () => {
4141
});
4242
});
4343

44+
describe('toASM', () => {
45+
const OP_RETURN = bscript.OPS.OP_RETURN;
46+
it('encodes empty buffer as OP_0', () => {
47+
const chunks = [OP_RETURN, Buffer.from([])];
48+
assert.strictEqual(bscript.toASM(chunks), 'OP_RETURN OP_0');
49+
});
50+
51+
for (let i = 1; i <= 16; i++) {
52+
it(`encodes one byte buffer [${i}] as OP_${i}`, () => {
53+
const chunks = [OP_RETURN, Buffer.from([i])];
54+
assert.strictEqual(bscript.toASM(chunks), 'OP_RETURN OP_' + i);
55+
});
56+
}
57+
});
58+
4459
describe('fromASM/toASM (templates)', () => {
4560
fixtures2.valid.forEach(f => {
4661
if (f.inputHex) {

0 commit comments

Comments
 (0)