public byte[] toByteArray() {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        try {
            write(stream);
        } catch (IOException e) {
            // Should not happen as ByteArrayOutputStream does not throw IOException on write
            throw new RuntimeException(e);
        }
        return stream.toByteArray();
    }
@Test
    public void testToByteArray_smallNum() {
        byte[] expected = new byte[] { OP_0 };
        byte[] actual = new ScriptChunk(OP_0, null).toByteArray();
        assertArrayEquals(expected, actual);
    }