test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package test provides helper and setup functions to test the sr25519 wallet.

Index

Constants

This section is empty.

Variables

View Source
var AccountsCfg []byte

Functions

func NewAddressZero

func NewAddressZero() *sr25519.Address

NewAddressZero returns a zero address that is strictly smaller than all other addresses.

func ZeroPK

func ZeroPK() *schnorrkel.PublicKey

ZeroPK returns a PK that can be used to create a zero address.

Types

type DevAccount

type DevAccount struct {
	Acc                wallet.Account
	Seed, Id, Msg, Sig Hex
	Addr               []SS58Addr
}

DevAccount contains an account for testing and developing which is funded by the substrate node.

func LoadDevAccounts

func LoadDevAccounts(t *testing.T) []*DevAccount

LoadDevAccounts loads all dev accounts by assuming that the config file is in the passed directory.

type Hex

type Hex []byte

Hex allows hexadecimal strings to be decoded by the go JSON lib.

func (*Hex) UnmarshalJSON

func (s *Hex) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls a Hex string from a byte slice.

type Randomizer

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

Randomizer implements the wallet/test.Randomizer interface.

func NewRandomizer

func NewRandomizer() *Randomizer

NewRandomizer returns a new Randomizer.

func (*Randomizer) NewRandomAddress

func (*Randomizer) NewRandomAddress(rng *rand.Rand) pwallet.Address

NewRandomAddress samples a random address from the passed entropy source.

func (*Randomizer) NewWallet

func (*Randomizer) NewWallet() ptest.Wallet

NewWallet returns a new wallet.

func (*Randomizer) RandomWallet

func (r *Randomizer) RandomWallet() ptest.Wallet

RandomWallet returns the random wallet of the Randomizer.

type SS58Addr

type SS58Addr struct {
	Value   string
	Network substrate.NetworkID
}

SS58Addr contains an address and a network id.

type Wallet

type Wallet struct {
	*sr25519.Wallet
}

Wallet is used for testing and implements the Wallet interface.

func NewWallet

func NewWallet() *Wallet

NewWallet returns a new Wallet.

func (*Wallet) NewRandomAccount

func (w *Wallet) NewRandomAccount(rng *rand.Rand) pwallet.Account

NewRandomAccount samples a random account from the passed entropy source. Imports the account into the wallet and returns it.

Jump to

Keyboard shortcuts

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