From e3ae3f3fb070a6cc39ddda76d55d237e5ada863d Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Mon, 16 Oct 2023 18:12:05 +0200 Subject: [PATCH] =?UTF-8?q?fix(table):=20=F0=9F=90=9B=20codec=20when=20cop?= =?UTF-8?q?ying=20last=20schema=20from=20a=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/zencode_table.lua | 9 +++++++-- test/zencode/array.bats | 32 ++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/lua/zencode_table.lua b/src/lua/zencode_table.lua index 0272e5b38..375d5ffcc 100644 --- a/src/lua/zencode_table.lua +++ b/src/lua/zencode_table.lua @@ -259,6 +259,11 @@ When("create the copy of last element in ''", function(obj_name) else error("Cannot find last element in " .. obj_codec.zentype) end - -- TODO: fix codec when copying from table of schemas - new_codec('copy_of_last_element', {encoding = obj_codec.encoding}) + local n_codec = {encoding = obj_codec.encoding} + -- if copying from table of schema + if obj_codec.schema then + n_codec.schema = obj_codec.schema + n_codec.zentype = "e" + end + new_codec('copy_of_last_element', n_codec) end) diff --git a/test/zencode/array.bats b/test/zencode/array.bats index a82a0c845..2f0c40607 100755 --- a/test/zencode/array.bats +++ b/test/zencode/array.bats @@ -907,23 +907,47 @@ EOF "smalldict": { "key": "val", "foo": "bar" - } + }, + "smallSignatures": [ + { + "r": "ed8f36c71989f8660e8f5d4adbfd8f1c0288cca90d3a5330b7bf735d71ab52fe", + "s": "7ba0a7827dc4ba707431f1c10babd389f658f8e208b89390a9be3c097579a2ff", + "v": "27" + }, + { + "r": "40d305373c648bb6b2bbadebe02ada256a9d0b3d3c37367c0a2795e367b22f73", + "s": "72e40dfc3497927764d1585783d058e4367bb4d24d2107777d7aa4ddcb6593c7", + "v": "27" + }, + { + "r": "9e07477c31db612e8c99a950385162373ff41a5b8941470b1aeba43b76c53570", + "s": "05fce6615567dc1944cc02fbed86202b09d92d79fbade425af0d74c328d8f6ae", + "v": "28" + } + ] } EOF cat <