testkeyring

package
v0.0.0-...-dcdbaa1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreGeneratedAccount

type PreGeneratedAccount struct {
	Address  sdktypes.AccAddress `json:"address"`
	Mnemonic string              `json:"mnemonic"`
}

PreGeneratedAccount holds the address and mnemonic of an account which was pre-generated by the `gen_accounts` package. It is intended to be used ONLY in tests. It is useful for scenarios where it is necessary to know the address of a specific key in a separate context from that of keyring and/or module genesis state construction.

func CreatePreGeneratedKeyringAccounts

func CreatePreGeneratedKeyringAccounts(
	t *testing.T,
	kr keyring.Keyring,
	limit int,
) []*PreGeneratedAccount

CreatePreGeneratedKeyringAccounts uses the mnemonic from limit number of pre-generated accounts to populated the provided keyring, kr. It then returns the pre-generated accounts which were used.

TODO_CONSIDERATION: Returning a new PreGeneratedAccountIterator instead of the slice of accounts could be more idiomatic. It would only contain keys which are known to be in the keyring.

func MustPreGeneratedAccountAtIndex

func MustPreGeneratedAccountAtIndex(index uint32) *PreGeneratedAccount

MustPreGeneratedAccountAtIndex returns the pre-generated account at the given index. It panics on error; i.e. if the index is out of range.

func PreGeneratedAccountAtIndex

func PreGeneratedAccountAtIndex(index uint32) (_ *PreGeneratedAccount, ok bool)

PreGeneratedAccountAtIndex returns the pre-generated account at the given index. It returns nil and false if the index is out of range.

func (*PreGeneratedAccount) Marshal

func (pga *PreGeneratedAccount) Marshal() (string, error)

Marshal returns the base64 and JSON encoded account string.

func (*PreGeneratedAccount) UnmarshalString

func (pga *PreGeneratedAccount) UnmarshalString(encodedAccountStr string) error

UnmarshalString parses the given base64 and JSON encoded account string into the PreGeneratedAccount receiver.

type PreGeneratedAccountIterator

type PreGeneratedAccountIterator struct {
	// contains filtered or unexported fields
}

PreGeneratedAccountIterator is an iterator over the pre-generated accounts. A new iterator populated with existing pre-generated accounts can be created with the PreGeneratedAccounts function. Alternatively, a new iterator can be created with the NewPreGeneratedAccountIterator function, to which a list of pre-generated accounts to be iterated over must be provided.

func NewPreGeneratedAccountIterator

func NewPreGeneratedAccountIterator(accounts ...*PreGeneratedAccount) *PreGeneratedAccountIterator

NewPreGeneratedAccountIterator returns a new PreGeneratedAccountIterator with the given accounts. It is primarily used by the generated code to initially construct the preGeneratedAccounts variable.

func PreGeneratedAccounts

func PreGeneratedAccounts() *PreGeneratedAccountIterator

PreGeneratedAccounts returns a new PreGeneratedAccountIterator with the accounts which were pre-generated by the `gen_accounts` package (i.e. accounts_table.go).

func (*PreGeneratedAccountIterator) Clone

Clone returns a new PreGeneratedAccountIterator with the same accounts as the receiver but with its nextIndex reset to 0.

func (*PreGeneratedAccountIterator) Next

Next returns the next account in the iterator. It is safe to call concurrently and is guaranteed to return a unique account on each call. If the iterator index goes out of range, it returns nil and false.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL