forked from zigbee-alliance/distributed-compliance-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodelversion-demo-hex.sh
155 lines (122 loc) · 6.8 KB
/
modelversion-demo-hex.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
#!/bin/bash
# Copyright 2020 DSR Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
source integration_tests/cli/common.sh
# Preparation of Actors
vid_in_hex_format=0xA13
pid_in_hex_format=0xA11
vid=2579
pid=2577
vendor_account=vendor_account_$vid_in_hex_format
echo "Create Vendor account - $vendor_account"
create_new_vendor_account $vendor_account $vid_in_hex_format
# Create a new model version
echo "Add Model with VID: $vid_in_hex_format PID: $pid_in_hex_format"
result=$(echo "test1234" | dcld tx model add-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format --deviceTypeID=1 --productName=TestProduct --productLabel="Test Product" --partNumber=1 --commissioningCustomFlow=0 --enhancedSetupFlowOptions=0 --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
test_divider
sv=$RANDOM
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
# Query the model version
echo "Query Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv"
result=$(dcld query model model-version --vid=$vid_in_hex_format --pid=$pid_in_hex_format --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
# Query all models versions
echo "Query all model versions with VID: $vid_in_hex_format PID: $pid_in_hex_format "
result=$(dcld query model all-model-versions --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"softwareVersions\""
check_response "$result" "$sv"
test_divider
# Query non existent model version
echo "Query Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: 123456"
result=$(dcld query model model-version --vid=$vid_in_hex_format --pid=$pid_in_hex_format --softwareVersion=123456)
check_response "$result" "Not Found"
test_divider
# Query non existent model versions
vid1_in_hex_format=0xA14
pid1_in_hex_format=0xA15
echo "Query all Device Model Versions with VID: $vid1_in_hex_format PID: $pid1_in_hex_format"
result=$(dcld query model all-model-versions --vid=$vid1_in_hex_format --pid=$pid1_in_hex_format)
check_response "$result" "Not Found"
test_divider
# Update the existing model version
echo "Update Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv"
result=$(echo 'test1234' | dcld tx model update-model-version --vid=$vid_in_hex_format --pid=$pid_in_hex_format --minApplicableSoftwareVersion=2 --maxApplicableSoftwareVersion=10 --softwareVersion=$sv --softwareVersionValid=false --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
test_divider
# Query Updated model version
echo "Query updated Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv"
result=$(dcld query model model-version --vid=$vid_in_hex_format --pid=$pid_in_hex_format --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\": false"
check_response "$result" "\"minApplicableSoftwareVersion\": 2"
check_response "$result" "\"maxApplicableSoftwareVersion\": 10"
test_divider
# Add second model version
sv2=$RANDOM
echo "Create a Second Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv2"
result=$(echo 'test1234' | dcld tx model add-model-version --cdVersionNumber=1 --maxApplicableSoftwareVersion=10 --minApplicableSoftwareVersion=1 --vid=$vid --pid=$pid --softwareVersion=$sv2 --softwareVersionString=1 --from=$vendor_account --yes)
result=$(get_txn_result "$result")
echo "$result"
check_response "$result" "\"code\": 0"
test_divider
# Query all model versions
echo "Query all model versions with VID: $vid_in_hex_format PID: $pid_in_hex_format "
result=$(dcld query model all-model-versions --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
echo "$result"
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"softwareVersions\""
check_response "$result" "$sv"
check_response "$result" "$sv2"
test_divider
# Create model version with vid belonging to another vendor
echo "Create a Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv from a different vendor account"
new_vid_in_hex_format="0xB17"
different_vendor_account=vendor_account_$new_vid_in_hex_format
create_new_vendor_account $different_vendor_account $new_vid_in_hex_format
result=$(echo 'test1234' | dcld tx model add-model-version --cdVersionNumber=1 --maxApplicableSoftwareVersion=10 --minApplicableSoftwareVersion=1 --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=1 --from=$different_vendor_account --yes)
result=$(get_txn_result "$result")
check_response_and_report "$result" "transaction should be signed by a vendor account containing the vendorID $vid"
test_divider
# Update model version with vid belonging to another vendor
echo "Update a Device Model Version with VID: $vid_in_hex_format PID: $pid_in_hex_format SV: $sv from a different vendor account"
result=$(echo 'test1234' | dcld tx model update-model-version --vid=$vid_in_hex_format --pid=$pid_in_hex_format --softwareVersion=$sv --softwareVersionValid=false --from=$different_vendor_account --yes)
result=$(get_txn_result "$result")
check_response_and_report "$result" "transaction should be signed by a vendor account containing the vendorID $vid"