mock

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 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 {
	// BlockByNumberFunc mocks the BlockByNumber method.
	BlockByNumberFunc func(ctx context.Context, number *big.Int) (*types.Block, error)

	// BlockNumberFunc mocks the BlockNumber method.
	BlockNumberFunc func(ctx context.Context) (uint64, error)

	// CloseFunc mocks the Close method.
	CloseFunc func()

	// TransactionByHashFunc mocks the TransactionByHash method.
	TransactionByHashFunc func(ctx context.Context, hash common.Hash) (*types.Transaction, 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{
		BlockByNumberFunc: func(ctx context.Context, number *big.Int) (*types.Block, error) {
			panic("mock out the BlockByNumber method")
		},
		BlockNumberFunc: func(ctx context.Context) (uint64, error) {
			panic("mock out the BlockNumber method")
		},
		CloseFunc: func()  {
			panic("mock out the Close method")
		},
		TransactionByHashFunc: func(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) {
			panic("mock out the TransactionByHash 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) BlockByNumber

func (mock *ClientMock) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

BlockByNumber calls BlockByNumberFunc.

func (*ClientMock) BlockByNumberCalls

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

BlockByNumberCalls gets all the calls that were made to BlockByNumber. Check the length with:

len(mockedClient.BlockByNumberCalls())

func (*ClientMock) BlockNumber

func (mock *ClientMock) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber calls BlockNumberFunc.

func (*ClientMock) BlockNumberCalls

func (mock *ClientMock) BlockNumberCalls() []struct {
	Ctx context.Context
}

BlockNumberCalls gets all the calls that were made to BlockNumber. Check the length with:

len(mockedClient.BlockNumberCalls())

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) TransactionByHash

func (mock *ClientMock) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)

TransactionByHash calls TransactionByHashFunc.

func (*ClientMock) TransactionByHashCalls

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

TransactionByHashCalls gets all the calls that were made to TransactionByHash. Check the length with:

len(mockedClient.TransactionByHashCalls())

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())

type MoonbeamClientMock

type MoonbeamClientMock struct {
	// BlockByNumberFunc mocks the BlockByNumber method.
	BlockByNumberFunc func(ctx context.Context, number *big.Int) (*types.Block, error)

	// BlockNumberFunc mocks the BlockNumber method.
	BlockNumberFunc func(ctx context.Context) (uint64, error)

	// ChainGetFinalizedHeadFunc mocks the ChainGetFinalizedHead method.
	ChainGetFinalizedHeadFunc func(ctx context.Context) (common.Hash, error)

	// ChainGetHeaderFunc mocks the ChainGetHeader method.
	ChainGetHeaderFunc func(ctx context.Context, hash common.Hash) (*rpc.MoonbeamHeader, error)

	// CloseFunc mocks the Close method.
	CloseFunc func()

	// TransactionByHashFunc mocks the TransactionByHash method.
	TransactionByHashFunc func(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)

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

MoonbeamClientMock is a mock implementation of rpc.MoonbeamClient.

func TestSomethingThatUsesMoonbeamClient(t *testing.T) {

	// make and configure a mocked rpc.MoonbeamClient
	mockedMoonbeamClient := &MoonbeamClientMock{
		BlockByNumberFunc: func(ctx context.Context, number *big.Int) (*types.Block, error) {
			panic("mock out the BlockByNumber method")
		},
		BlockNumberFunc: func(ctx context.Context) (uint64, error) {
			panic("mock out the BlockNumber method")
		},
		ChainGetFinalizedHeadFunc: func(ctx context.Context) (common.Hash, error) {
			panic("mock out the ChainGetFinalizedHead method")
		},
		ChainGetHeaderFunc: func(ctx context.Context, hash common.Hash) (*rpc.MoonbeamHeader, error) {
			panic("mock out the ChainGetHeader method")
		},
		CloseFunc: func()  {
			panic("mock out the Close method")
		},
		TransactionByHashFunc: func(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error) {
			panic("mock out the TransactionByHash method")
		},
		TransactionReceiptFunc: func(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
			panic("mock out the TransactionReceipt method")
		},
	}

	// use mockedMoonbeamClient in code that requires rpc.MoonbeamClient
	// and then make assertions.

}

func (*MoonbeamClientMock) BlockByNumber

func (mock *MoonbeamClientMock) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

BlockByNumber calls BlockByNumberFunc.

func (*MoonbeamClientMock) BlockByNumberCalls

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

BlockByNumberCalls gets all the calls that were made to BlockByNumber. Check the length with:

len(mockedMoonbeamClient.BlockByNumberCalls())

func (*MoonbeamClientMock) BlockNumber

func (mock *MoonbeamClientMock) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber calls BlockNumberFunc.

func (*MoonbeamClientMock) BlockNumberCalls

func (mock *MoonbeamClientMock) BlockNumberCalls() []struct {
	Ctx context.Context
}

BlockNumberCalls gets all the calls that were made to BlockNumber. Check the length with:

len(mockedMoonbeamClient.BlockNumberCalls())

func (*MoonbeamClientMock) ChainGetFinalizedHead

func (mock *MoonbeamClientMock) ChainGetFinalizedHead(ctx context.Context) (common.Hash, error)

ChainGetFinalizedHead calls ChainGetFinalizedHeadFunc.

func (*MoonbeamClientMock) ChainGetFinalizedHeadCalls

func (mock *MoonbeamClientMock) ChainGetFinalizedHeadCalls() []struct {
	Ctx context.Context
}

ChainGetFinalizedHeadCalls gets all the calls that were made to ChainGetFinalizedHead. Check the length with:

len(mockedMoonbeamClient.ChainGetFinalizedHeadCalls())

func (*MoonbeamClientMock) ChainGetHeader

func (mock *MoonbeamClientMock) ChainGetHeader(ctx context.Context, hash common.Hash) (*rpc.MoonbeamHeader, error)

ChainGetHeader calls ChainGetHeaderFunc.

func (*MoonbeamClientMock) ChainGetHeaderCalls

func (mock *MoonbeamClientMock) ChainGetHeaderCalls() []struct {
	Ctx  context.Context
	Hash common.Hash
}

ChainGetHeaderCalls gets all the calls that were made to ChainGetHeader. Check the length with:

len(mockedMoonbeamClient.ChainGetHeaderCalls())

func (*MoonbeamClientMock) Close

func (mock *MoonbeamClientMock) Close()

Close calls CloseFunc.

func (*MoonbeamClientMock) CloseCalls

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

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

len(mockedMoonbeamClient.CloseCalls())

func (*MoonbeamClientMock) TransactionByHash

func (mock *MoonbeamClientMock) TransactionByHash(ctx context.Context, hash common.Hash) (*types.Transaction, bool, error)

TransactionByHash calls TransactionByHashFunc.

func (*MoonbeamClientMock) TransactionByHashCalls

func (mock *MoonbeamClientMock) TransactionByHashCalls() []struct {
	Ctx  context.Context
	Hash common.Hash
}

TransactionByHashCalls gets all the calls that were made to TransactionByHash. Check the length with:

len(mockedMoonbeamClient.TransactionByHashCalls())

func (*MoonbeamClientMock) TransactionReceipt

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

TransactionReceipt calls TransactionReceiptFunc.

func (*MoonbeamClientMock) TransactionReceiptCalls

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

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

len(mockedMoonbeamClient.TransactionReceiptCalls())

Jump to

Keyboard shortcuts

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