run.sh 10.7 KB
Newer Older
1
#!/usr/bin/env bash
2

3
DEBUG=1
4
5
6
7
8
####################
# common script init
if ! test -r ../utils.sh; then
	echo "run executable from its own directory: $0"; exit 1; fi
. ../utils.sh
HYChang's avatar
HYChang committed
9
10
11
12
13
14

is_cortexm=false
if [[ "$1" == "cortexm" ]]; then
	is_cortexm=true
fi

15
16
Z="`detect_zenroom_path` `detect_zenroom_conf`"
####################
17

Danilo Spinella's avatar
Danilo Spinella committed
18
19
set -e

20
cat <<EOF | zexe array_32_256.zen > arr.json
21
rule output encoding url64
22
23
24
25
26
27
Given nothing
When I create the array of '32' random objects of '256' bits
and I rename the 'array' to 'bonnetjes'
Then print the 'bonnetjes'
EOF

Jaromil's avatar
Jaromil committed
28
29
30
31
32
33
cat << EOF | zexe array_length.zen -a arr.json
Given I have a 'url64 array' named 'bonnetjes'
When I create the length of 'bonnetjes'
Then print the 'length'
EOF

34
cat <<EOF | zexe array_rename_remove.zen -a arr.json
35
36
rule input encoding url64
rule output encoding hex
Jaromil's avatar
Jaromil committed
37
Given I have a 'url64 array' named 'bonnetjes'
Jaromil's avatar
Jaromil committed
38
When I pick the random object in 'bonnetjes'
39
and I rename the 'random object' to 'lucky one'
Jaromil's avatar
Jaromil committed
40
and I remove the 'lucky one' from 'bonnetjes'
41
# redundant check
Jaromil's avatar
Jaromil committed
42
and the 'lucky one' is not found in 'bonnetjes'
43
44
45
Then print the 'lucky one'
EOF

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# cat <<EOF | zexe array_hashtopoint.zen -a arr.json > ecp.json
# rule input encoding url64
# rule output encoding url64
# Given I have a 'array' named 'bonnetjes'
# When I create the hash to point 'ECP' of each object in 'bonnetjes'
# # When for each x in 'bonnetjes' create the of 'ECP.hashtopoint(x)'
# Then print the 'hashes'
# EOF

# cat <<EOF | zexe array_ecp_check.zen -a arr.json -k ecp.json > hashes.json
# rule input encoding url64
# rule output encoding url64
# Given I have a 'array' named 'bonnetjes'
# and I have a 'ecp array' named 'hashes'
# # When I pick the random object in array 'hashes'
# # and I remove the 'random object' from array 'hashes'
# When for each x in 'hashes' y in 'bonnetjes' is true 'x == ECP.hashtopoint(y)'
# Then print the 'hashes'
# EOF
# # 'x == ECP.hashtopoint(y)'
66
67


68
cat <<EOF | zexe left_array_from_hash.zen -a arr.json > left_arr.json
69
70
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
71
Given I have a 'url64 array' named 'bonnetjes'
72
73
When I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'left array'
74
Then print the 'left array'
75
EOF
76
77
78
79
80


cat <<EOF | zexe right_array_from_hash.zen -a arr.json > right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
81
Given I have a 'url64 array' named 'bonnetjes'
82
83
When I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'right array'
84
85
86
87
88
89
90
91
Then print the 'right array'
EOF

# comparison

cat <<EOF | zexe array_comparison.zen -a left_arr.json -k right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
92
93
Given I have a 'url64 array' named 'left array'
and I have a 'url64 array' named 'right array'
94
When I verify 'left array' is equal to 'right array'
95
Then print the string 'OK'
96
97
EOF

98
99
100
cat <<EOF | zexe array_remove_object.zen -a arr.json > right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
101
Given I have a 'url64 array' named 'bonnetjes'
102
When I pick the random object in 'bonnetjes'
103
and I remove the 'random object' from 'bonnetjes'
104
105
106
107
108
109
110
111
112
and I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'right array'
Then print the 'right array'
EOF

# verify that arrays are not equal
cat <<EOF | zexe array_not_comparison.zen -a left_arr.json -k right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
113
114
Given I have a 'url64 array' named 'left array'
and I have a 'url64 array' named 'right array'
115
When I verify 'left array' is not equal to 'right array'
116
Then print the string 'OK'
117
EOF
118
119


120
121
# 'x == ECP.hashtopoint(y)'

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cat <<EOF > nesting.json
{
  "first" : { "inside" : "first.inside" },
  "second" : { "inside" : "second.inside" },
  "third" : "three"
}
EOF

cat <<EOF | zexe pick_nested.zen -a nesting.json
rule check version 1.0.0
rule input encoding string
Given I have a 'string' named 'inside' inside 'first'
and I have a 'string' named 'third'
When I write string 'first.inside' in 'test'
and I write string 'three' in 'tertiur'
and I verify 'third' is equal to 'tertiur'
Then print the 'test' as 'string'
EOF

cat <<EOF | zexe random_from_array.zen
rule check version 1.0.0
Given nothing
When I create the array of '32' random objects of '256' bits
and I pick the random object in 'array'
146
and I remove the 'random object' from 'array'
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
and the 'random object' is not found in 'array'
Then print the 'random object'
EOF

cat <<EOF | zexe leftmost_split.zen
rule check version 1.0.0
Given nothing
When I set 'whole' to 'Zenroom works great' as 'string'
and I split the leftmost '3' bytes of 'whole'
Then print the 'leftmost' as 'string'
and print the 'whole' as 'string'
EOF

cat <<EOF | zexe random_numbers.zen | tee array_random_nums.json
Given nothing
When I create the array of '64' random numbers
Then print the 'array' as 'number'
EOF

166

167
168
169
170
171
172
173
cat <<EOF | zexe random_numbers.zen | tee array_random_nums.json
Given nothing
When I create the array of '64' random numbers modulo '100'
and I create the aggregation of array 'array'
Then print the 'array' as 'number'
and print the 'aggregation' as 'number'
EOF
Jaromil's avatar
Jaromil committed
174

175
cat <<EOF | zexe cbor.zen -a array_random_nums.json
Jaromil's avatar
Jaromil committed
176
Given I have an 'number array' named 'array'
177
178
179
180
When I create the cbor of 'array'
Then print the 'cbor' as 'hex'
and print the 'array'
EOF
181

182
183
184
185
186
187
# cat << EOF > array_public_bls.json
# { "public_keys": {
#  "Alice":{"reflow_public_key": "KrfEl2HFpml3di0N5vnrN+yrbSgiSClGBgz9zEmp2BihHOejIuOrTsOS573Fh6ciCxv6jI3syiF7mfGKUKXurUruj1kUtJfRpXHXa4d22LlioeB9uv+l14qhecrFojboOGrxZulFoDKVVWVCB0/bAD6HquSmvX4+jyPl/BLt6TUnNDLeWK8vm6zu9sR8/XFtKqEfCgQB4u0vbDhqOKhRNut8MjLtMcxYgWZTunmszNAZdAGMcYSod/0p1AzOnAUi"},
#  "Bob"  :{"reflow_public_key": "HA5WkWcTL0bJRRtjaTlW67SxTKBvuMniEOuao+jeuKA/2PT5965hvJgeDuTc2dHjGkCUzTjYhruOmY8puiF6s+8LRttJo17utYtsDNtNPNpaNdDSg8Dsg+wljGnqDUW8Jy29GQtuse2nqCOhGDzx9XC9pRCcu7hxAlIQsivpI2D9vXvi6BrVEniFG/kOrzzaUXXWNzBEuLhkwgvHcjLwC4Ph6ynrcsFIwEZycKuJKCaoOJu/ZQRT/nyfSf/Bom2k"}
# } }
# EOF
188

189
190
191
192
193
# cat <<EOF | debug array_schema.zen -a array_public_bls.json
# Scenario reflow
# Given I have a 'reflow public key array' named 'public keys'
# Then print all data
# EOF
194

Jaromil's avatar
Jaromil committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
cat << EOF > array_matches.json
{ "haystack": [ "Approved", "Not approved", "Approved", "Not approved", "Approved","Not approved", "Approved","Not approved", "Approved" ] }
EOF
cat << EOF > quorum.json
{ "quorum": 5,
  "needle": "Approved" }
EOF

cat << EOF | zexe needle_in_haystack.zen -a array_matches.json -k quorum.json
Given I have a 'string array' named 'haystack'
and I have a 'number' named 'quorum'
and I have a 'string' named 'needle'
When the 'needle' is found in 'haystack' at least 'quorum' times
Then Print the string 'Success' 
EOF

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
cat <<EOF >timestamp_stats.json
{
	"1": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://50.116.53.12:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787666",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "c633408f9d364740bec696456d5f1ae2",
		"version": "1"
	},
	"2": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://172.105.83.46:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787611",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "c1da19c60b7a4bf7a66f60825bec7a82",
		"version": "1"
	},
	"3": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://212.71.234.197:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787367",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "cc95dbf6a3d340fb95452f452a23aa40",
		"version": "1"
	},
	"4": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://192.46.209.107:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787754",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "3d0fa08a6d034d01a820ea05cbf93831",
		"version": "1"
	},
	"5": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://172.105.18.196:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787679",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "3794a7c3d1734dc8abcb57c82c972549",
		"version": "1"
	},
	"6": {
		"announce": "/api/consensusroom-announce",
		"baseUrl": "http://45.79.92.158:3300",
		"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
		"myTimestamp": "1644878787692",
		"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
		"timestampAPI": "/api/consensusroom-get-timestamp",
		"uid": "11e06cf7615a43f08ebd31c97e1ef9cb",
		"version": "1"
	},
        "non numero": "quarantadue"
}
EOF


cat <<EOF | zexe timestamp_stats.zen -a timestamp_stats.json
Given I have a 'string dictionary' named '1'
Given I have a 'string dictionary' named '2'
Given I have a 'string dictionary' named '3'
Given I have a 'string dictionary' named '4'
Given I have a 'string dictionary' named '5'
Given I have a 'string dictionary' named '6'

Given I have the 'string' named 'non numero'

When I create the copy of 'myTimestamp' from dictionary '1'
When I rename the 'copy' to 'time1'

When I create the copy of 'myTimestamp' from dictionary '2'
When I rename the 'copy' to 'time2'

When I create the copy of 'myTimestamp' from dictionary '3'
When I rename the 'copy' to 'time3'
Jaromil's avatar
Jaromil committed
296

297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
When I create the copy of 'myTimestamp' from dictionary '4'
When I rename the 'copy' to 'time4'

When I create the copy of 'myTimestamp' from dictionary '5'
When I rename the 'copy' to 'time5'

When I create the copy of 'myTimestamp' from dictionary '6'
When I rename the 'copy' to 'time6'

# Insert timestamps in array to create average and variance

When I create the 'string array'
When I rename the 'string array' to 'allTimestamps'

When I insert 'time1' in 'allTimestamps'
When I insert 'time2' in 'allTimestamps'
When I insert 'time3' in 'allTimestamps'
When I insert 'time4' in 'allTimestamps'
When I insert 'time5' in 'allTimestamps'
When I insert 'time6' in 'allTimestamps'
# When I insert 'non numero' in 'allTimestamps'

When I create the average of elements in array 'allTimestamps'
When I create the variance of elements in array 'allTimestamps'
When I create the standard deviation of elements in array 'allTimestamps'

Then print the 'average'
Then print the 'variance'
Then print the 'standard deviation'
Then print the 'allTimestamps'
EOF
Jaromil's avatar
Jaromil committed
328
329
success