package crypto import ( "strings" "testing" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/tests" sdk "github.com/cosmos/cosmos-sdk/types" ) func TestKeyring(t *testing.T) { dir, cleanup := tests.NewTestCaseDir(t) mockIn := strings.NewReader("") t.Cleanup(cleanup) kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, EthSeckp256k1Option) require.NoError(t, err) // fail in retrieving key info, err := kr.Key("foo") require.Error(t, err) require.Nil(t, info) mockIn.Reset("password\npassword\n") info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, sdk.FullFundraiserPath, Secp256k1) require.NoError(t, err) require.NotEmpty(t, mnemonic) require.Equal(t, "foo", info.GetName()) require.Equal(t, "local", info.GetType().String()) require.Equal(t, EthSecp256k1Type, info.GetAlgo()) }