-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathmodel.sh
201 lines (141 loc) · 5.86 KB
/
model.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
set -euo pipefail
source integration_tests/cli/common.sh
# 1. check non-existent values via light client when no entry added
echo "check non-existent values via light client when no entry added"
test_divider
# connect to light client proxy
dcld config node tcp://localhost:26620
sleep 10
vid=$RANDOM
pid=$RANDOM
sv=$RANDOM
echo "Query non existent model"
result=$(execute_with_retry "dcld query model get-model --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent Vendor Models"
result=$(execute_with_retry "dcld query model vendor-models --vid=$vid")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent model version"
result=$(execute_with_retry "dcld query model model-version --vid=$vid --pid=$pid --softwareVersion=$sv")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent model versions"
result=$(execute_with_retry "dcld query model all-model-versions --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "Not Found"
test_divider
# 2. list queries should return a warning via light client
echo "list queries should return a warning via light client"
test_divider
echo "Request all models"
result=$(execute_with_retry "dcld query model all-models")
echo "$result"
check_response "$result" "List queries don't work with a Light Client Proxy"
test_divider
# 3. write entries
echo "write entries"
test_divider
# write requests can be sent via Full Node only
dcld config node tcp://localhost:26657
vid=$RANDOM
pid=$RANDOM
sv=$RANDOM
vendor_account=vendor_account_$vid
echo "Create Vendor account - $vendor_account"
create_new_vendor_account $vendor_account $vid
test_divider
productLabel="Device #1"
echo "Add Model with VID: $vid PID: $pid"
result=$(echo "test1234" | dcld tx model add-model --vid=$vid --pid=$pid --deviceTypeID=1 --productName=TestProduct --productLabel="$productLabel" --partNumber=1 --commissioningCustomFlow=0 --from=$vendor_account --yes)
result=$(get_txn_result "$result")
echo "$result"
check_response "$result" "\"code\": 0"
test_divider
echo "Create a Device Model Version with VID: $vid PID: $pid SV: $sv"
result=$(echo 'test1234' | dcld tx model add-model-version --cdVersionNumber=1 --maxApplicableSoftwareVersion=10 --minApplicableSoftwareVersion=1 --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=1 --from=$vendor_account --yes)
result=$(get_txn_result "$result")
echo "$result"
check_response "$result" "\"code\": 0"
test_divider
# 4. check existent values via light client
echo "check existent values via light client"
test_divider
# connect to light client proxy
dcld config node tcp://localhost:26620
sleep 5
echo "Get Model with VID: $vid PID: $pid"
result=$(execute_with_retry "dcld query model get-model --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"productLabel\": \"$productLabel\""
test_divider
echo "Query Device Model Version with VID: $vid PID: $pid SV: $sv"
result=$(execute_with_retry "dcld query model model-version --vid=$vid --pid=$pid --softwareVersion=$sv")
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"softwareVersion\": $sv"
check_response "$result" "\"softwareVersionString\": \"1\""
check_response "$result" "\"cdVersionNumber\": 1"
check_response "$result" "\"softwareVersionValid\": true"
check_response "$result" "\"minApplicableSoftwareVersion\": 1"
check_response "$result" "\"maxApplicableSoftwareVersion\": 10"
test_divider
echo "Query Vendor Models"
result=$(execute_with_retry "dcld query model vendor-models --vid=$vid")
echo "$result"
check_response "$result" "\"pid\": $pid"
test_divider
echo "Query model versions"
result=$(execute_with_retry "dcld query model all-model-versions --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"softwareVersions\""
check_response "$result" "$sv"
test_divider
# 5. check non-existent values via light client when entry added
echo "check non-existent values via light client when entry added"
test_divider
vid=$RANDOM
pid=$RANDOM
sv=$RANDOM
echo "Query non existent model"
result=$(execute_with_retry "dcld query model get-model --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent model version"
result=$(execute_with_retry "dcld query model model-version --vid=$vid --pid=$pid --softwareVersion=$sv")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent Vendor Models"
result=$(execute_with_retry "dcld query model vendor-models --vid=$vid")
echo "$result"
check_response "$result" "Not Found"
test_divider
echo "Query non existent model versions"
result=$(execute_with_retry "dcld query model all-model-versions --vid=$vid --pid=$pid")
echo "$result"
check_response "$result" "Not Found"
test_divider
# 6. try to write via light client proxy
echo "try to write via light client proxy"
test_divider
echo "Add Model with VID: $vid PID: $pid"
result=$(echo "test1234" | dcld tx model add-model --vid=$vid --pid=$pid --deviceTypeID=1 --productName=TestProduct --productLabel="$productLabel" --partNumber=1 --commissioningCustomFlow=0 --from=$vendor_account --yes)
echo "$result"
check_response "$result" "Write requests don't work with a Light Client Proxy"
test_divider
echo "Create a Device Model Version with VID: $vid PID: $pid SV: $sv"
result=$(echo 'test1234' | dcld tx model add-model-version --cdVersionNumber=1 --maxApplicableSoftwareVersion=10 --minApplicableSoftwareVersion=1 --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=1 --from=$vendor_account --yes)
echo "$result"
check_response "$result" "Write requests don't work with a Light Client Proxy"
test_divider