[tarantool-patches] Re: [PATCH v2 2/4] msgpack: make msgpackffi use encode_max_depth option

Alexander Turenko alexander.turenko at tarantool.org
Fri Sep 13 02:24:06 MSK 2019


LGTM.

One small comment about the test case, see below.

WBR, Alexander Turenko.

> +    --
> +    -- gh-4434: msgpackffi does not care about msgpack serializer
> +    -- configuration, but it should.
> +    --
> +    local function check_depth(depth_to_try)
> +        local t = nil
> +        for i = 1, depth_to_try do t = {t} end
> +        t = s.decode_unchecked(s.encode(t))
> +        local level = 0
> +        while t ~= nil do level = level + 1 t = t[1] end
> +        return level
> +    end
> +    local msgpack = require('msgpack')
> +    local max_depth = msgpack.cfg.encode_max_depth
> +    local result_depth = check_depth(max_depth + 5)
> +    test:is(result_depth, max_depth,
> +            "msgpackffi uses msgpack.cfg.encode_max_depth")
> +
> +    msgpack.cfg({encode_max_depth = max_depth + 5})
> +    result_depth = check_depth(max_depth + 5)
> +    test:is(result_depth, max_depth + 5, "and uses it dynamically")
> +
> +    msgpack.cfg({encode_max_depth = max_depth})

Just in case: we recently close an [issue][1] when json module handles
max depth correctly for maps, but non-correctly for arrays. I think it
worth to ensure that those cases works good both for msgpackffi too.

[1]: https://github.com/tarantool/tarantool/issues/4366




More information about the Tarantool-patches mailing list