testutils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: AGPL-3.0, Apache-2.0 Imports: 9 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           SpyAuthenticateRequest
	Track                  SpyTrackRequest
	ConfirmExecution       SpyConfirmExecutionRequest
	OnAuthenticatorAdded   SpyAddRequest
	OnAuthenticatorRemoved SpyRemoveRequest
}

type SpyAddRequest

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

type SpyAuthenticateRequest

type SpyAuthenticateRequest struct {
	AuthenticatorId string         `json:"authenticator_id"`
	Account         sdk.AccAddress `json:"account"`
	Msg             []byte         `json:"msg"`
	MsgIndex        uint64         `json:"msg_index"`
}

type SpyAuthenticator

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

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

func NewSpyAuthenticator

func NewSpyAuthenticator(cdc codec.BinaryCodec, kvStoreKey storetypes.StoreKey) SpyAuthenticator

func (SpyAuthenticator) Authenticate

func (s SpyAuthenticator) Authenticate(ctx sdk.Context, request types.AuthenticationRequest) error

func (SpyAuthenticator) ConfirmExecution

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

func (SpyAuthenticator) GetLatestCalls

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

func (SpyAuthenticator) Initialize

func (s SpyAuthenticator) Initialize(config []byte) (types.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 SpyConfirmExecutionRequest

type SpyConfirmExecutionRequest struct {
	AuthenticatorId string         `json:"authenticator_id"`
	Account         sdk.AccAddress `json:"account"`
	Msg             []byte         `json:"msg"`
	MsgIndex        uint64         `json:"msg_index"`
}

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             []byte         `json:"msg"`
	MsgIndex        uint64         `json:"msg_index"`
}

type TestingAuthenticator

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

func (TestingAuthenticator) Authenticate

func (t TestingAuthenticator) Authenticate(ctx sdk.Context, request types.AuthenticationRequest) error

func (TestingAuthenticator) ConfirmExecution

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

func (TestingAuthenticator) Initialize

func (t TestingAuthenticator) Initialize(config []byte) (types.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