forked from zigbee-alliance/distributed-compliance-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model-demo-hex.sh
139 lines (106 loc) · 4.56 KB
/
model-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
#!/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
# Check add model with fieds VID/PID in hex format and
# get model with fields VID/PID in hex format
# Preperation 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
test_divider
# Body
echo "Query non existent model"
result=$(dcld query model get-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
check_response "$result" "Not Found"
echo "$result"
test_divider
echo "Query non existent Vendor Models"
result=$(dcld query model vendor-models --vid=$vid_in_hex_format)
check_response "$result" "Not Found"
echo "$result"
test_divider
echo "Request all models must be empty"
result=$(dcld query model all-models)
check_response "$result" "\[\]"
echo "$result"
test_divider
productLabel="Device #1"
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="$productLabel" --partNumber=1 --commissioningCustomFlow=0 --enhancedSetupFlowOptions=0 --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
echo "$result"
test_divider
echo "Get Model with VID: $vid_in_hex_format PID: $pid_in_hex_format"
result=$(dcld query model get-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"productLabel\": \"$productLabel\""
echo "$result"
test_divider
echo "Get all models"
result=$(dcld query model all-models)
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
echo "$result"
test_divider
echo "Get Vendor Models with VID: ${vid_in_hex_format}"
result=$(dcld query model vendor-models --vid=$vid_in_hex_format)
check_response "$result" "\"pid\": $pid"
echo "$result"
test_divider
echo "Update Model with VID: ${vid_in_hex_format} PID: ${pid_in_hex_format} with new description"
description="New Device Description"
result=$(echo "test1234" | dcld tx model update-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format --enhancedSetupFlowOptions=2 --from $vendor_account --yes --productLabel "$description")
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
echo "$result"
test_divider
echo "Get Model with VID: ${vid_in_hex_format} PID: ${pid_in_hex_format}"
result=$(dcld query model get-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"productLabel\": \"$description\""
echo "$result"
test_divider
echo "Update Model with VID: ${vid_in_hex_format} PID: ${pid_in_hex_format} modifying supportURL"
supportURL="https://newsupporturl.test"
result=$(echo "test1234" | dcld tx model update-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format --enhancedSetupFlowOptions=2 --from $vendor_account --yes --supportURL "$supportURL")
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
echo "$result"
test_divider
echo "Get Model with VID: ${vid_in_hex_format} PID: ${pid_in_hex_format}"
result=$(dcld query model get-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"supportUrl\": \"$supportURL\""
echo "$result"
test_divider
echo "Delete Model with VID: ${vid_in_hex_format} PID: ${pid_in_hex_format}"
result=$(dcld tx model delete-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format --from=$vendor_account --yes)
result=$(get_txn_result "$result")
echo "$result"
test_divider
echo "Query non existent model"
result=$(dcld query model get-model --vid=$vid_in_hex_format --pid=$pid_in_hex_format)
check_response "$result" "Not Found"
echo "$result"
test_divider