-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f31b645
commit c0dea35
Showing
6 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//go:build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// keyExistsInKeyring checks if a key with the given name exists in the keyring | ||
// using the `poktrolld keys show <key_name>` CLI subcommand. | ||
func (s *suite) keyExistsInKeyring(keyName string) bool { | ||
s.Helper() | ||
|
||
// poktrolld keys show <key_name> --keyring-backend test | ||
argsAndFlags := []string{ | ||
"keys", | ||
"show", | ||
keyName, | ||
keyRingFlag, | ||
} | ||
res, err := s.pocketd.RunCommand(argsAndFlags...) | ||
if err == nil { | ||
// `keys show <key_name>` will not error if a key with the given name exists. | ||
return true | ||
} | ||
|
||
keyNotExistErrFmt := "%s is not a valid name or address" | ||
if strings.Contains(res.Stderr, fmt.Sprintf(keyNotExistErrFmt, keyName)) { | ||
return false | ||
} | ||
|
||
// If the key doesn't exist & the error message is unexpected, fail the test. | ||
s.Fatal(err) | ||
return false | ||
} | ||
|
||
// addKeyToKeyring adds a new key, with the given name, to the keyring | ||
// using the `poktrolld keys add <key_name>` CLI subcommand. | ||
func (s *suite) addKeyToKeyring(keyName string) { | ||
s.Helper() | ||
|
||
// poktrolld keys add <key_name> --keyring-backend test | ||
argsAndFlags := []string{ | ||
"keys", | ||
"add", | ||
keyName, | ||
keyRingFlag, | ||
} | ||
_, err := s.pocketd.RunCommand(argsAndFlags...) | ||
require.NoError(s, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters