spring cleanup (#5991)

* Make format

* Fix golangci-lint warnings

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Alessio Treglia 2020-04-14 20:13:15 +01:00 committed by GitHub
parent 58a6c4c007
commit aeee097b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 78 additions and 91 deletions

View File

@ -17,7 +17,6 @@ import (
func Test_runMigrateCmd(t *testing.T) {
cmd := AddKeyCommand()
assert.NotNil(t, cmd)
mockIn, _, _ := tests.ApplyMockIO(cmd)
kbHome, kbCleanUp := tests.NewTestCaseDir(t)
copy.Copy("testdata", kbHome)
@ -31,7 +30,7 @@ func Test_runMigrateCmd(t *testing.T) {
viper.Set(flags.FlagDryRun, true)
cmd = MigrateCommand()
mockIn, _, _ = tests.ApplyMockIO(cmd)
mockIn, _, _ := tests.ApplyMockIO(cmd)
mockIn.Reset("test1234\ntest1234\n")
assert.NoError(t, runMigrateCmd(cmd, []string{}))
}

View File

@ -25,7 +25,7 @@ const (
headerType = "type"
)
// Make bcrypt security parameter var, so it can be changed within the lcd test
// BcryptSecurityParameter is security parameter var, and it can be changed within the lcd test.
// Making the bcrypt security parameter a var shouldn't be a security issue:
// One can't verify an invalid key by maliciously changing the bcrypt
// parameter during a runtime vulnerability. The main security

View File

@ -6,11 +6,12 @@ import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/tests"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)
func TestInMemoryCreateLedger(t *testing.T) {

View File

@ -16,7 +16,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/tests"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -43,7 +42,7 @@ func TestNewKeyring(t *testing.T) {
require.Equal(t, "unknown keyring backend fuzzy", err.Error())
mockIn.Reset("password\npassword\n")
info, _, err := kr.NewMnemonic("foo", English, types.FullFundraiserPath, hd.Secp256k1)
info, _, err := kr.NewMnemonic("foo", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
require.Equal(t, "foo", info.GetName())
}
@ -62,17 +61,17 @@ func TestKeyManagementKeyRing(t *testing.T) {
require.Nil(t, err)
require.Empty(t, l)
_, _, err = kb.NewMnemonic(n1, English, types.FullFundraiserPath, notSupportedAlgo{})
_, _, err = kb.NewMnemonic(n1, English, sdk.FullFundraiserPath, notSupportedAlgo{})
require.Error(t, err, "ed25519 keys are currently not supported by keybase")
// create some keys
_, err = kb.Key(n1)
require.Error(t, err)
i, _, err := kb.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
i, _, err := kb.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.NoError(t, err)
require.Equal(t, n1, i.GetName())
_, _, err = kb.NewMnemonic(n2, English, types.FullFundraiserPath, algo)
_, _, err = kb.NewMnemonic(n2, English, sdk.FullFundraiserPath, algo)
require.NoError(t, err)
// we can get these keys
@ -141,10 +140,10 @@ func TestSignVerifyKeyRing(t *testing.T) {
n1, n2, n3 := "some dude", "a dudette", "dude-ish"
// create two users and get their info
i1, _, err := kb.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
i1, _, err := kb.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
i2, _, err := kb.NewMnemonic(n2, English, types.FullFundraiserPath, algo)
i2, _, err := kb.NewMnemonic(n2, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
// let's try to sign some messages
@ -215,7 +214,7 @@ func TestExportImportKeyRing(t *testing.T) {
kb, err := New("keybasename", "test", dir, nil)
require.NoError(t, err)
info, _, err := kb.NewMnemonic("john", English, types.FullFundraiserPath, hd.Secp256k1)
info, _, err := kb.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
require.Equal(t, info.GetName(), "john")
@ -251,7 +250,7 @@ func TestExportImportPubKeyKeyRing(t *testing.T) {
algo := hd.Secp256k1
// CreateMnemonic a private-public key pair and ensure consistency
info, _, err := kb.NewMnemonic("john", English, types.FullFundraiserPath, algo)
info, _, err := kb.NewMnemonic("john", English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
require.NotEqual(t, info, "")
require.Equal(t, info.GetName(), "john")
@ -294,7 +293,7 @@ func TestAdvancedKeyManagementKeyRing(t *testing.T) {
n1, n2 := "old-name", "new name"
// make sure key works with initial password
_, _, err = kb.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
_, _, err = kb.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err, "%+v", err)
_, err = kb.ExportPubKeyArmor(n1 + ".notreal")
@ -329,7 +328,7 @@ func TestSeedPhraseKeyRing(t *testing.T) {
n1, n2 := "lost-key", "found-again"
// make sure key works with initial password
info, mnemonic, err := kb.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
info, mnemonic, err := kb.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err, "%+v", err)
require.Equal(t, n1, info.GetName())
require.NotEmpty(t, mnemonic)
@ -356,7 +355,7 @@ func TestKeyringKeybaseExportImportPrivKey(t *testing.T) {
kb, err := New("keybasename", "test", dir, nil)
require.NoError(t, err)
_, _, err = kb.NewMnemonic("john", English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = kb.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
keystr, err := kb.ExportPrivKeyArmor("john", "somepassword")
@ -383,7 +382,7 @@ func TestKeyringKeybaseExportImportPrivKey(t *testing.T) {
func TestInMemoryLanguage(t *testing.T) {
kb := NewInMemory()
_, _, err := kb.NewMnemonic("something", Japanese, types.FullFundraiserPath, hd.Secp256k1)
_, _, err := kb.NewMnemonic("something", Japanese, sdk.FullFundraiserPath, hd.Secp256k1)
require.Error(t, err)
require.Equal(t, "unsupported language: only english is supported", err.Error())
}
@ -422,17 +421,17 @@ func TestInMemoryKeyManagement(t *testing.T) {
require.Nil(t, err)
require.Empty(t, l)
_, _, err = cstore.NewMnemonic(n1, English, types.FullFundraiserPath, notSupportedAlgo{})
_, _, err = cstore.NewMnemonic(n1, English, sdk.FullFundraiserPath, notSupportedAlgo{})
require.Error(t, err, "ed25519 keys are currently not supported by keybase")
// create some keys
_, err = cstore.Key(n1)
require.Error(t, err)
i, _, err := cstore.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
i, _, err := cstore.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.NoError(t, err)
require.Equal(t, n1, i.GetName())
_, _, err = cstore.NewMnemonic(n2, English, types.FullFundraiserPath, algo)
_, _, err = cstore.NewMnemonic(n2, English, sdk.FullFundraiserPath, algo)
require.NoError(t, err)
// we can get these keys
@ -502,10 +501,10 @@ func TestInMemorySignVerify(t *testing.T) {
n1, n2, n3 := "some dude", "a dudette", "dude-ish"
// create two users and get their info
i1, _, err := cstore.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
i1, _, err := cstore.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
i2, _, err := cstore.NewMnemonic(n2, English, types.FullFundraiserPath, algo)
i2, _, err := cstore.NewMnemonic(n2, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
// let's try to sign some messages
@ -576,7 +575,7 @@ func TestInMemoryExportImport(t *testing.T) {
// make the storage with reasonable defaults
cstore := NewInMemory()
info, _, err := cstore.NewMnemonic("john", English, types.FullFundraiserPath, hd.Secp256k1)
info, _, err := cstore.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
require.Equal(t, info.GetName(), "john")
@ -606,7 +605,7 @@ func TestInMemoryExportImport(t *testing.T) {
func TestInMemoryExportImportPrivKey(t *testing.T) {
kb := NewInMemory()
info, _, err := kb.NewMnemonic("john", English, types.FullFundraiserPath, hd.Secp256k1)
info, _, err := kb.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
require.Equal(t, info.GetName(), "john")
priv1, err := kb.Key("john")
@ -634,7 +633,7 @@ func TestInMemoryExportImportPubKey(t *testing.T) {
cstore := NewInMemory()
// CreateMnemonic a private-public key pair and ensure consistency
info, _, err := cstore.NewMnemonic("john", English, types.FullFundraiserPath, hd.Secp256k1)
info, _, err := cstore.NewMnemonic("john", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.Nil(t, err)
require.NotEqual(t, info, "")
require.Equal(t, info.GetName(), "john")
@ -673,7 +672,7 @@ func TestInMemoryAdvancedKeyManagement(t *testing.T) {
n1, n2 := "old-name", "new name"
// make sure key works with initial password
_, _, err := cstore.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
_, _, err := cstore.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err, "%+v", err)
// exporting requires the proper name and passphrase
@ -708,7 +707,7 @@ func TestInMemorySeedPhrase(t *testing.T) {
n1, n2 := "lost-key", "found-again"
// make sure key works with initial password
info, mnemonic, err := cstore.NewMnemonic(n1, English, types.FullFundraiserPath, algo)
info, mnemonic, err := cstore.NewMnemonic(n1, English, sdk.FullFundraiserPath, algo)
require.Nil(t, err, "%+v", err)
require.Equal(t, n1, info.GetName())
require.NotEmpty(t, mnemonic)
@ -758,7 +757,7 @@ func ExampleNew() {
sec := hd.Secp256k1
// Add keys and see they return in alphabetical order
bob, _, err := cstore.NewMnemonic("Bob", English, types.FullFundraiserPath, sec)
bob, _, err := cstore.NewMnemonic("Bob", English, sdk.FullFundraiserPath, sec)
if err != nil {
// this should never happen
fmt.Println(err)
@ -766,8 +765,8 @@ func ExampleNew() {
// return info here just like in List
fmt.Println(bob.GetName())
}
_, _, _ = cstore.NewMnemonic("Alice", English, types.FullFundraiserPath, sec)
_, _, _ = cstore.NewMnemonic("Carl", English, types.FullFundraiserPath, sec)
_, _, _ = cstore.NewMnemonic("Alice", English, sdk.FullFundraiserPath, sec)
_, _, _ = cstore.NewMnemonic("Carl", English, sdk.FullFundraiserPath, sec)
info, _ := cstore.List()
for _, i := range info {
fmt.Println(i.GetName())
@ -813,16 +812,16 @@ func TestAltKeyring_List(t *testing.T) {
require.Empty(t, list)
// Fails on creating unsupported pubKeyType
_, _, err = keyring.NewMnemonic("failing", English, types.FullFundraiserPath, notSupportedAlgo{})
_, _, err = keyring.NewMnemonic("failing", English, sdk.FullFundraiserPath, notSupportedAlgo{})
require.EqualError(t, err, ErrUnsupportedSigningAlgo.Error())
// Create 3 keys
uid1, uid2, uid3 := "Zkey", "Bkey", "Rkey"
_, _, err = keyring.NewMnemonic(uid1, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid1, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
_, _, err = keyring.NewMnemonic(uid2, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid2, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
_, _, err = keyring.NewMnemonic(uid3, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid3, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
list, err = keyring.List()
@ -872,7 +871,7 @@ func TestAltKeyring_Get(t *testing.T) {
require.NoError(t, err)
uid := someKey
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
key, err := keyring.Key(uid)
@ -888,7 +887,7 @@ func TestAltKeyring_KeyByAddress(t *testing.T) {
require.NoError(t, err)
uid := someKey
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
key, err := keyring.KeyByAddress(mnemonic.GetAddress())
@ -904,7 +903,7 @@ func TestAltKeyring_Delete(t *testing.T) {
require.NoError(t, err)
uid := someKey
_, _, err = keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
list, err := keyring.List()
@ -927,7 +926,7 @@ func TestAltKeyring_DeleteByAddress(t *testing.T) {
require.NoError(t, err)
uid := someKey
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
list, err := keyring.List()
@ -975,9 +974,9 @@ func TestAltKeyring_SaveMultisig(t *testing.T) {
keyring, err := New(t.Name(), BackendTest, dir, nil)
require.NoError(t, err)
mnemonic1, _, err := keyring.NewMnemonic("key1", English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic1, _, err := keyring.NewMnemonic("key1", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
mnemonic2, _, err := keyring.NewMnemonic("key2", English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic2, _, err := keyring.NewMnemonic("key2", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
key := "multi"
@ -1001,7 +1000,7 @@ func TestAltKeyring_Sign(t *testing.T) {
require.NoError(t, err)
uid := "jack"
_, _, err = keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
msg := []byte("some message")
@ -1020,7 +1019,7 @@ func TestAltKeyring_SignByAddress(t *testing.T) {
require.NoError(t, err)
uid := "jack"
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
msg := []byte("some message")
@ -1039,7 +1038,7 @@ func TestAltKeyring_ImportExportPrivKey(t *testing.T) {
require.NoError(t, err)
uid := theID
_, _, err = keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
passphrase := "somePass"
@ -1068,7 +1067,7 @@ func TestAltKeyring_ImportExportPrivKey_ByAddress(t *testing.T) {
require.NoError(t, err)
uid := theID
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
passphrase := "somePass"
@ -1098,7 +1097,7 @@ func TestAltKeyring_ImportExportPubKey(t *testing.T) {
require.NoError(t, err)
uid := theID
_, _, err = keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
armor, err := keyring.ExportPubKeyArmor(uid)
@ -1123,7 +1122,7 @@ func TestAltKeyring_ImportExportPubKey_ByAddress(t *testing.T) {
require.NoError(t, err)
uid := theID
mnemonic, _, err := keyring.NewMnemonic(uid, English, types.FullFundraiserPath, hd.Secp256k1)
mnemonic, _, err := keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
armor, err := keyring.ExportPubKeyArmorByAddress(mnemonic.GetAddress())
@ -1148,11 +1147,11 @@ func TestAltKeyring_ConstructorSupportedAlgos(t *testing.T) {
require.NoError(t, err)
// should fail when using unsupported signing algorythm.
_, _, err = keyring.NewMnemonic("test", English, types.FullFundraiserPath, notSupportedAlgo{})
_, _, err = keyring.NewMnemonic("test", English, sdk.FullFundraiserPath, notSupportedAlgo{})
require.EqualError(t, err, "unsupported signing algo")
// but works with default signing algo.
_, _, err = keyring.NewMnemonic("test", English, types.FullFundraiserPath, hd.Secp256k1)
_, _, err = keyring.NewMnemonic("test", English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
// but we can create a new keybase with our provided algos.
@ -1167,7 +1166,7 @@ func TestAltKeyring_ConstructorSupportedAlgos(t *testing.T) {
require.NoError(t, err)
// now this new keyring does not fail when signing with provided algo
_, _, err = keyring2.NewMnemonic("test", English, types.FullFundraiserPath, notSupportedAlgo{})
_, _, err = keyring2.NewMnemonic("test", English, sdk.FullFundraiserPath, notSupportedAlgo{})
require.NoError(t, err)
}

View File

@ -5,7 +5,6 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -14,7 +13,7 @@ import (
// phrase to recover the private key.
func GenerateCoinKey() (sdk.AccAddress, string, error) {
// generate a private key, with recovery phrase
info, secret, err := keyring.NewInMemory().NewMnemonic("name", keyring.English, types.FullFundraiserPath, hd.Secp256k1)
info, secret, err := keyring.NewInMemory().NewMnemonic("name", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1)
if err != nil {
return sdk.AccAddress([]byte{}), "", err
}
@ -45,7 +44,7 @@ func GenerateSaveCoinKey(keybase keyring.Keyring, keyName, keyPass string, overw
}
}
info, secret, err := keybase.NewMnemonic(keyName, keyring.English, types.FullFundraiserPath, hd.Secp256k1)
info, secret, err := keybase.NewMnemonic(keyName, keyring.English, sdk.FullFundraiserPath, hd.Secp256k1)
if err != nil {
return sdk.AccAddress([]byte{}), "", err
}

View File

@ -34,17 +34,6 @@ const (
FlagUnsafeSkipUpgrades = "unsafe-skip-upgrades"
)
var (
errPruningWithGranularOptions = fmt.Errorf(
"'--%s' flag is not compatible with granular options '--%s' or '--%s'",
flagPruning, flagPruningKeepEvery, flagPruningSnapshotEvery,
)
errPruningGranularOptions = fmt.Errorf(
"'--%s' and '--%s' must be set together",
flagPruningSnapshotEvery, flagPruningKeepEvery,
)
)
// StartCmd runs the service passed in, either stand-alone or in-process with
// Tendermint.
func StartCmd(ctx *Context, appCreator AppCreator) *cobra.Command {

View File

@ -151,7 +151,7 @@ func TestContextWithCustom(t *testing.T) {
require.Equal(t, cp, ctx.WithConsensusParams(cp).ConsensusParams())
// test inner context
newContext := context.WithValue(ctx.Context(), "key", "value") //nolint:golint
newContext := context.WithValue(ctx.Context(), "key", "value") //nolint:golint,staticcheck
require.NotEqual(t, ctx.Context(), ctx.WithContext(newContext).Context())
}

View File

@ -237,7 +237,7 @@ func TestReadRESTReq(t *testing.T) {
// test OK
rest.ReadRESTReq(w, req, codec.New(), &br)
res := w.Result()
res := w.Result() //nolint:bodyclose
t.Cleanup(func() { res.Body.Close() })
require.Equal(t, rest.BaseReq{ChainID: "alessio", Memo: "text"}, br)
require.Equal(t, http.StatusOK, res.StatusCode)
@ -249,7 +249,7 @@ func TestReadRESTReq(t *testing.T) {
w = httptest.NewRecorder()
rest.ReadRESTReq(w, req, codec.New(), &br)
require.Equal(t, br, br)
res = w.Result()
res = w.Result() //nolint:bodyclose
t.Cleanup(func() { res.Body.Close() })
require.Equal(t, http.StatusBadRequest, res.StatusCode)
}
@ -258,7 +258,7 @@ func TestWriteSimulationResponse(t *testing.T) {
t.Parallel()
w := httptest.NewRecorder()
rest.WriteSimulationResponse(w, codec.New(), 10)
res := w.Result()
res := w.Result() //nolint:bodyclose
t.Cleanup(func() { res.Body.Close() })
require.Equal(t, http.StatusOK, res.StatusCode)
bs, err := ioutil.ReadAll(res.Body)
@ -272,12 +272,12 @@ func TestParseUint64OrReturnBadRequest(t *testing.T) {
w := httptest.NewRecorder()
_, ok := rest.ParseUint64OrReturnBadRequest(w, "100")
require.True(t, ok)
require.Equal(t, http.StatusOK, w.Result().StatusCode)
require.Equal(t, http.StatusOK, w.Result().StatusCode) //nolint:bodyclose
w = httptest.NewRecorder()
_, ok = rest.ParseUint64OrReturnBadRequest(w, "-100")
require.False(t, ok)
require.Equal(t, http.StatusBadRequest, w.Result().StatusCode)
require.Equal(t, http.StatusBadRequest, w.Result().StatusCode) //nolint:bodyclose
}
func TestParseFloat64OrReturnBadRequest(t *testing.T) {
@ -285,18 +285,18 @@ func TestParseFloat64OrReturnBadRequest(t *testing.T) {
w := httptest.NewRecorder()
_, ok := rest.ParseFloat64OrReturnBadRequest(w, "100", 0)
require.True(t, ok)
require.Equal(t, http.StatusOK, w.Result().StatusCode)
require.Equal(t, http.StatusOK, w.Result().StatusCode) //nolint:bodyclose
w = httptest.NewRecorder()
_, ok = rest.ParseFloat64OrReturnBadRequest(w, "bad request", 0)
require.False(t, ok)
require.Equal(t, http.StatusBadRequest, w.Result().StatusCode)
require.Equal(t, http.StatusBadRequest, w.Result().StatusCode) //nolint:bodyclose
w = httptest.NewRecorder()
ret, ok := rest.ParseFloat64OrReturnBadRequest(w, "", 9.0)
require.Equal(t, float64(9), ret)
require.True(t, ok)
require.Equal(t, http.StatusOK, w.Result().StatusCode)
require.Equal(t, http.StatusOK, w.Result().StatusCode) //nolint:bodyclose
}
func TestParseQueryParamBool(t *testing.T) {
@ -318,7 +318,7 @@ func TestPostProcessResponseBare(t *testing.T) {
rest.PostProcessResponseBare(w, ctx, bs)
res := w.Result()
res := w.Result() //nolint:bodyclose
require.Equal(t, http.StatusOK, res.StatusCode)
got, err := ioutil.ReadAll(res.Body)
@ -337,7 +337,7 @@ func TestPostProcessResponseBare(t *testing.T) {
rest.PostProcessResponseBare(w, ctx, data)
res = w.Result()
res = w.Result() //nolint:bodyclose
require.Equal(t, http.StatusOK, res.StatusCode)
got, err = ioutil.ReadAll(res.Body)
@ -359,7 +359,7 @@ func TestPostProcessResponseBare(t *testing.T) {
rest.PostProcessResponseBare(w, ctx, data)
res = w.Result()
res = w.Result() //nolint:bodyclose
require.Equal(t, http.StatusOK, res.StatusCode)
got, err = ioutil.ReadAll(res.Body)
@ -375,7 +375,7 @@ func TestPostProcessResponseBare(t *testing.T) {
rest.PostProcessResponseBare(w, ctx, data2)
res = w.Result()
res = w.Result() //nolint:bodyclose
require.Equal(t, http.StatusInternalServerError, res.StatusCode)
got, err = ioutil.ReadAll(res.Body)
@ -406,7 +406,7 @@ func runPostProcessResponse(t *testing.T, ctx context.CLIContext, obj interface{
rest.PostProcessResponse(w, ctx, obj)
require.Equal(t, http.StatusOK, w.Code, w.Body)
resp := w.Result()
resp := w.Result() //nolint:bodyclose
t.Cleanup(func() { resp.Body.Close() })
body, err := ioutil.ReadAll(resp.Body)
@ -426,7 +426,7 @@ func runPostProcessResponse(t *testing.T, ctx context.CLIContext, obj interface{
rest.PostProcessResponse(w, ctx, marshalled)
require.Equal(t, http.StatusOK, w.Code, w.Body)
resp = w.Result()
resp = w.Result() //nolint:bodyclose
t.Cleanup(func() { resp.Body.Close() })
body, err = ioutil.ReadAll(resp.Body)

View File

@ -4,9 +4,10 @@ package cli
import (
"bufio"
"fmt"
"github.com/cosmos/cosmos-sdk/client/tx"
"strings"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cobra"
"github.com/spf13/viper"

View File

@ -1,9 +1,10 @@
package rest
import (
"net/http"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"net/http"
"github.com/gorilla/mux"

View File

@ -1,9 +1,10 @@
package rest
import (
"net/http"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"net/http"
"github.com/gorilla/mux"

View File

@ -21,7 +21,7 @@ func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) {
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/open-confirm", RestPortID, RestChannelID), channelOpenConfirmHandlerFn(cliCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/close-init", RestPortID, RestChannelID), channelCloseInitHandlerFn(cliCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/close-confirm", RestPortID, RestChannelID), channelCloseConfirmHandlerFn(cliCtx)).Methods("POST")
r.HandleFunc(fmt.Sprintf("/ibc/packets/receive"), recvPacketHandlerFn(cliCtx)).Methods("POST")
r.HandleFunc("/ibc/packets/receive", recvPacketHandlerFn(cliCtx)).Methods("POST")
}
// channelOpenInitHandlerFn implements a channel open init handler

View File

@ -14,7 +14,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
@ -287,7 +286,7 @@ func (chain *TestChain) createConnection(
// nolint: unused
func (chain *TestChain) createChannel(
portID, channelID, counterpartyPortID, counterpartyChannelID string,
state channelexported.State, order exported.Order, connectionID string,
state channelexported.State, order channelexported.Order, connectionID string,
) channeltypes.Channel {
counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID)
channel := channeltypes.NewChannel(state, order, counterparty,

View File

@ -15,7 +15,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
@ -259,7 +258,7 @@ func (chain *TestChain) createConnection(
func (chain *TestChain) createChannel(
portID, channelID, counterpartyPortID, counterpartyChannelID string,
state channelexported.State, order exported.Order, connectionID string,
state channelexported.State, order channelexported.Order, connectionID string,
) channeltypes.Channel {
counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID)
channel := channeltypes.NewChannel(state, order, counterparty,

View File

@ -16,7 +16,6 @@ import (
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
@ -332,7 +331,7 @@ func (chain *TestChain) createConnection(
func (chain *TestChain) createChannel(
portID, channelID, counterpartyPortID, counterpartyChannelID string,
state channelexported.State, order exported.Order, connectionID string,
state channelexported.State, order channelexported.Order, connectionID string,
) channeltypes.Channel {
counterparty := channeltypes.NewCounterparty(counterpartyPortID, counterpartyChannelID)
channel := channeltypes.NewChannel(state, order, counterparty,

View File

@ -1,6 +1,6 @@
package types
// the one key to use for the keeper store
// MinterKey is the key to use for the keeper store.
var MinterKey = []byte{0x00}
// nolint

View File

@ -6,5 +6,5 @@ import (
"github.com/cosmos/cosmos-sdk/x/params/client/rest"
)
// param change proposal handler
// ProposalHandler is the param change proposal handler.
var ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler)

View File

@ -16,7 +16,7 @@ func NewCodec(amino *codec.Codec) *Codec {
return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino}
}
// module codec
// ModuleCdc is the module codec.
var ModuleCdc *Codec
func init() {