Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjoon-lee committed Oct 16, 2022
1 parent 554fd48 commit 96c160f
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Build (+ generating proto and docs)
run: make build-all
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.30
version: latest

- name: Publish coverage.html as an artifact
uses: actions/upload-artifact@master
Expand Down
2 changes: 1 addition & 1 deletion x/aol/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (suite *aolMsgServerTestSuite) BeforeTest(_, _ string) {

}

func (suite aolMsgServerTestSuite) TestMsgServer() {
func (suite *aolMsgServerTestSuite) TestMsgServer() {
ctx := suite.Ctx
goCtx := sdk.WrapSDKContext(ctx)
aolKeeper := suite.AolKeeper
Expand Down
4 changes: 2 additions & 2 deletions x/aol/keeper/owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestOwnerKeeperTestSuite(t *testing.T) {
suite.Run(t, new(ownerTestSuite))
}

func (suite ownerTestSuite) TestOneOwner() {
func (suite *ownerTestSuite) TestOneOwner() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand All @@ -58,7 +58,7 @@ func (suite ownerTestSuite) TestOneOwner() {
suite.Require().Equal([]aoltypes.Owner{owner}, resultOwners)
}

func (suite ownerTestSuite) TestMultiOwner() {
func (suite *ownerTestSuite) TestMultiOwner() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand Down
4 changes: 2 additions & 2 deletions x/aol/keeper/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestRecordKeeper(t *testing.T) {
suite.Run(t, new(recordTestSuite))
}

func (suite recordTestSuite) TestOneRecord() {
func (suite *recordTestSuite) TestOneRecord() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand Down Expand Up @@ -54,7 +54,7 @@ func (suite recordTestSuite) TestOneRecord() {
suite.Require().Equal([]aoltypes.Record{record}, resultRecords)
}

func (suite recordTestSuite) TestMultiRecord() {
func (suite *recordTestSuite) TestMultiRecord() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand Down
4 changes: 2 additions & 2 deletions x/aol/keeper/topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestTopicKeeperTestSuite(t *testing.T) {
suite.Run(t, new(topicTestSuite))
}

func (suite topicTestSuite) TestOneTopic() {
func (suite *topicTestSuite) TestOneTopic() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand Down Expand Up @@ -58,7 +58,7 @@ func (suite topicTestSuite) TestOneTopic() {
suite.Require().Equal(uint64(0), resultAllTopics[0].TotalWriters)
}

func (suite topicTestSuite) TestMultiTopic() {
func (suite *topicTestSuite) TestMultiTopic() {
ctx := suite.Ctx
aolKeeper := suite.AolKeeper

Expand Down
34 changes: 17 additions & 17 deletions x/did/client/cli/txDID_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func TestTxTestSuite(t *testing.T) {
suite.Run(t, new(txTestSuite))
}

func (suite txTestSuite) AfterTest(_, _ string) {
func (suite *txTestSuite) AfterTest(_, _ string) {
err := os.RemoveAll(baseDir)
suite.Require().NoError(err)
}

func (suite txTestSuite) TestNewMsgCreateDID() {
func (suite *txTestSuite) TestNewMsgCreateDID() {
privKey, _ := crypto.GenSecp256k1PrivKey("", "")
fromAddr, err := sdk.AccAddressFromBech32("panacea154p6kyu9kqgvcmq63w3vpn893ssy6anpu8ykfq")
suite.Require().NoError(err)
Expand All @@ -49,14 +49,14 @@ func (suite txTestSuite) TestNewMsgCreateDID() {
suite.Require().True(ok)
}

func (suite txTestSuite) TestReadBIP39ParamsFrom_NotInteractive() {
func (suite *txTestSuite) TestReadBIP39ParamsFrom_NotInteractive() {
mnemonic, passphrase, err := readBIP39ParamsFrom(false, nil)
suite.Require().NoError(err)
suite.Require().Empty(mnemonic)
suite.Require().Empty(passphrase)
}

func (suite txTestSuite) TestReadBIP39ParamsFrom() {
func (suite *txTestSuite) TestReadBIP39ParamsFrom() {
inputMnemonic := "travel broken word scare punch suggest air behind process gather sick void potato double furnace"
inputPassphrase := "mypasswd"
reader := bufio.NewReader(strings.NewReader(fmt.Sprintf(
Expand All @@ -69,7 +69,7 @@ func (suite txTestSuite) TestReadBIP39ParamsFrom() {
suite.Require().Equal(inputPassphrase, passphrase)
}

func (suite txTestSuite) TestReadBIP39ParamsFrom_EmptyPassphrase() {
func (suite *txTestSuite) TestReadBIP39ParamsFrom_EmptyPassphrase() {
inputMnemonic := "travel broken word scare punch suggest air behind process gather sick void potato double furnace"
reader := bufio.NewReader(strings.NewReader(fmt.Sprintf(
"%s\n\n", inputMnemonic,
Expand All @@ -81,7 +81,7 @@ func (suite txTestSuite) TestReadBIP39ParamsFrom_EmptyPassphrase() {
suite.Require().Equal("", passphrase)
}

func (suite txTestSuite) TestReadBIP39ParamsFrom_PassphraseNotMatched() {
func (suite *txTestSuite) TestReadBIP39ParamsFrom_PassphraseNotMatched() {
inputMnemonic := "travel broken word scare punch suggest air behind process gather sick void potato double furnace"
reader := bufio.NewReader(strings.NewReader(fmt.Sprintf(
"%s\npasswd1\npasswd2\n", inputMnemonic,
Expand All @@ -91,7 +91,7 @@ func (suite txTestSuite) TestReadBIP39ParamsFrom_PassphraseNotMatched() {
suite.Require().Error(err, "passphrases don't match")
}

func (suite txTestSuite) TestReadBIP39ParamsFrom_InvalidMnemonic() {
func (suite *txTestSuite) TestReadBIP39ParamsFrom_InvalidMnemonic() {
inputMnemonic := "travel broken"
reader := bufio.NewReader(strings.NewReader(fmt.Sprintf(
"%s\npasswd1\npasswd1\n", inputMnemonic,
Expand All @@ -101,7 +101,7 @@ func (suite txTestSuite) TestReadBIP39ParamsFrom_InvalidMnemonic() {
suite.Require().Error(err, "invalid mnemonic")
}

func (suite txTestSuite) TestSaveAndGetPrivKeyFromKeyStore() {
func (suite *txTestSuite) TestSaveAndGetPrivKeyFromKeyStore() {
verificationMethodID := "key1"
privKey, _ := crypto.GenSecp256k1PrivKey("", "")

Expand All @@ -114,15 +114,15 @@ func (suite txTestSuite) TestSaveAndGetPrivKeyFromKeyStore() {
suite.Require().Equal(privKey, privKeyLoaded)
}

func (suite txTestSuite) TestReadDIDDocOneContext() {
func (suite *txTestSuite) TestReadDIDDocOneContext() {
suite.testReadDIDDocOneContext("./testdata/did_one_context.json")
}

func (suite txTestSuite) TestReadDIDDocOneContext_W3C() {
func (suite *txTestSuite) TestReadDIDDocOneContext_W3C() {
suite.testReadDIDDocOneContext("./testdata/did_one_context_w3c.json")
}

func (suite txTestSuite) testReadDIDDocOneContext(path string) {
func (suite *txTestSuite) testReadDIDDocOneContext(path string) {
doc, err := readDIDDocFrom(path)
suite.Require().NoError(err)
contexts := *doc.Contexts
Expand All @@ -138,15 +138,15 @@ func (suite txTestSuite) testReadDIDDocOneContext(path string) {
suite.Require().Equal("did:panacea:27FnaDeQZApXhsRZZDARhWYs2nKFaw3p7evGd9zUSrBZ#key1", doc.Authentications[0].GetVerificationMethodId())
}

func (suite txTestSuite) TestReadDIDDocTwoContexts() {
func (suite *txTestSuite) TestReadDIDDocTwoContexts() {
suite.testReadDIDDocTwoContexts("./testdata/did_multi_context.json")
}

func (suite txTestSuite) TestReadDIDDocTwoContexts_W3C() {
func (suite *txTestSuite) TestReadDIDDocTwoContexts_W3C() {
suite.testReadDIDDocTwoContexts("./testdata/did_multi_context_w3c.json")
}

func (suite txTestSuite) testReadDIDDocTwoContexts(path string) {
func (suite *txTestSuite) testReadDIDDocTwoContexts(path string) {
doc, err := readDIDDocFrom(path)

suite.Require().NoError(err)
Expand All @@ -164,15 +164,15 @@ func (suite txTestSuite) testReadDIDDocTwoContexts(path string) {
suite.Require().Equal("did:panacea:27FnaDeQZApXhsRZZDARhWYs2nKFaw3p7evGd9zUSrBZ#key1", doc.Authentications[0].GetVerificationMethodId())
}

func (suite txTestSuite) TestReadDIDDocMultiRelationship() {
func (suite *txTestSuite) TestReadDIDDocMultiRelationship() {
suite.testReadDIDDocMultiRelationship("./testdata/did_multi_authentication.json")
}

func (suite txTestSuite) TestReadDIDDocMultiRelationship_W3C() {
func (suite *txTestSuite) TestReadDIDDocMultiRelationship_W3C() {
suite.testReadDIDDocMultiRelationship("./testdata/did_multi_authentication_w3c.json")
}

func (suite txTestSuite) testReadDIDDocMultiRelationship(path string) {
func (suite *txTestSuite) testReadDIDDocMultiRelationship(path string) {
doc, err := readDIDDocFrom(path)

suite.Require().NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions x/did/client/crypto/keygen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func TestKeygenTestSuite(t *testing.T) {
suite.Run(t, new(keygenTestSuite))
}

func (suite keygenTestSuite) TestGenSecp256k1PrivKey() {
func (suite *keygenTestSuite) TestGenSecp256k1PrivKey() {
privKey, err := crypto.GenSecp256k1PrivKey("", "")
suite.Require().NoError(err)
suite.Require().NotEqual(secp256k1.PrivKey{}, privKey)
}

func (suite keygenTestSuite) TestGenSecp256k1PrivKey_InvalidMnemonic() {
func (suite *keygenTestSuite) TestGenSecp256k1PrivKey_InvalidMnemonic() {
privKey, err := crypto.GenSecp256k1PrivKey("dummy", "")
suite.Require().Error(err, "invalid mnemonic: dummy")
suite.Require().Equal(secp256k1.PrivKey{}, privKey)
Expand Down
16 changes: 8 additions & 8 deletions x/did/client/crypto/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ func TestKeyStoreTestSuite(t *testing.T) {
suite.Run(t, new(keyStoreTestSuite))
}

func (suite keyStoreTestSuite) AfterTest(_, _ string) {
func (suite *keyStoreTestSuite) AfterTest(_, _ string) {
err := os.RemoveAll(baseDir)
suite.Require().NoError(err)
}

// Check if the keystore can decrypt a JSON provided by Web3 Secret Storage Definition
// https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition#test-vectors
func (suite keyStoreTestSuite) TestKeyStore_DecryptWeb3() {
func (suite *keyStoreTestSuite) TestKeyStore_DecryptWeb3() {
ks := newKeyStore(suite)
secret, err := ks.Load("testdata/web3.json", "testpassword")
suite.Require().NoError(err)
suite.Require().Equal("7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d", hex.EncodeToString(secret))
}

func (suite keyStoreTestSuite) TestKeyStore_SaveAndLoad() {
func (suite *keyStoreTestSuite) TestKeyStore_SaveAndLoad() {
ks := newKeyStore(suite)

path, err := ks.Save(address, priv[:], passwd)
Expand All @@ -53,21 +53,21 @@ func (suite keyStoreTestSuite) TestKeyStore_SaveAndLoad() {
suite.Require().Equal(priv[:], secp256k1.PrivKey(loadedPriv))
}

func (suite keyStoreTestSuite) TestKeyStore_Load_WithInvalidPath() {
func (suite *keyStoreTestSuite) TestKeyStore_Load_WithInvalidPath() {
ks := newKeyStore(suite)
path, _ := ks.Save(address, priv[:], passwd)
_, err := ks.Load(path+path, passwd)
suite.Require().Error(err)
}

func (suite keyStoreTestSuite) TestKeyStore_Load_WithInvalidPassword() {
func (suite *keyStoreTestSuite) TestKeyStore_Load_WithInvalidPassword() {
ks := newKeyStore(suite)
path, _ := ks.Save(address, priv[:], passwd)
_, err := ks.Load(path, passwd+passwd)
suite.Require().Error(err)
}

func (suite keyStoreTestSuite) TestKeyStore_LoadByAddress_RecentFile() {
func (suite *keyStoreTestSuite) TestKeyStore_LoadByAddress_RecentFile() {
ks := newKeyStore(suite)
_, err := ks.Save(address, priv[:], passwd)
suite.Require().NoError(err)
Expand All @@ -81,14 +81,14 @@ func (suite keyStoreTestSuite) TestKeyStore_LoadByAddress_RecentFile() {
suite.Require().Equal(newPriv[:], secp256k1.PrivKey(privBytes))
}

func (suite keyStoreTestSuite) TestKeyStore_LoadByAddress_NotExist() {
func (suite *keyStoreTestSuite) TestKeyStore_LoadByAddress_NotExist() {
ks := newKeyStore(suite)
privBytes, err := ks.LoadByAddress(address, passwd)
suite.Require().Error(err)
suite.Require().Nil(privBytes)
}

func newKeyStore(suite keyStoreTestSuite) *crypto.KeyStore {
func newKeyStore(suite *keyStoreTestSuite) *crypto.KeyStore {
ks, err := crypto.NewKeyStore(baseDir)
suite.Require().NoError(err)
suite.Require().NotNil(ks)
Expand Down
6 changes: 3 additions & 3 deletions x/did/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestGenesisTestSuite(t *testing.T) {
suite.Run(t, new(genesisTestSuite))
}

func (suite genesisTestSuite) TestGenesis() {
func (suite *genesisTestSuite) TestGenesis() {
didKeeper := suite.DIDKeeper

// prepare a keeper with some data
Expand Down Expand Up @@ -51,11 +51,11 @@ func (suite genesisTestSuite) TestGenesis() {
suite.Require().Equal(doc2Deactivated, didKeeper.GetDIDDocument(suite.Ctx, did2))
}

func (suite genesisTestSuite) newGenesisKey(did string) string {
func (suite *genesisTestSuite) newGenesisKey(did string) string {
return types.GenesisDIDDocumentKey{DID: did}.Marshal()
}

func (suite genesisTestSuite) newDIDDocumentWithSeq(did string) (types.DIDDocumentWithSeq, crypto.PrivKey) {
func (suite *genesisTestSuite) newDIDDocumentWithSeq(did string) (types.DIDDocumentWithSeq, crypto.PrivKey) {
privKey := secp256k1.GenPrivKey()
pubKey := secp256k1util.PubKeyBytes(secp256k1util.DerivePubKey(privKey))
verificationMethodID := types.NewVerificationMethodID(did, "key1")
Expand Down

0 comments on commit 96c160f

Please sign in to comment.