Commit b9d0e93e authored by Jaromil's avatar Jaromil
Browse files

zencode append works with numbers and strings

also minor cleanups
parent 39e40c84
......@@ -259,8 +259,6 @@ When("take '' from path ''", function(target, path)
take_out_f(root,parr,uscore(target))
end)
When("move '' out of ''", function(name, dict) take_out_f(dict, name, name) end)
When("move '' from '' to ''", function(name, src, dst)
local dest = have(dst)
local source = have(src)
......
......@@ -64,17 +64,16 @@ When("append '' to ''", function(src, dest)
local dst = have(dest)
-- if the destination is a number, fix the encoding to string
if luatype(dst) == 'number' then
dst = tostring(dst)
dst = O.from_string( tostring(dst) )
ZEN.CODEC[dest].encoding = "string"
ZEN.CODEC[dest].luatype = "string"
ZEN.CODEC[dest].zentype = "element"
end
if luatype(val) == 'number' then
val = O.from_string( tostring(val) )
end
dst = dst .. val
if luatype(dst) == 'string' then
ACK[dest] = O.from_string(dst)
else
ACK[dest] = dst
end
ACK[dest] = dst
end)
When("create the ''", function(dest)
......
......@@ -48,6 +48,7 @@ When I move 'timestamp' from 'result' to 'newblock'
Then print the 'newblock'
EOF
cat << EOF | zexe newheads_message.zen -a newblock.json | save zenswarm mpack.json
Given I have a 'hex dictionary' named 'newblock'
When I create the mpack of 'newblock'
......@@ -57,13 +58,13 @@ EOF
cat << EOF | zexe newblock_unpack.zen -a newblock.json -k mpack.json
Given I have a 'base64' named 'mpack'
and I have a 'hex dictionary' named 'newblock'
and debug
When I create the 'decoded' decoded from mpack 'mpack'
and I verify 'decoded' is equal to 'newblock'
Then print the string 'MPACK SUCCESS'
EOF
# TODO: ZPACK
cat << EOF | zexe zpack.zen -a newblock.json | save zenswarm zpack.json
Given I have a 'hex dictionary' named 'newblock'
When I create the zpack of 'newblock'
......@@ -76,7 +77,7 @@ and I have a 'hex dictionary' named 'newblock'
When I create the 'decoded' decoded from zpack 'zpack'
and debug
and I verify 'decoded' is equal to 'newblock'
Then print the string 'MPACK SUCCESS'
Then print the string 'ZPACK SUCCESS'
EOF
......
#!/usr/bin/env bash
DEBUG=1
####################
# common script init
if ! test -r ../utils.sh; then
echo "run executable from its own directory: $0"; exit 1; fi
# DEBUG=1
. ../utils.sh
is_cortexm=false
if [[ "$1" == "cortexm" ]]; then
is_cortexm=true
fi
Z="`detect_zenroom_path` `detect_zenroom_conf`"
####################
set -e
cat <<EOF | zexe copy_random.zen
Given nothing
......@@ -37,3 +24,19 @@ When I copy 'my hex' to 'dest'
Then print 'my hex'
Then print 'dest'
EOF
cat <<EOF | save when stringnum.json
{
"api": "http://3.68.108.18/api/v1/blocks/latest",
"path": "blocks/",
"height": 102
}
EOF
cat <<EOF | zexe append_number.zen -a stringnum.json
Given I have a 'string' named 'api'
and a 'string' named 'path'
and a 'number' named 'height'
When I append 'height' to 'path'
Then print 'path'
EOF
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment