run.sh 21.9 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

matteocristino's avatar
matteocristino committed
329
330
331
332
cat <<EOF > not_flat_array.json
{
"identities": [
	[
333
	     	"https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
matteocristino's avatar
matteocristino committed
334
335
336
337
338
339
340
341
342
343
344
345
346
347
	],
	[
		"https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
	],
	[
		"https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
	],
	[
		"https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
	]
]
}
EOF

348
cat <<EOF | zexe flat_array.zen -a not_flat_array.json | jq .
matteocristino's avatar
matteocristino committed
349
350
Rule check version 2.0.0
Given I have a 'string array' named 'identities'
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
When I create the flat array of contents in 'identities'
and I rename 'flat array' to 'contents flat array'
When I create the flat array of keys in 'identities'
and I rename 'flat array' to 'keys flat array'
Then print the 'keys flat array'
and print the 'contents flat array'
EOF

cat timestamp_stats.json | jq '{"timestamp": . }' > not_flat_dic.json

cat <<EOF | zexe flat_array_contents.zen -a not_flat_dic.json | jq .
Rule check version 2.0.0
Given I have a 'string dictionary' named 'timestamp'
When I create the flat array of contents in 'timestamp'
and I rename 'flat array' to 'contents flat array'
When I create the flat array of keys in 'timestamp'
and I rename 'flat array' to 'keys flat array'
Then print the 'keys flat array'
and print the 'contents flat array'
matteocristino's avatar
matteocristino committed
370
371
EOF

372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
cat <<EOF > consensusroom-flatten.data
{
 "identities": [
  [
   "https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
  ],
  [
   "https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
  ],
  [
   "https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
  ],
  [
   "https://api/dyneorgroom.net/api/dyneorg/consensusroom-get-timestamp"
  ]
 ],
 "identity": {
  "uid": "random",
  "ip": "hostname -I",
  "baseUrl": "http://hostname -I",
  "port_http": "$PORT_HTTP",
  "port_https": "$PORT_HTTPS",
  "public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
  "version": "2",
  "announceAPI": "/api/consensusroom-announce",
  "get-6-timestampsAPI": "/api/consensusroom-get-6-timestamps",
  "timestampAPI": "/api/consensusroom-get-timestamp",
  "tracker": "https://apiroom.net/"
 }
}
EOF

cat <<EOF | zexe consensusroom-flatten.zen -a consensusroom-flatten.data
Given I have a 'string array' named 'identities'
Given I have a 'string dictionary' named 'identity'

When I create the flat array of contents in 'identities'
When I rename the 'flat array' to 'flattened array 1'

When I create the flat array of keys in 'identity'
When I rename the 'flat array' to 'flattened array 2'

Then print the 'flattened array 1'
Then print the 'flattened array 2'
Then print the string 'succes'
EOF


420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
cat <<EOF | save array dictionaries.json
{
	"nameOfObject": "timestampEndpoint",
	"identities": {
		"172.105.105.137": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://172.105.105.137:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "172.105.105.137",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"172.105.33.141": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://172.105.33.141:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "172.105.33.141",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"194.195.123.140": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://194.195.123.140:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "194.195.123.140",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"194.195.240.46": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://194.195.240.46:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "194.195.240.46",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"45.33.44.32": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://45.33.44.32:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "45.33.44.32",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"50.116.61.250": {
			"announce": "/api/consensusroom-announce",
			"baseUrl": "http://50.116.61.250:3300",
			"get-6-timestamps": "/api/consensusroom-get-6-timestamps",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timestampAPI": "/api/consensusroom-get-timestamp",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "50.116.61.250",
			"updateAPI": "/api/consensusroom-update",
			"version": "1"
		},
		"Pepero": {
			"baseUrl": "http://192.168.0.100:3030",
			"ip": "192.168.0.100",
			"public_key": "BGiQeHz55rNc/k/iy7wLzR1jNcq/MOy8IyS6NBZ0kY3Z4sExlyFXcILcdmWDJZp8FyrILOC6eukLkRNt7Q5tzWU=",
			"timeServer": "http://localhost:3312",
			"timestampEndpoint": "http://172.105.105.137:3300/api/consensusroom-get-timestamp",
			"uid": "Kenshiro",
			"version": "1"
		}
	}
}
EOF

cat <<EOF | zexe dict2array.zen -a dictionaries.json
Given I have a 'string dictionary' named 'identities'
and a 'string' named 'nameOfObject'
When I create the array of objects named by 'nameOfObject' found in 'identities'
Then print the 'array'
EOF

510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
cat <<EOF > compare-equal.data
{
 "arr": [1,1,1,1],
 "dict": {
   "hello": "world",
   "nice": "world",
   "big": "world"
 },
 "empty_dict": {},
 "nested_arr": [
   { "nested": "nested" },
   { "nested": "nested" }
 ]

}
EOF

Alberto Lerda's avatar
Alberto Lerda committed
527
cat <<EOF | zexe compare-equal.zen -a compare-equal.data
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
Given I have a 'string array' named 'arr'
Given I have a 'string dictionary' named 'dict'
Given I have a 'string array' named 'nested_arr'
Given I have a 'string dictionary' named 'empty_dict'

If the elements in 'arr' are all equal
If the elements in 'dict' are all equal
If the elements in 'nested arr' are all equal
If the elements in 'empty dict' are all equal
Then print string 'OK'
EOF

cat <<EOF > compare-not-equal.data
{
 "arr": [1,1,1,3],
 "dict": {
   "hello": "world",
   "nice": "world",
   "big": "earth"
 },
 "nested_arr": [
   { "nested": "nested" },
   { "nested": "not-nested" }
 ]

}
EOF

Alberto Lerda's avatar
Alberto Lerda committed
556
cat <<EOF | zexe compare-not-equal.zen -a compare-not-equal.data
557
558
559
560
561
562
563
564
565
566
Given I have a 'string array' named 'arr'
Given I have a 'string dictionary' named 'dict'
Given I have a 'string array' named 'nested_arr'

If the elements in 'arr' are not all equal
If the elements in 'dict' are not all equal
If the elements in 'nested arr' are not all equal
Then print string 'OK'
EOF

567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
cat <<EOF | save array table-arrays.json
{ "identity": {
    "announceAPI": "/api/zenswarm-oracle-announce",
    "baseUrl": "http://zenswarm.zenroom.org",
    "country": "IT",
    "ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
    "get-identityAPI": "/api/zenswarm-oracle-get-identity",
    "http-postAPI": "/api/zenswarm-oracle-http-post",
    "oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
    "pingAPI": "/api/zenswarm-oracle-ping.zen",
    "port_http": "28170",
    "port_https": "28331",
    "sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
    "timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
    "tracker": "https://apiroom.net/",
    "type": "restroom-mw",
    "updateAPI": "/api/zenswarm-oracle-update",
    "version": "2"
  },
"identities": [
 {
      "announceAPI": "/api/zenswarm-oracle-announce",
      "baseUrl": "http://zenswarm.zenroom.org",
      "country": "IT",
      "ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
      "get-identityAPI": "/api/zenswarm-oracle-get-identity",
      "http-postAPI": "/api/zenswarm-oracle-http-post",
      "oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
      "pingAPI": "/api/zenswarm-oracle-ping.zen",
      "port_http": "26962",
      "port_https": "25991",
      "region": "NONE",
      "sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
      "timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
      "tracker": "https://apiroom.net/",
      "type": "restroom-mw",
      "updateAPI": "/api/zenswarm-oracle-update",
      "version": "2"
    },
    {
      "announceAPI": "/api/zenswarm-oracle-announce",
      "baseUrl": "http://zenswarm.zenroom.org",
      "country": "IT",
      "ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
      "get-identityAPI": "/api/zenswarm-oracle-get-identity",
      "http-postAPI": "/api/zenswarm-oracle-http-post",
      "oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
      "pingAPI": "/api/zenswarm-oracle-ping.zen",
      "port_http": "26368",
      "port_https": "29841",
      "region": "NONE",
      "sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
      "timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
      "tracker": "https://apiroom.net/",
      "type": "restroom-mw",
      "updateAPI": "/api/zenswarm-oracle-update",
      "version": "2"
    },
{
    "announceAPI": "/api/zenswarm-oracle-announce",
    "baseUrl": "http://zenswarm.zenroom.org",
    "country": "IT",
    "ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
    "get-identityAPI": "/api/zenswarm-oracle-get-identity",
    "http-postAPI": "/api/zenswarm-oracle-http-post",
    "oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
    "pingAPI": "/api/zenswarm-oracle-ping.zen",
    "port_http": "28170",
    "port_https": "28331",
    "sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
    "timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
    "tracker": "https://apiroom.net/",
    "type": "restroom-mw",
    "updateAPI": "/api/zenswarm-oracle-update",
    "version": "2"
}
  ]
}

EOF

648
cat <<EOF | zexe remove-table-from-table.zen -a table-arrays.json | jq .
649
650
651
652
653
654
655
656
657
658
659
Given I have a 'string array' named 'identities'
Given I have a 'string array' named 'identity'
When I create the size of 'identities'
and I rename 'size' to 'before'
and I remove the 'identity' from 'identities'
and I create the size of 'identities'
and I rename 'size' to 'after'
Then print the 'before'
and print the 'after'
EOF

matteocristino's avatar
matteocristino committed
660
success