testdelegation

package
v0.0.0-...-3dee9c1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package testdelegation provides helper functions for constructing real (e.g. localnet) and mock DelegationClient objects with pre-configured and/or parameterised call arguments, return value(s), and/or expectations thereof. Intended for use in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnyTimeLastNRedelegationsClient

func NewAnyTimeLastNRedelegationsClient(
	t *testing.T,
	appAddress string,
) *mockclient.MockDelegationClient

NewAnyTimeLastNRedelegationsClient creates a mock DelegationClient that expects calls to the LastNRedelegations method any number of times. When the LastNRedelegations method is called, it returns a mock Redelegation with the provided appAddress.

func NewAnyTimesRedelegation

func NewAnyTimesRedelegation(
	t *testing.T,
	appAddress string,
	gatewayAddress string,
) *mockclient.MockRedelegation

NewAnyTimesRedelegation creates a mock Redelegation that expects calls to the AppAddress method any number of times. When the method is called, it returns the provided app address.

func NewAnyTimesRedelegationsSequence

func NewAnyTimesRedelegationsSequence(
	ctx context.Context,
	t *testing.T,
	appAddress string,
	redelegationObs observable.Observable[client.Redelegation],
) *mockclient.MockDelegationClient

NewAnyTimesRedelegationsSequence creates a new mock DelegationClient. This mock DelegationClient will expect any number of calls to RedelegationsSequence, and when that call is made, it returns the given EventsObservable[Redelegation].

func NewLocalnetClient

func NewLocalnetClient(ctx context.Context, t *testing.T) client.DelegationClient

NewLocalnetClient creates and returns a new DelegationClient that's configured for use with the LocalNet validator.

func NewOneTimeRedelegationsSequenceDelegationClient

func NewOneTimeRedelegationsSequenceDelegationClient(
	ctx context.Context,
	t *testing.T,
	redelegationPublishCh chan client.Redelegation,
) *mockclient.MockDelegationClient

NewOneTimeRedelegationsSequenceDelegationClient creates a new mock DelegationClient. This mock DelegationClient will expect a call to RedelegationsSequence, and when that call is made, it returns a new RedelegationReplayObservable that publishes Redelegation events sent on the given redelegationPublishCh. redelegationPublishCh is the channel the caller can use to publish Redelegation events to the observable.

func NewRedelegationEventBytes

func NewRedelegationEventBytes(
	t *testing.T,
	appAddress string,
	gatewayAddress string,
) []byte

NewRedelegationEventBytes returns a byte slice containing a JSON string that mocks the event bytes returned from the events query client for a Redelegation event.

Types

This section is empty.

Jump to

Keyboard shortcuts

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