laconicd/keys/show_test.go
Austin Abell 72fc3ca3af
Transaction signing and encoding (#95)
* WIP setting up evm tx command and updating emint keys output

* Fix linting issue

* Wip restructuring to allow for ethereum signing and encoding

* WIP setting up keybase and context to use Ethermint keys

* Fixed encoding and decoding of emint keys

* Adds command for generating explicit ethereum tx

* Fixed evm route for handling tx

* Fixed tx and msg encoding which allows transactions to be sent

* Added relevant documentation for changes and cleaned up code

* Added documentation and indicators why code was overriden
2019-09-15 12:12:59 -04:00

52 lines
1.4 KiB
Go

package keys
import (
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/tests"
)
func TestShowKeysCmd(t *testing.T) {
cmd := showKeysCmd()
assert.NotNil(t, cmd)
assert.Equal(t, "false", cmd.Flag(FlagAddress).DefValue)
assert.Equal(t, "false", cmd.Flag(FlagPublicKey).DefValue)
}
func TestRunShowCmd(t *testing.T) {
cmd := showKeysCmd()
err := runShowCmd(cmd, []string{"invalid"})
assert.EqualError(t, err, "Key invalid not found")
// Prepare a key base
// Now add a temporary keybase
kbHome, cleanUp := tests.NewTestCaseDir(t)
defer cleanUp()
viper.Set(flags.FlagHome, kbHome)
fakeKeyName1 := "runShowCmd_Key1"
fakeKeyName2 := "runShowCmd_Key2"
kb, err := NewKeyBaseFromHomeFlag()
assert.NoError(t, err)
_, err = kb.CreateAccount(fakeKeyName1, tests.TestMnemonic, "", "", 0, 0)
assert.NoError(t, err)
_, err = kb.CreateAccount(fakeKeyName2, tests.TestMnemonic, "", "", 0, 1)
assert.NoError(t, err)
// // Now try single key
// err = runShowCmd(cmd, []string{fakeKeyName1})
// assert.EqualError(t, err, "invalid Bech32 prefix encoding provided: ")
// // Now try single key - set bech to acc
// viper.Set(FlagBechPrefix, sdk.PrefixAccount)
err = runShowCmd(cmd, []string{fakeKeyName1})
assert.NoError(t, err)
err = runShowCmd(cmd, []string{fakeKeyName2})
assert.NoError(t, err)
}