testutils

package
v25.0.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(fixed, toCheck FailureFlag) bool

Types

type ApproveOn

type ApproveOn int
const (
	Always ApproveOn = iota
	Never
)

type FailureFlag

type FailureFlag = uint8
const (
	AUTHENTICATE_FAIL FailureFlag = 1 << iota
	CONFIRM_EXECUTION_FAIL
)

type LatestCalls

type LatestCalls struct {
	Authenticate           authenticator.AuthenticationRequest
	Track                  SpyTrackRequest
	ConfirmExecution       authenticator.AuthenticationRequest
	OnAuthenticatorAdded   SpyAddRequest
	OnAuthenticatorRemoved SpyRemoveRequest
}

type MaxAmountAuthenticator

type MaxAmountAuthenticator struct {
	KvStoreKey storetypes.StoreKey
}

func (MaxAmountAuthenticator) Authenticate

func (MaxAmountAuthenticator) ConfirmExecution

func (MaxAmountAuthenticator) GetAmount

func (m MaxAmountAuthenticator) GetAmount(ctx sdk.Context) osmomath.Int

func (MaxAmountAuthenticator) Initialize

func (m MaxAmountAuthenticator) Initialize(config []byte) (authenticator.Authenticator, error)

func (MaxAmountAuthenticator) OnAuthenticatorAdded

func (m MaxAmountAuthenticator) OnAuthenticatorAdded(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (MaxAmountAuthenticator) OnAuthenticatorRemoved

func (m MaxAmountAuthenticator) OnAuthenticatorRemoved(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (MaxAmountAuthenticator) SetAmount

func (m MaxAmountAuthenticator) SetAmount(ctx sdk.Context, amount osmomath.Int)

The following methods for MaxAmountAuthenticator are similar to the set and get value methods for StatefulAuthenticator but set and get an int

func (MaxAmountAuthenticator) StaticGas

func (m MaxAmountAuthenticator) StaticGas() uint64

func (MaxAmountAuthenticator) Track

func (MaxAmountAuthenticator) Type

func (m MaxAmountAuthenticator) Type() string

type MaxAmountAuthenticatorData

type MaxAmountAuthenticatorData struct {
	Amount osmomath.Int
}

type SpyAddRequest

type SpyAddRequest struct {
	Account         sdk.AccAddress `json:"account"`
	Data            []byte         `json:"data"`
	AuthenticatorId string         `json:"authenticator_id"`
}

type SpyAuthenticator

type SpyAuthenticator struct {
	KvStoreKey storetypes.StoreKey
	Name       string
	Failure    FailureFlag
}

SpyAuthenticator tracks latest call and can be used to test the authenticator

func NewSpyAuthenticator

func NewSpyAuthenticator(kvStoreKey storetypes.StoreKey) SpyAuthenticator

func (SpyAuthenticator) Authenticate

func (SpyAuthenticator) ConfirmExecution

func (s SpyAuthenticator) ConfirmExecution(ctx sdk.Context, request authenticator.AuthenticationRequest) error

func (SpyAuthenticator) GetLatestCalls

func (s SpyAuthenticator) GetLatestCalls(ctx sdk.Context) LatestCalls

func (SpyAuthenticator) Initialize

func (s SpyAuthenticator) Initialize(config []byte) (authenticator.Authenticator, error)

func (SpyAuthenticator) OnAuthenticatorAdded

func (s SpyAuthenticator) OnAuthenticatorAdded(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (SpyAuthenticator) OnAuthenticatorRemoved

func (s SpyAuthenticator) OnAuthenticatorRemoved(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (SpyAuthenticator) ResetLatestCalls

func (s SpyAuthenticator) ResetLatestCalls(ctx sdk.Context)

func (SpyAuthenticator) StaticGas

func (s SpyAuthenticator) StaticGas() uint64

func (SpyAuthenticator) Track

func (SpyAuthenticator) Type

func (s SpyAuthenticator) Type() string

func (SpyAuthenticator) UpdateLatestCalls

func (s SpyAuthenticator) UpdateLatestCalls(ctx sdk.Context, f func(calls LatestCalls) LatestCalls) LatestCalls

type SpyAuthenticatorData

type SpyAuthenticatorData struct {
	Name    string      `json:"name"`
	Failure FailureFlag `json:"failure"` // bit flag representing authenticator failure
}

type SpyRemoveRequest

type SpyRemoveRequest struct {
	Account         sdk.AccAddress `json:"account"`
	Data            []byte         `json:"data"`
	AuthenticatorId string         `json:"authenticator_id"`
}

type SpyTrackRequest

type SpyTrackRequest struct {
	AuthenticatorId string                 `json:"authenticator_id"`
	Account         sdk.AccAddress         `json:"account"`
	Msg             authenticator.LocalAny `json:"msg"`
	MsgIndex        uint64                 `json:"msg_index"`
}

type StatefulAuthenticator

type StatefulAuthenticator struct {
	KvStoreKey storetypes.StoreKey
}

StatefulAuthenticator is an experiment of how to write authenticators that handle state

func (StatefulAuthenticator) Authenticate

func (StatefulAuthenticator) ConfirmExecution

func (s StatefulAuthenticator) ConfirmExecution(ctx sdk.Context, request authenticator.AuthenticationRequest) error

func (StatefulAuthenticator) GetValue

func (s StatefulAuthenticator) GetValue(ctx sdk.Context) int

func (StatefulAuthenticator) Initialize

func (s StatefulAuthenticator) Initialize(config []byte) (authenticator.Authenticator, error)

func (StatefulAuthenticator) OnAuthenticatorAdded

func (s StatefulAuthenticator) OnAuthenticatorAdded(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (StatefulAuthenticator) OnAuthenticatorRemoved

func (s StatefulAuthenticator) OnAuthenticatorRemoved(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (StatefulAuthenticator) SetValue

func (s StatefulAuthenticator) SetValue(ctx sdk.Context, value int)

func (StatefulAuthenticator) StaticGas

func (s StatefulAuthenticator) StaticGas() uint64

func (StatefulAuthenticator) Track

func (StatefulAuthenticator) Type

func (s StatefulAuthenticator) Type() string

type StatefulAuthenticatorData

type StatefulAuthenticatorData struct {
	Value int
}

type TestingAuthenticator

type TestingAuthenticator struct {
	Approve        ApproveOn
	GasConsumption int
	BlockAddition  bool
	BlockRemoval   bool
	Confirm        ApproveOn
}

func (TestingAuthenticator) Authenticate

func (TestingAuthenticator) ConfirmExecution

func (t TestingAuthenticator) ConfirmExecution(ctx sdk.Context, request authenticator.AuthenticationRequest) error

func (TestingAuthenticator) Initialize

func (t TestingAuthenticator) Initialize(config []byte) (authenticator.Authenticator, error)

func (TestingAuthenticator) OnAuthenticatorAdded

func (t TestingAuthenticator) OnAuthenticatorAdded(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (TestingAuthenticator) OnAuthenticatorRemoved

func (t TestingAuthenticator) OnAuthenticatorRemoved(ctx sdk.Context, account sdk.AccAddress, config []byte, authenticatorId string) error

func (TestingAuthenticator) StaticGas

func (t TestingAuthenticator) StaticGas() uint64

func (TestingAuthenticator) Track

func (TestingAuthenticator) Type

func (t TestingAuthenticator) Type() string

type TestingAuthenticatorData

type TestingAuthenticatorData struct{}

Jump to

Keyboard shortcuts

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