ethtest

package
v0.0.0-...-0001d10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMockMethods = map[string]MockMethod{
	"EstimateGas": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return:    []interface{}{uint64(0), nil},
	},
	"NonceAt": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return:    []interface{}{uint64(1), nil},
	},
	"GetCode": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return:    []interface{}{"0x0000000000000000000000000000000000000000", nil},
	},
	"BalanceAt": {
		Arguments: []interface{}{mock.Anything, mock.Anything, mock.Anything},
		Return:    []interface{}{big.NewInt(1), nil},
	},
	"TransactionReceipt": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return: []interface{}{
			&types.Receipt{
				Status:          1,
				ContractAddress: common.HexToAddress("0x0000000000000000000000000000000000000000"),
			}, nil,
		},
	},
	"GetExpiry": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return:    []interface{}{uint64(123456789), nil},
	},
	"GetPublicKey": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return: []interface{}{
			eth.PublicKey{
				Timestamp: 1234,
				PublicKey: "0x6f6704e5a10332af6672e50b3d9754dc460dfa4d",
				Signature: "0x6f6704e5a10332af6672e50b3d9754dc460dfa4d",
			}, nil,
		},
	},
	"SendTransaction": {
		Arguments: []interface{}{mock.Anything, mock.Anything},
		Return: []interface{}{
			eth.SendTransactionResponse{
				Status: 1,
				Output: "0x73756363657373",
				Hash:   "0x00000000000000000000000000000000000000000000000000000000000000000",
			}, nil,
		},
	},
	"SubscribeFilterLogs": {
		Arguments: []interface{}{mock.Anything, mock.Anything, mock.Anything},
		Return: []interface{}{
			&MockSubscription{ErrC: make(chan error)}, nil,
		},
	},
}

Functions

func ImplementMock

func ImplementMock(client *MockClient)

func ImplementMockWithMethods

func ImplementMockWithMethods(client *MockClient, methods MockMethods)

func ImplementMockWithOverwrite

func ImplementMockWithOverwrite(client *MockClient, overwrite MockMethods)

Types

type MockClient

type MockClient struct {
	mock.Mock
}

func (*MockClient) BalanceAt

func (c *MockClient) BalanceAt(
	ctx context.Context,
	address common.Address,
	block *big.Int,
) (*big.Int, error)

func (*MockClient) EstimateGas

func (m *MockClient) EstimateGas(
	ctx context.Context,
	msg ethereum.CallMsg,
) (uint64, error)

func (*MockClient) GetCode

func (m *MockClient) GetCode(
	ctx context.Context,
	addr common.Address,
) (string, error)

func (*MockClient) GetExpiry

func (m *MockClient) GetExpiry(
	ctx context.Context,
	addr common.Address,
) (uint64, error)

func (*MockClient) GetPublicKey

func (m *MockClient) GetPublicKey(
	ctx context.Context,
	addr common.Address,
) (eth.PublicKey, error)

func (*MockClient) NonceAt

func (m *MockClient) NonceAt(
	ctx context.Context,
	addr common.Address,
) (uint64, error)

func (*MockClient) SendTransaction

func (m *MockClient) SendTransaction(
	ctx context.Context,
	tx *types.Transaction,
) (eth.SendTransactionResponse, error)

func (*MockClient) SubscribeFilterLogs

func (m *MockClient) SubscribeFilterLogs(
	ctx context.Context,
	q ethereum.FilterQuery,
	c chan<- types.Log,
) (ethereum.Subscription, error)

func (*MockClient) TransactionReceipt

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

type MockMethod

type MockMethod struct {
	Arguments []interface{}
	Return    []interface{}
	Run       func(mock.Arguments)
}

type MockMethods

type MockMethods map[string]MockMethod

func OverwriteDefaults

func OverwriteDefaults(overwrite MockMethods) MockMethods

type MockSubscription

type MockSubscription struct {
	ErrC chan error
}

func (*MockSubscription) Err

func (s *MockSubscription) Err() <-chan error

func (*MockSubscription) Unsubscribe

func (s *MockSubscription) Unsubscribe()

Jump to

Keyboard shortcuts

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