From 370b5ba06e3ee5c9e308a8ab8dd21a738acd0394 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 29 Aug 2022 02:43:55 +0000 Subject: [PATCH] Lint --- cli_test/cli_test.go | 31 ++++++++++++++++++++----------- cmd/lbm/cmd/root.go | 4 ++-- cmd/lbm/cmd/testnet.go | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 51e32fbd..2b8bc29f 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -554,13 +554,15 @@ func TestLBMSubmitProposal(t *testing.T) { // Query the vote vote := f.QueryGovVote(1, fooAddr) require.Equal(t, uint64(1), vote.ProposalId) - require.Equal(t, gov.OptionYes, vote.Option) + require.Equal(t, 1, len(vote.Options)) + require.Equal(t, gov.OptionYes, vote.Options[0].Option) // Query the votes votes := f.QueryGovVotes(1) require.Len(t, votes.GetVotes(), 1) require.Equal(t, uint64(1), votes.GetVotes()[0].ProposalId) - require.Equal(t, gov.OptionYes, votes.GetVotes()[0].Option) + require.Equal(t, 1, len(votes.GetVotes()[0].Options)) + require.Equal(t, gov.OptionYes, votes.GetVotes()[0].Options[0].Option) // Ensure tags are applied to voting transaction properly searchResult = f.QueryTxs(1, 50, fmt.Sprintf("--events='message.action=%s&message.sender=%s'", sdk.MsgTypeURL(&gov.MsgVote{}), fooAddr)) @@ -1236,7 +1238,8 @@ func TestLBMWasmContract(t *testing.T) { flagFromFoo := fmt.Sprintf("--from=%s", fooAddr) flagGas := "--gas=auto" flagGasAdjustment := "--gas-adjustment=1.2" - workDir, _ := os.Getwd() + workDir, err := os.Getwd() + require.NoError(t, err) tmpDir := path.Join(workDir, "tmp-dir-for-test-queue") dirContract := path.Join(workDir, "contracts", "queue") hashFile := path.Join(dirContract, "hash.txt") @@ -1251,7 +1254,8 @@ func TestLBMWasmContract(t *testing.T) { enqueueValue := 2 // make tmpDir - os.Mkdir(tmpDir, os.ModePerm) + err = os.Mkdir(tmpDir, os.ModePerm) + require.NoError(t, err) // validate that there are no code in the chain { @@ -1273,8 +1277,9 @@ func TestLBMWasmContract(t *testing.T) { queryCodesResponse := f.QueryListCodeWasm() require.Len(t, queryCodesResponse.CodeInfos, 1) - //validate the hash is the same - expectedRow, _ := ioutil.ReadFile(hashFile) + // validate the hash is the same + expectedRow, err := ioutil.ReadFile(hashFile) + require.NoError(t, err) expected, err := hex.DecodeString(string(expectedRow[:64])) require.NoError(t, err) actual := queryCodesResponse.CodeInfos[0].DataHash.Bytes() @@ -1285,14 +1290,18 @@ func TestLBMWasmContract(t *testing.T) { { outputPath := path.Join(tmpDir, "queue-tmp.wasm") f.QueryCodeWasm(codeID, outputPath) - fLocal, _ := os.Open(wasmQueue) - fChain, _ := os.Open(outputPath) + fLocal, err := os.Open(wasmQueue) + require.NoError(t, err) + fChain, err := os.Open(outputPath) + require.NoError(t, err) // 2000000 is enough length dataLocal := make([]byte, 2000000) dataChain := make([]byte, 2000000) - fLocal.Read(dataLocal) - fChain.Read(dataChain) + _, err = fLocal.Read(dataLocal) + require.NoError(t, err) + _, err = fChain.Read(dataChain) + require.NoError(t, err) require.Equal(t, dataLocal, dataChain) } @@ -1304,7 +1313,7 @@ func TestLBMWasmContract(t *testing.T) { // instantiate a contract with the code queue { - msgJSON := fmt.Sprintf("{}") + msgJSON := "{}" flagLabel := "--label=queue-test" flagAmount := fmt.Sprintf("--amount=%d%s", amountSend, denomSend) _, err := f.TxInstantiateWasm(codeID, msgJSON, flagFromFoo, flagGasAdjustment, flagGas, flagLabel, flagAmount, flagFromFoo, "-y", "--no-admin") diff --git a/cmd/lbm/cmd/root.go b/cmd/lbm/cmd/root.go index 3d95dbfc..7cfa4ff8 100644 --- a/cmd/lbm/cmd/root.go +++ b/cmd/lbm/cmd/root.go @@ -149,8 +149,8 @@ lru_size = 0` func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { // Todo This is applied to https://github.com/cosmos/cosmos-sdk/pull/9299. // But it is failed in `make localnet-start`. Let's check it later. - //cfg := sdk.GetConfig() - //cfg.Seal() + // cfg := sdk.GetConfig() + // cfg.Seal() rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), diff --git a/cmd/lbm/cmd/testnet.go b/cmd/lbm/cmd/testnet.go index 6e49bb67..5607c75a 100644 --- a/cmd/lbm/cmd/testnet.go +++ b/cmd/lbm/cmd/testnet.go @@ -384,7 +384,7 @@ func calculateIP(ip string, i int) (string, error) { } func writeFile(name string, dir string, contents []byte) error { - writePath := filepath.Join(dir) + writePath := dir file := filepath.Join(writePath, name) err := ostos.EnsureDir(writePath, 0755)