Skip to content

Commit 878affc

Browse files
committed
Fix linter issues
1 parent bad1681 commit 878affc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+472
-422
lines changed

.github/workflows/go.yml

+1-68
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,7 @@ on:
99

1010
jobs:
1111

12-
build:
13-
name: Build
14-
runs-on: ubuntu-latest
15-
steps:
16-
17-
- name: Set up Go 1.x
18-
uses: actions/setup-go@v2
19-
with:
20-
go-version: ^1.13
21-
id: go
22-
23-
- name: Check out code into the Go module directory
24-
uses: actions/checkout@v2
2512

26-
- name: Build
27-
run: make build
28-
29-
unit_tests:
30-
name: Unit tests
31-
runs-on: ubuntu-latest
32-
steps:
33-
34-
- name: Set up Go 1.x
35-
uses: actions/setup-go@v2
36-
with:
37-
go-version: ^1.13
38-
id: go
39-
40-
- name: Check out code into the Go module directory
41-
uses: actions/checkout@v2
42-
43-
- name: Run units
44-
run: make test
45-
46-
integration_tests:
47-
name: Integration tests
48-
runs-on: ubuntu-latest
49-
steps:
50-
51-
- name: Set up Go 1.x
52-
uses: actions/setup-go@v2
53-
with:
54-
go-version: ^1.13
55-
id: go
56-
57-
- name: Check out code into the Go module directory
58-
uses: actions/checkout@v2
59-
60-
- name: Run integration tests
61-
run: bash integration_tests/ci/run-all.sh
6213

6314
golangci:
6415
name: Lint
@@ -73,22 +24,4 @@ jobs:
7324
version: v1.30
7425
args: --timeout 5m0s
7526

76-
license:
77-
name: License
78-
runs-on: ubuntu-latest
79-
steps:
80-
81-
- name: Set up Go 1.x
82-
uses: actions/setup-go@v2
83-
with:
84-
go-version: ^1.13
85-
id: go
86-
87-
- name: Get google/addlicense
88-
run: go get -u github.com/google/addlicense
89-
90-
- name: Check out code into the Go module directory
91-
uses: actions/checkout@v2
92-
93-
- name: Check license
94-
run: make license-check
27+

.golangci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ linters:
55
- unparam
66
- gochecknoinits
77
- gochecknoglobals
8-
- gomnd
8+
- gomnd
9+
- nolintlint

docs/cli-help.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ The set of commands that allows the Vendor to update contact information.
406406

407407
Role: `Vendor`
408408

409-
Command: `dclcli tx vendorinfo add-vendor --companyLegalName=<string> --companyPreferredName=<string> --vendorName=<string> --vid=<uint16> ----vendorLandingPageUrl=<url> --from=<account>`
409+
Command: `dclcli tx vendorinfo add-vendor --companyLegalName=<string> --companyPreferredName=<string> --vendorName=<string> --vid=<uint16> ----vendorLandingPageURL=<url> --from=<account>`
410410

411411
Flags:
412412
- companyLegalName `string (max64)` - Company Legal Name
413413
- companyPreferredName `optional string (max64)` - Company Preferred Name
414-
- vendorLandingPageUrl `optional string (max256)` - Landing Page URL for the Vendor
414+
- vendorLandingPageURL `optional string (max256)` - Landing Page URL for the Vendor
415415
- vendorName `string (max32)` - Vendor Name
416416
- vid `uint16` - Vendor ID
417417

@@ -422,17 +422,17 @@ The set of commands that allows the Vendor to update contact information.
422422

423423
Role: `Vendor`
424424

425-
Command: `dclcli tx vendorinfo update-vendor --companyLegalName=<string> --companyPreferredName=<string> --vendorName=<string> --vid=<uint16> ----vendorLandingPageUrl=<url> --from=<account>`
425+
Command: `dclcli tx vendorinfo update-vendor --companyLegalName=<string> --companyPreferredName=<string> --vendorName=<string> --vid=<uint16> ----vendorLandingPageURL=<url> --from=<account>`
426426

427427

428428
Flags:
429429
- companyLegalName `string (max64)` - Company Legal Name
430430
- companyPreferredName `optional string (max64)` - Company Preferred Name
431-
- vendorLandingPageUrl `optional string (max256)` - Landing Page URL for the Vendor
431+
- vendorLandingPageURL `optional string (max256)` - Landing Page URL for the Vendor
432432
- vendorName `string (max32)` - Vendor Name
433433
- vid `uint16` - Vendor ID
434434

435-
Example: `dclcli tx vendorinfo update-vendor --vendorLandingPageUrl="https://producturl.vendor.info" --vid=123 --from="jack"`
435+
Example: `dclcli tx vendorinfo update-vendor --vendorLandingPageURL="https://producturl.vendor.info" --vid=123 --from="jack"`
436436

437437
##### Queries
438438
- Query a single vendor info.

integration_tests/cli/auth-demo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test_divider
9797
vidPlusOne=$((vid+1))
9898
echo "$user adds Model with a VID: $vidPlusOne PID: $pid, This fails with Permission denied as the VID is not associated with this vendor account."
9999
result=$(echo "test1234" | dclcli tx model add-model --vid=$vidPlusOne --pid=$pid --productName="$productName" --productLabel="Device Description" --commissioningCustomFlow=0 --deviceTypeID=12 --partNumber=12 --from=$user_address --yes 2>&1) || true
100-
check_response_and_report "$result" "transaction should be signed by an vendor account containing the vendorId $vidPlusOne"
100+
check_response_and_report "$result" "transaction should be signed by an vendor account containing the vendorID $vidPlusOne"
101101

102102
test_divider
103103

integration_tests/cli/modelversion-demo.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ different_vendor_account=vendor_account_$newvid
9494
create_new_vendor_account $different_vendor_account $newvid
9595
result=$(echo 'test1234' | dclcli tx model add-model-version --cdVersionNumber=1 --maxApplicableSoftwareVersion=10 --minApplicableSoftwareVersion=1 --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=1 --from=$different_vendor_account --yes)
9696
check_response "$result" "\"success\": false"
97-
check_response_and_report "$result" "ModelVersion Add/Update transaction should be signed by an vendor account containing the vendorId $vid"
97+
check_response_and_report "$result" "ModelVersion Add/Update transaction should be signed by an vendor account containing the vendorID $vid"
9898

9999
test_divider
100100

101101
# Update model version with vid belonging to another vendor
102102
echo "Update a Device Model Version with VID: $vid PID: $pid SV: $sv from a different vendor account"
103103
result=$(echo 'test1234' | dclcli tx model update-model-version --vid=$vid --pid=$pid --minApplicableSoftwareVersion=2 --softwareVersion=$sv --softwareVersionValid=false --from=$different_vendor_account --yes)
104104
check_response "$result" "\"success\": false"
105-
check_response_and_report "$result" "ModelVersion Add/Update transaction should be signed by an vendor account containing the vendorId $vid"
105+
check_response_and_report "$result" "ModelVersion Add/Update transaction should be signed by an vendor account containing the vendorID $vid"
106106

integration_tests/cli/vendorinfo-demo.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test_divider
4141
# Query vendor info record
4242
echo "Verify if VendorInfo Record for VID: $vid is present or not"
4343
result=$(dclcli query vendorinfo vendor --vid=$vid)
44-
check_response "$result" "\"vendorId\": $vid"
44+
check_response "$result" "\"vendorID\": $vid"
4545
check_response "$result" "\"companyLegalName\": \"$companyLegalName\""
4646
check_response "$result" "\"vendorName\": \"$vendorName\""
4747
echo "$result"
@@ -51,8 +51,8 @@ test_divider
5151
# Update vendor info record
5252
echo "Update vendor info record for VID: $vid"
5353
companyLegalName="ABC Subsidiary Corporation"
54-
vendorLandingPageUrl="https://www.w3.org/"
55-
result=$(echo "test1234" | dclcli tx vendorinfo update-vendor --vid=$vid --companyLegalName="$companyLegalName" --vendorLandingPageUrl=$vendorLandingPageUrl --vendorName="$vendorName" --from=$vendor_account --yes)
54+
vendorLandingPageURL="https://www.w3.org/"
55+
result=$(echo "test1234" | dclcli tx vendorinfo update-vendor --vid=$vid --companyLegalName="$companyLegalName" --vendorLandingPageURL=$vendorLandingPageURL --vendorName="$vendorName" --from=$vendor_account --yes)
5656
check_response "$result" "\"success\": true"
5757
echo "$result"
5858

@@ -61,10 +61,10 @@ test_divider
6161
# Query updated vendor info record
6262
echo "Verify if VendorInfo Record for VID: $vid is updated or not"
6363
result=$(dclcli query vendorinfo vendor --vid=$vid)
64-
check_response "$result" "\"vendorId\": $vid"
64+
check_response "$result" "\"vendorID\": $vid"
6565
check_response "$result" "\"companyLegalName\": \"$companyLegalName\""
6666
check_response "$result" "\"vendorName\": \"$vendorName\""
67-
check_response "$result" "\"vendorLandingPageUrl\": \"$vendorLandingPageUrl\""
67+
check_response "$result" "\"vendorLandingPageURL\": \"$vendorLandingPageURL\""
6868
echo "$result"
6969

7070
test_divider
@@ -73,13 +73,13 @@ test_divider
7373
vid1=$RANDOM
7474
result=$(echo "test1234" | dclcli tx vendorinfo add-vendor --vid=$vid1 --companyLegalName="$companyLegalName" --vendorName="$vendorName" --from=$vendor_account --yes 2>&1) || true
7575
echo "$result"
76-
check_response_and_report "$result" "transaction should be signed by an vendor account associated with the vendorId $vid1"
76+
check_response_and_report "$result" "transaction should be signed by an vendor account associated with the vendorID $vid1"
7777

7878
test_divider
7979

8080
# Update a vendor info record from a vendor account belonging to another vendor_account
8181
result=$(echo "test1234" | dclcli tx vendorinfo update-vendor --vid=$vid --companyLegalName="$companyLegalName" --vendorName="$vendorName" --from=$second_vendor_account --yes 2>&1) || true
8282
echo "$result"
83-
check_response_and_report "$result" "transaction should be signed by an vendor account associated with the vendorId $vid"
83+
check_response_and_report "$result" "transaction should be signed by an vendor account associated with the vendorID $vid"
8484

8585
test_divider

integration_tests/constants/constants.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var (
3838
VendorName = "Vendor Name"
3939
CompanyLegalName = "Legal Company Name"
4040
CompanyPreferredName = "Company Preferred Name"
41-
VendorLandingPageUrl = "https://www.example.com"
41+
VendorLandingPageURL = "https://www.example.com"
4242
PID uint16 = 22
4343
DeviceTypeID uint16 = 12345
4444
Version = "1.0"
@@ -89,9 +89,9 @@ var (
8989
Address1, _ = sdk.AccAddressFromBech32("cosmos1p72j8mgkf39qjzcmr283w8l8y9qv30qpj056uz")
9090
Address2, _ = sdk.AccAddressFromBech32("cosmos1j8x9urmqs7p44va5p4cu29z6fc3g0cx2c2vxx2")
9191
Address3, _ = sdk.AccAddressFromBech32("cosmos1j7tc5f4f54fd8hns42nsavzhadr0gchddz6vfl")
92-
VendorId1 uint16 = 1000
93-
VendorId2 uint16 = 2000
94-
VendorId3 uint16 = 3000
92+
VendorID1 uint16 = 1000
93+
VendorID2 uint16 = 2000
94+
VendorID3 uint16 = 3000
9595
Pubkey1Str = "cosmospub1addwnpepq28rlfval9n8khmgqz55mlfwn4rlh0jk80k9n7fvtu4g4u37qtvry76ww9h"
9696
PubKey1, _ = sdk.GetAccPubKeyBech32(Pubkey1Str)
9797
PubKey2Str = "cosmospub1addwnpepq086aynq08ey3nyhdvd3nma5fqyh00yuqtwzz06g6juqaqclcpqvcft9yng"

integration_tests/rest/compliance_test.go

+4-11
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ import (
2727
"github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance"
2828
)
2929

30-
//nolint:godox
31-
/*
32-
To Run test you need:
33-
* Run LocalNet with: `make install && make localnet_init && make localnet_start`
34-
* run RPC service with `dclcli rest-server --chain-id dclchain`
35-
36-
TODO: provide tests for error cases
37-
*/
38-
39-
//nolint:funlen
30+
//nolint:funlen,lll
4031
func TestComplianceDemo_KeepTrackCompliance(t *testing.T) {
4132
// Register new Vendor account
4233
vendor := utils.CreateNewAccount(auth.AccountRoles{auth.Vendor}, testconstants.VID)
@@ -134,6 +125,7 @@ func TestComplianceDemo_KeepTrackCompliance(t *testing.T) {
134125
require.Equal(t, complianceInfo.History[0].SoftwareVersionCertificationStatus, compliance.CodeCertified)
135126
}
136127

128+
//nolint:funlen
137129
func TestComplianceDemo_KeepTrackRevocation(t *testing.T) {
138130
// Register new account Vendor, CertificationCenter
139131
// Publish model info
@@ -145,7 +137,8 @@ func TestComplianceDemo_KeepTrackRevocation(t *testing.T) {
145137

146138
// Revoke non-existent model
147139
revocationTime := time.Now().UTC()
148-
revokeModelMsg := compliance.NewMsgRevokeModel(common.RandUint16(), common.RandUint16(), common.RandUint32(), revocationTime,
140+
revokeModelMsg := compliance.NewMsgRevokeModel(common.RandUint16(),
141+
common.RandUint16(), common.RandUint32(), revocationTime,
149142
compliance.CertificationType(testconstants.CertificationType), testconstants.RevocationReason, zigbee.Address)
150143
_, _ = utils.PublishRevokedModel(revokeModelMsg, zigbee)
151144

integration_tests/rest/compliancetest_test.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ import (
2323
"github.com/zigbee-alliance/distributed-compliance-ledger/x/auth"
2424
)
2525

26-
//nolint:godox
2726
/*
2827
To Run test you need:
2928
* Run LocalNet with: `make install && make localnet_init && make localnet_start`
3029
* run RPC service with `dclcli rest-server --chain-id dclchain`
31-
32-
TODO: provide tests for error cases
3330
*/
3431

32+
//nolint:funlen
3533
func TestCompliancetestDemo(t *testing.T) {
3634
// Register new Vendor account
3735
vendor := utils.CreateNewAccount(auth.AccountRoles{auth.Vendor}, testconstants.VID)
@@ -51,11 +49,13 @@ func TestCompliancetestDemo(t *testing.T) {
5149
_, _ = utils.AddModelVersion(modelVersion, vendor)
5250

5351
// Publish first testing result using Sign and Broadcast AddTestingResult message
54-
firstTestingResult := utils.NewMsgAddTestingResult(model.VID, model.PID, modelVersion.SoftwareVersion, modelVersion.SoftwareVersionString, testHouse.Address)
52+
firstTestingResult := utils.NewMsgAddTestingResult(model.VID, model.PID,
53+
modelVersion.SoftwareVersion, modelVersion.SoftwareVersionString, testHouse.Address)
5554
utils.SignAndBroadcastMessage(testHouse, firstTestingResult)
5655

5756
// Check testing result is created
58-
receivedTestingResult, _ := utils.GetTestingResult(firstTestingResult.VID, firstTestingResult.PID, firstTestingResult.SoftwareVersion)
57+
receivedTestingResult, _ := utils.GetTestingResult(firstTestingResult.VID,
58+
firstTestingResult.PID, firstTestingResult.SoftwareVersion)
5959
require.Equal(t, receivedTestingResult.VID, firstTestingResult.VID)
6060
require.Equal(t, receivedTestingResult.PID, firstTestingResult.PID)
6161
require.Equal(t, receivedTestingResult.SoftwareVersion, firstTestingResult.SoftwareVersion)
@@ -78,7 +78,8 @@ func TestCompliancetestDemo(t *testing.T) {
7878
_, _ = utils.PublishTestingResult(secondTestingResult, testHouse)
7979

8080
// Check testing result is created
81-
receivedTestingResult, _ = utils.GetTestingResult(secondTestingResult.VID, secondTestingResult.PID, secondTestingResult.SoftwareVersion)
81+
receivedTestingResult, _ = utils.GetTestingResult(secondTestingResult.VID,
82+
secondTestingResult.PID, secondTestingResult.SoftwareVersion)
8283
require.Equal(t, receivedTestingResult.VID, secondTestingResult.VID)
8384
require.Equal(t, receivedTestingResult.PID, secondTestingResult.PID)
8485
require.Equal(t, receivedTestingResult.SoftwareVersion, secondTestingResult.SoftwareVersion)
@@ -93,7 +94,8 @@ func TestCompliancetestDemo(t *testing.T) {
9394
_, _ = utils.PublishTestingResult(thirdTestingResult, secondTestHouse)
9495

9596
// Check testing result is created
96-
receivedTestingResult, _ = utils.GetTestingResult(secondTestingResult.VID, secondTestingResult.PID, secondTestingResult.SoftwareVersion)
97+
receivedTestingResult, _ = utils.GetTestingResult(secondTestingResult.VID,
98+
secondTestingResult.PID, secondTestingResult.SoftwareVersion)
9799
require.Equal(t, 2, len(receivedTestingResult.Results))
98100
require.Equal(t, receivedTestingResult.Results[0].Owner, secondTestingResult.Signer)
99101
require.Equal(t, receivedTestingResult.Results[0].TestResult, secondTestingResult.TestResult)

integration_tests/utils/client.go

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func sendRequest(uri string, method string, body []byte, account string, passphr
6868
resp, err := client.Do(req)
6969
if err != nil {
7070
fmt.Printf("Error received from server: %v", err)
71+
7172
return nil, http.StatusInternalServerError
7273
}
7374

integration_tests/utils/requests.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func GetKeyInfo(accountName string) (KeyInfo, int) {
6868
return keyInfo, code
6969
}
7070

71-
func ProposeAddAccount(keyInfo KeyInfo, signer KeyInfo, roles auth.AccountRoles, vendorId uint16) (TxnResponse, int) {
71+
func ProposeAddAccount(keyInfo KeyInfo, signer KeyInfo, roles auth.AccountRoles, vendorID uint16) (TxnResponse, int) {
7272
println("Propose Add Account for: ", keyInfo.Name)
7373

7474
request := authRest.ProposeAddAccountRequest{
@@ -79,7 +79,7 @@ func ProposeAddAccount(keyInfo KeyInfo, signer KeyInfo, roles auth.AccountRoles,
7979
Address: keyInfo.Address,
8080
Pubkey: keyInfo.PublicKey,
8181
Roles: roles,
82-
VendorId: vendorId,
82+
VendorID: vendorID,
8383
}
8484

8585
body, _ := codec.MarshalJSONIndent(app.MakeCodec(), request)
@@ -201,7 +201,7 @@ func GetProposedAccountsToRevoke() (ProposedAccountToRevokeHeadersResult, int) {
201201
return result, code
202202
}
203203

204-
func CreateNewAccount(roles auth.AccountRoles, vendorId uint16) KeyInfo {
204+
func CreateNewAccount(roles auth.AccountRoles, vendorID uint16) KeyInfo {
205205
name := RandString()
206206
println("Register new account on the ledger: ", name)
207207

@@ -210,7 +210,7 @@ func CreateNewAccount(roles auth.AccountRoles, vendorId uint16) KeyInfo {
210210

211211
keyInfo, _ := CreateKey(name)
212212

213-
ProposeAddAccount(keyInfo, jackKeyInfo, roles, vendorId)
213+
ProposeAddAccount(keyInfo, jackKeyInfo, roles, vendorID)
214214
ApproveAddAccount(keyInfo, aliceKeyInfo)
215215

216216
return keyInfo
@@ -540,7 +540,8 @@ func SendCertifiedModelRequest(certifyModel compliance.MsgCertifyModel, name str
540540
body, _ := codec.MarshalJSONIndent(app.MakeCodec(), request)
541541

542542
uri := fmt.Sprintf("%s/%v/%v/%v/%v/%v/%v", compliance.RouterKey, compliance.Certified,
543-
certifyModel.VID, certifyModel.PID, certifyModel.SoftwareVersion, certifyModel.SoftwareVersionString, certifyModel.CertificationType)
543+
certifyModel.VID, certifyModel.PID, certifyModel.SoftwareVersion,
544+
certifyModel.SoftwareVersionString, certifyModel.CertificationType)
544545

545546
return SendPutRequest(uri, body, name, constants.Passphrase)
546547
}
@@ -613,7 +614,8 @@ func getComplianceInfo(vid uint16, pid uint16, softwareVersion uint32,
613614
}
614615

615616
func getComplianceInfoInState(vid uint16, pid uint16, softwareVersion uint32,
616-
certificationType compliance.CertificationType, state compliance.ComplianceState) (compliance.ComplianceInfoInState, int) {
617+
certificationType compliance.CertificationType,
618+
state compliance.ComplianceState) (compliance.ComplianceInfoInState, int) {
617619
uri := fmt.Sprintf("%s/%v/%v/%v/%v/%v", compliance.RouterKey, state, vid, pid, softwareVersion, certificationType)
618620

619621
response, code := SendGetRequest(uri)
@@ -1131,7 +1133,8 @@ func InitStartData() (KeyInfo, KeyInfo, model.MsgAddModel, model.MsgAddModelVers
11311133
fmt.Printf("%v, %v", txnResponse, errCode)
11321134

11331135
// Publish model version
1134-
modelVersion := NewMsgAddModelVersion(model.VID, model.PID, constants.SoftwareVersion, constants.SoftwareVersionString, vendor.Address)
1136+
modelVersion := NewMsgAddModelVersion(model.VID, model.PID,
1137+
constants.SoftwareVersion, constants.SoftwareVersionString, vendor.Address)
11351138
txnResponse, errCode = AddModelVersion(modelVersion, vendor)
11361139
fmt.Printf("%v, %v", txnResponse, errCode)
11371140

0 commit comments

Comments
 (0)