mock

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnapshotterMock

type SnapshotterMock struct {
	// CreateSnapshotFunc mocks the CreateSnapshot method.
	CreateSnapshotFunc func(ctx sdk.Context, threshold utils.Threshold) (snapshot.Snapshot, error)

	// GetOperatorFunc mocks the GetOperator method.
	GetOperatorFunc func(ctx sdk.Context, proxy sdk.AccAddress) sdk.ValAddress
	// contains filtered or unexported fields
}

SnapshotterMock is a mock implementation of keeper.Snapshotter.

func TestSomethingThatUsesSnapshotter(t *testing.T) {

	// make and configure a mocked keeper.Snapshotter
	mockedSnapshotter := &SnapshotterMock{
		CreateSnapshotFunc: func(ctx sdk.Context, threshold utils.Threshold) (snapshot.Snapshot, error) {
			panic("mock out the CreateSnapshot method")
		},
		GetOperatorFunc: func(ctx sdk.Context, proxy sdk.AccAddress) sdk.ValAddress {
			panic("mock out the GetOperator method")
		},
	}

	// use mockedSnapshotter in code that requires keeper.Snapshotter
	// and then make assertions.

}

func (*SnapshotterMock) CreateSnapshot

func (mock *SnapshotterMock) CreateSnapshot(ctx sdk.Context, threshold utils.Threshold) (snapshot.Snapshot, error)

CreateSnapshot calls CreateSnapshotFunc.

func (*SnapshotterMock) CreateSnapshotCalls

func (mock *SnapshotterMock) CreateSnapshotCalls() []struct {
	Ctx       sdk.Context
	Threshold utils.Threshold
}

CreateSnapshotCalls gets all the calls that were made to CreateSnapshot. Check the length with:

len(mockedSnapshotter.CreateSnapshotCalls())

func (*SnapshotterMock) GetOperator

func (mock *SnapshotterMock) GetOperator(ctx sdk.Context, proxy sdk.AccAddress) sdk.ValAddress

GetOperator calls GetOperatorFunc.

func (*SnapshotterMock) GetOperatorCalls

func (mock *SnapshotterMock) GetOperatorCalls() []struct {
	Ctx   sdk.Context
	Proxy sdk.AccAddress
}

GetOperatorCalls gets all the calls that were made to GetOperator. Check the length with:

len(mockedSnapshotter.GetOperatorCalls())

Jump to

Keyboard shortcuts

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