mock

package
v0.26.5 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientMock

type ClientMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func()

	// HeaderByNumberFunc mocks the HeaderByNumber method.
	HeaderByNumberFunc func(ctx context.Context, number *big.Int) (*rpc.Header, error)

	// IsFinalizedFunc mocks the IsFinalized method.
	IsFinalizedFunc func(ctx context.Context, conf uint64, txReceipt *types.Receipt) (bool, error)

	// TransactionReceiptFunc mocks the TransactionReceipt method.
	TransactionReceiptFunc func(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of rpc.Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked rpc.Client
	mockedClient := &ClientMock{
		CloseFunc: func()  {
			panic("mock out the Close method")
		},
		HeaderByNumberFunc: func(ctx context.Context, number *big.Int) (*rpc.Header, error) {
			panic("mock out the HeaderByNumber method")
		},
		IsFinalizedFunc: func(ctx context.Context, conf uint64, txReceipt *types.Receipt) (bool, error) {
			panic("mock out the IsFinalized method")
		},
		TransactionReceiptFunc: func(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
			panic("mock out the TransactionReceipt method")
		},
	}

	// use mockedClient in code that requires rpc.Client
	// and then make assertions.

}

func (*ClientMock) Close

func (mock *ClientMock) Close()

Close calls CloseFunc.

func (*ClientMock) CloseCalls

func (mock *ClientMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedClient.CloseCalls())

func (*ClientMock) HeaderByNumber added in v0.26.4

func (mock *ClientMock) HeaderByNumber(ctx context.Context, number *big.Int) (*rpc.Header, error)

HeaderByNumber calls HeaderByNumberFunc.

func (*ClientMock) HeaderByNumberCalls added in v0.26.4

func (mock *ClientMock) HeaderByNumberCalls() []struct {
	Ctx    context.Context
	Number *big.Int
}

HeaderByNumberCalls gets all the calls that were made to HeaderByNumber. Check the length with:

len(mockedClient.HeaderByNumberCalls())

func (*ClientMock) IsFinalized added in v0.26.4

func (mock *ClientMock) IsFinalized(ctx context.Context, conf uint64, txReceipt *types.Receipt) (bool, error)

IsFinalized calls IsFinalizedFunc.

func (*ClientMock) IsFinalizedCalls added in v0.26.4

func (mock *ClientMock) IsFinalizedCalls() []struct {
	Ctx       context.Context
	Conf      uint64
	TxReceipt *types.Receipt
}

IsFinalizedCalls gets all the calls that were made to IsFinalized. Check the length with:

len(mockedClient.IsFinalizedCalls())

func (*ClientMock) TransactionReceipt

func (mock *ClientMock) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt calls TransactionReceiptFunc.

func (*ClientMock) TransactionReceiptCalls

func (mock *ClientMock) TransactionReceiptCalls() []struct {
	Ctx    context.Context
	TxHash common.Hash
}

TransactionReceiptCalls gets all the calls that were made to TransactionReceipt. Check the length with:

len(mockedClient.TransactionReceiptCalls())

Jump to

Keyboard shortcuts

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