Skip to content

Commit

Permalink
fix(dictionary): 🐛 move element in a table of schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored and jaromil committed Jul 20, 2023
1 parent 8ce5974 commit d8f8f60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lua/zencode_dictionary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ local function move_or_copy_in(src_value, src_name, dest)
local d = have(dest)
if luatype(d) ~= 'table' then error("Object is not a table: "..dest, 2) end
local cdest = ZEN.CODEC[dest]
if cdest.schema then
if cdest.zentype == 'e' and cdest.schema then
local sdest = ZEN.schemas[cdest.schema]
if luatype(sdest) ~= 'table' then -- old schema types are not open
error("Schema is not open to accept extra objects: "..dest)
Expand Down
22 changes: 22 additions & 0 deletions test/zencode/dictionary.bats
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,25 @@ EOF
run $ZENROOM_EXECUTABLE -z -a fail_move.data fail_move.zen
assert_line --partial 'Schema is not open to accept extra objects: ecdh_signature'
}

@test "move element in an array of schemas" {
cat << EOF | save_asset move_in_array_of_schemas.data
{
"ethereum signature": "0xed8f36c71989f8660e8f5d4adbfd8f1c0288cca90d3a5330b7bf735d71ab52fe7ba0a7827dc4ba707431f1c10babd389f658f8e208b89390a9be3c097579a2ff1b"
}
EOF

cat << EOF | zexe move_in_array_of_schemas.zen move_in_array_of_schemas.data
Scenario 'ethereum': insert signature in an array
Given I have a 'ethereum signature'
When I create the 'ethereum signature array' named 'signatures'
When I move 'ethereum signature' in 'signatures'
Then print the 'signatures'
EOF
save_output 'move_in_array_of_schemas.json'
assert_output '{"signatures":["0xed8f36c71989f8660e8f5d4adbfd8f1c0288cca90d3a5330b7bf735d71ab52fe7ba0a7827dc4ba707431f1c10babd389f658f8e208b89390a9be3c097579a2ff1b"]}'
}

0 comments on commit d8f8f60

Please sign in to comment.