-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathvendorinfo.sh
109 lines (70 loc) · 2.65 KB
/
vendorinfo.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
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
echo "Query non existent vendorinfo"
result=$(execute_with_retry "dcld query vendorinfo vendor --vid=$vid")
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 vendorinfos"
result=$(execute_with_retry "dcld query vendorinfo all-vendors")
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
vendor_account=vendor_account_$vid
echo "Create Vendor account - $vendor_account"
create_new_vendor_account $vendor_account $vid
test_divider
echo "Create VendorInfo Record for VID: $vid"
companyLegalName="XYZ IOT Devices Inc"
vendorName="XYZ Devices"
result=$(echo "test1234" | dcld tx vendorinfo add-vendor --vid=$vid --companyLegalName="$companyLegalName" --vendorName="$vendorName" --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"
echo "$result"
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 vendorinfo"
result=$(execute_with_retry "dcld query vendorinfo vendor --vid=$vid")
echo "$result"
check_response "$result" "\"vendorID\": $vid"
check_response "$result" "\"companyLegalName\": \"$companyLegalName\""
check_response "$result" "\"vendorName\": \"$vendorName\""
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
echo "Query non existent vendorinfo"
result=$(execute_with_retry "dcld query vendorinfo vendor --vid=$vid")
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 vendorinfo"
result=$(echo "test1234" | dcld tx vendorinfo add-vendor --vid=$vid --companyLegalName="$companyLegalName" --vendorName="$vendorName" --from=$vendor_account --yes)
echo "$result"
check_response "$result" "Write requests don't work with a Light Client Proxy"
test_divider