Fix various linter warnings (#5824)
This commit is contained in:
parent
a84e02f390
commit
3db39cda3c
|
@ -66,7 +66,7 @@ func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error)
|
|||
// If the input is not recognized, it returns false and a nil error.
|
||||
func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) {
|
||||
if inputIsTty() {
|
||||
fmt.Print(fmt.Sprintf("%s [y/N]: ", prompt))
|
||||
fmt.Printf("%s [y/N]: ", prompt)
|
||||
}
|
||||
|
||||
response, err := readLineFromBuf(buf)
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/tendermint/crypto/bcrypt"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
||||
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
|
||||
|
||||
|
@ -569,7 +568,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
saltBytes := crypto.CRandBytes(16)
|
||||
saltBytes := tmcrypto.CRandBytes(16)
|
||||
passwordHash, err := bcrypt.GenerateFromPassword(saltBytes, []byte(pass), 2)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
|
|
@ -408,6 +408,6 @@ func TestSupportedAlgos(t *testing.T) {
|
|||
t.Cleanup(cleanup)
|
||||
kb, err := NewKeyring("keybasename", "test", dir, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []SigningAlgo([]SigningAlgo{"secp256k1"}), kb.SupportedAlgos())
|
||||
require.Equal(t, []SigningAlgo([]SigningAlgo{"secp256k1"}), kb.SupportedAlgosLedger())
|
||||
require.Equal(t, []SigningAlgo{"secp256k1"}, kb.SupportedAlgos())
|
||||
require.Equal(t, []SigningAlgo{"secp256k1"}, kb.SupportedAlgosLedger())
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) {
|
|||
|
||||
// wrong key type
|
||||
armored = mintkey.ArmorPubKeyBytes(priv.PubKey().Bytes(), "")
|
||||
decrypted, algo, err = mintkey.UnarmorDecryptPrivKey(armored, "passphrase")
|
||||
_, _, err = mintkey.UnarmorDecryptPrivKey(armored, "passphrase")
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "unrecognized armor type")
|
||||
|
||||
|
@ -91,6 +91,7 @@ func TestArmorUnarmorPubKey(t *testing.T) {
|
|||
armored, err = cstore.ExportPrivKey("Bob", "passphrase", "alessio")
|
||||
require.NoError(t, err)
|
||||
_, _, err = mintkey.UnarmorPubKeyBytes(armored)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, `couldn't unarmor bytes: unrecognized armor type "TENDERMINT PRIVATE KEY", expected: "TENDERMINT PUBLIC KEY"`, err.Error())
|
||||
|
||||
// armor pubkey manually
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
@ -17,7 +16,7 @@ func Test_writeReadLedgerInfo(t *testing.T) {
|
|||
bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A")
|
||||
copy(tmpKey[:], bz)
|
||||
|
||||
lInfo := newLedgerInfo("some_name", tmpKey, *hd.NewFundraiserParams(5, types.CoinType, 1), Secp256k1)
|
||||
lInfo := newLedgerInfo("some_name", tmpKey, *hd.NewFundraiserParams(5, sdk.CoinType, 1), Secp256k1)
|
||||
assert.Equal(t, TypeLedger, lInfo.GetType())
|
||||
|
||||
path, err := lInfo.GetPath()
|
||||
|
@ -25,7 +24,7 @@ func Test_writeReadLedgerInfo(t *testing.T) {
|
|||
assert.Equal(t, "44'/118'/5'/0/1", path.String())
|
||||
assert.Equal(t,
|
||||
"cosmospub1addwnpepqddddqg2glc8x4fl7vxjlnr7p5a3czm5kcdp4239sg6yqdc4rc2r5wmxv8p",
|
||||
types.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, lInfo.GetPubKey()))
|
||||
sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, lInfo.GetPubKey()))
|
||||
|
||||
// Serialize and restore
|
||||
serialized := marshalInfo(lInfo)
|
||||
|
|
|
@ -2,7 +2,6 @@ package store
|
|||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/store/types"
|
||||
stypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
)
|
||||
|
||||
// Import cosmos-sdk/types/store.go for convenience.
|
||||
|
@ -27,9 +26,9 @@ type (
|
|||
StoreType = types.StoreType
|
||||
Queryable = types.Queryable
|
||||
TraceContext = types.TraceContext
|
||||
Gas = stypes.Gas
|
||||
Gas = types.Gas
|
||||
GasMeter = types.GasMeter
|
||||
GasConfig = stypes.GasConfig
|
||||
GasConfig = types.GasConfig
|
||||
)
|
||||
|
||||
// nolint - reexport
|
||||
|
|
|
@ -179,8 +179,8 @@ func TestManager_InitGenesis(t *testing.T) {
|
|||
genesisData = map[string]json.RawMessage{
|
||||
"module1": json.RawMessage(`{"key": "value"}`),
|
||||
"module2": json.RawMessage(`{"key": "value"}`)}
|
||||
mockAppModule1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module1"])).Times(1).Return([]abci.ValidatorUpdate{abci.ValidatorUpdate{}})
|
||||
mockAppModule2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module2"])).Times(1).Return([]abci.ValidatorUpdate{abci.ValidatorUpdate{}})
|
||||
mockAppModule1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module1"])).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
mockAppModule2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module2"])).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
require.Panics(t, func() { mm.InitGenesis(ctx, cdc, genesisData) })
|
||||
}
|
||||
|
||||
|
@ -239,13 +239,13 @@ func TestManager_EndBlock(t *testing.T) {
|
|||
|
||||
req := abci.RequestEndBlock{Height: 10}
|
||||
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{abci.ValidatorUpdate{}})
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1)
|
||||
ret := mm.EndBlock(sdk.Context{}, req)
|
||||
require.Equal(t, []abci.ValidatorUpdate{abci.ValidatorUpdate{}}, ret.ValidatorUpdates)
|
||||
require.Equal(t, []abci.ValidatorUpdate{{}}, ret.ValidatorUpdates)
|
||||
|
||||
// test panic
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{abci.ValidatorUpdate{}})
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{abci.ValidatorUpdate{}})
|
||||
mockAppModule1.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
mockAppModule2.EXPECT().EndBlock(gomock.Any(), gomock.Eq(req)).Times(1).Return([]abci.ValidatorUpdate{{}})
|
||||
require.Panics(t, func() { mm.EndBlock(sdk.Context{}, req) })
|
||||
}
|
||||
|
|
|
@ -235,8 +235,9 @@ func TestReadRESTReq(t *testing.T) {
|
|||
|
||||
// test OK
|
||||
ReadRESTReq(w, req, codec.New(), &br)
|
||||
require.Equal(t, BaseReq{ChainID: "alessio", Memo: "text"}, br)
|
||||
res := w.Result()
|
||||
t.Cleanup(func() { res.Body.Close() })
|
||||
require.Equal(t, BaseReq{ChainID: "alessio", Memo: "text"}, br)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
|
||||
// test non valid JSON
|
||||
|
@ -247,6 +248,7 @@ func TestReadRESTReq(t *testing.T) {
|
|||
ReadRESTReq(w, req, codec.New(), &br)
|
||||
require.Equal(t, br, br)
|
||||
res = w.Result()
|
||||
t.Cleanup(func() { res.Body.Close() })
|
||||
require.Equal(t, http.StatusBadRequest, res.StatusCode)
|
||||
}
|
||||
|
||||
|
@ -255,6 +257,7 @@ func TestWriteSimulationResponse(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
WriteSimulationResponse(w, codec.New(), 10)
|
||||
res := w.Result()
|
||||
t.Cleanup(func() { res.Body.Close() })
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
bs, err := ioutil.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
@ -361,13 +364,13 @@ func TestPostProcessResponseBare(t *testing.T) {
|
|||
got, err = ioutil.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { res.Body.Close() })
|
||||
require.Equal(t, []string([]string{"application/json"}), res.Header["Content-Type"])
|
||||
require.Equal(t, []string{"application/json"}, res.Header["Content-Type"])
|
||||
require.Equal(t, `{"error":"couldn't marshal"}`, string(got))
|
||||
}
|
||||
|
||||
type badJSONMarshaller struct{}
|
||||
|
||||
func (_ badJSONMarshaller) MarshalJSON() ([]byte, error) {
|
||||
func (badJSONMarshaller) MarshalJSON() ([]byte, error) {
|
||||
return nil, errors.New("couldn't marshal")
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ func TestBondStatus(t *testing.T) {
|
|||
require.False(t, sdk.Unbonded.Equal(sdk.Bonded))
|
||||
require.False(t, sdk.Unbonded.Equal(sdk.Unbonding))
|
||||
require.False(t, sdk.Bonded.Equal(sdk.Unbonding))
|
||||
require.Panicsf(t, func() { sdk.BondStatus(0).String() }, "invalid bond status")
|
||||
require.Equal(t, sdk.BondStatusUnbonded, sdk.BondStatus(sdk.Unbonded).String())
|
||||
require.Equal(t, sdk.BondStatusBonded, sdk.BondStatus(sdk.Bonded).String())
|
||||
require.Equal(t, sdk.BondStatusUnbonding, sdk.BondStatus(sdk.Unbonding).String())
|
||||
require.Panicsf(t, func() { _ = sdk.BondStatus(0).String() }, "invalid bond status")
|
||||
require.Equal(t, sdk.BondStatusUnbonded, sdk.Unbonded.String())
|
||||
require.Equal(t, sdk.BondStatusBonded, sdk.Bonded.String())
|
||||
require.Equal(t, sdk.BondStatusUnbonding, sdk.Unbonding.String())
|
||||
}
|
||||
|
||||
func TestTokensToConsensusPower(t *testing.T) {
|
||||
|
|
|
@ -33,10 +33,10 @@ func TestInfo_String(t *testing.T) {
|
|||
BuildTags: "netgo,ledger",
|
||||
GoVersion: "go version go1.14 linux/amd64",
|
||||
}
|
||||
want := fmt.Sprintf(`testapp: 1.0.0
|
||||
want := `testapp: 1.0.0
|
||||
git commit: 1b78457135a4104bc3af97f20654d49e2ea87454
|
||||
build tags: netgo,ledger
|
||||
go version go1.14 linux/amd64`)
|
||||
go version go1.14 linux/amd64`
|
||||
require.Equal(t, want, info.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package ante
|
|||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
err "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
|
@ -68,7 +67,7 @@ func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
|
|||
|
||||
memoLength := len(memoTx.GetMemo())
|
||||
if uint64(memoLength) > params.MaxMemoCharacters {
|
||||
return ctx, err.Wrapf(err.ErrMemoTooLarge,
|
||||
return ctx, sdkerrors.Wrapf(sdkerrors.ErrMemoTooLarge,
|
||||
"maximum number of characters is %d but received %d characters",
|
||||
params.MaxMemoCharacters, memoLength,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue