Add key recover test (#7183)
Add missing tests, see #7049. Closes: #7179
This commit is contained in:
parent
23a9f46aad
commit
f652ba4288
|
@ -79,4 +79,35 @@ func Test_runAddCmdBasic(t *testing.T) {
|
|||
})
|
||||
|
||||
require.NoError(t, cmd.Execute())
|
||||
|
||||
// In recovery mode
|
||||
cmd.SetArgs([]string{
|
||||
"keyname6",
|
||||
fmt.Sprintf("--%s=true", flagRecover),
|
||||
})
|
||||
|
||||
// use valid mnemonic and complete recovery key generation successfully
|
||||
mockIn.Reset("decide praise business actor peasant farm drastic weather extend front hurt later song give verb rhythm worry fun pond reform school tumble august one\n")
|
||||
require.NoError(t, cmd.Execute())
|
||||
|
||||
// use invalid mnemonic and fail recovery key generation
|
||||
mockIn.Reset("invalid mnemonic\n")
|
||||
require.Error(t, cmd.Execute())
|
||||
|
||||
// In interactive mode
|
||||
cmd.SetArgs([]string{
|
||||
"keyname7",
|
||||
"-i",
|
||||
fmt.Sprintf("--%s=false", flagRecover),
|
||||
})
|
||||
|
||||
const password = "password1!"
|
||||
|
||||
// set password and complete interactive key generation successfully
|
||||
mockIn.Reset("\n" + password + "\n" + password + "\n")
|
||||
require.NoError(t, cmd.Execute())
|
||||
|
||||
// passwords don't match and fail interactive key generation
|
||||
mockIn.Reset("\n" + password + "\n" + "fail" + "\n")
|
||||
require.Error(t, cmd.Execute())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue