network

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockchainMock

type BlockchainMock struct {
	// AddBlockFunc mocks the AddBlock method.
	AddBlockFunc func(blockResponse *neighborhood.BlockResponse)

	// BlocksFunc mocks the Blocks method.
	BlocksFunc func() []*neighborhood.BlockResponse

	// CalculateTotalAmountFunc mocks the CalculateTotalAmount method.
	CalculateTotalAmountFunc func(currentTimestamp int64, blockchainAddress string) uint64

	// StartVerificationFunc mocks the StartVerification method.
	StartVerificationFunc func()

	// VerifyFunc mocks the Verify method.
	VerifyFunc func()
	// contains filtered or unexported fields
}

BlockchainMock is a mock implementation of Blockchain.

func TestSomethingThatUsesBlockchain(t *testing.T) {

	// make and configure a mocked Blockchain
	mockedBlockchain := &BlockchainMock{
		AddBlockFunc: func(blockResponse *neighborhood.BlockResponse)  {
			panic("mock out the AddBlock method")
		},
		BlocksFunc: func() []*neighborhood.BlockResponse {
			panic("mock out the Blocks method")
		},
		CalculateTotalAmountFunc: func(currentTimestamp int64, blockchainAddress string) uint64 {
			panic("mock out the CalculateTotalAmount method")
		},
		StartVerificationFunc: func()  {
			panic("mock out the StartVerification method")
		},
		VerifyFunc: func()  {
			panic("mock out the Verify method")
		},
	}

	// use mockedBlockchain in code that requires Blockchain
	// and then make assertions.

}

func (*BlockchainMock) AddBlock

func (mock *BlockchainMock) AddBlock(blockResponse *neighborhood.BlockResponse)

AddBlock calls AddBlockFunc.

func (*BlockchainMock) AddBlockCalls

func (mock *BlockchainMock) AddBlockCalls() []struct {
	BlockResponse *neighborhood.BlockResponse
}

AddBlockCalls gets all the calls that were made to AddBlock. Check the length with:

len(mockedBlockchain.AddBlockCalls())

func (*BlockchainMock) Blocks

func (mock *BlockchainMock) Blocks() []*neighborhood.BlockResponse

Blocks calls BlocksFunc.

func (*BlockchainMock) BlocksCalls

func (mock *BlockchainMock) BlocksCalls() []struct {
}

BlocksCalls gets all the calls that were made to Blocks. Check the length with:

len(mockedBlockchain.BlocksCalls())

func (*BlockchainMock) CalculateTotalAmount

func (mock *BlockchainMock) CalculateTotalAmount(currentTimestamp int64, blockchainAddress string) uint64

CalculateTotalAmount calls CalculateTotalAmountFunc.

func (*BlockchainMock) CalculateTotalAmountCalls

func (mock *BlockchainMock) CalculateTotalAmountCalls() []struct {
	CurrentTimestamp  int64
	BlockchainAddress string
}

CalculateTotalAmountCalls gets all the calls that were made to CalculateTotalAmount. Check the length with:

len(mockedBlockchain.CalculateTotalAmountCalls())

func (*BlockchainMock) StartVerification

func (mock *BlockchainMock) StartVerification()

StartVerification calls StartVerificationFunc.

func (*BlockchainMock) StartVerificationCalls

func (mock *BlockchainMock) StartVerificationCalls() []struct {
}

StartVerificationCalls gets all the calls that were made to StartVerification. Check the length with:

len(mockedBlockchain.StartVerificationCalls())

func (*BlockchainMock) Verify

func (mock *BlockchainMock) Verify()

Verify calls VerifyFunc.

func (*BlockchainMock) VerifyCalls

func (mock *BlockchainMock) VerifyCalls() []struct {
}

VerifyCalls gets all the calls that were made to Verify. Check the length with:

len(mockedBlockchain.VerifyCalls())

type ClientFactoryMock added in v1.0.3

type ClientFactoryMock struct {
	// CreateClientFunc mocks the CreateClient method.
	CreateClientFunc func(ip string, port uint16, target string) (network.Client, error)
	// contains filtered or unexported fields
}

ClientFactoryMock is a mock implementation of ClientFactory.

func TestSomethingThatUsesClientFactory(t *testing.T) {

	// make and configure a mocked ClientFactory
	mockedClientFactory := &ClientFactoryMock{
		CreateClientFunc: func(ip string, port uint16, target string) (Client, error) {
			panic("mock out the CreateClient method")
		},
	}

	// use mockedClientFactory in code that requires ClientFactory
	// and then make assertions.

}

func (*ClientFactoryMock) CreateClient added in v1.0.3

func (mock *ClientFactoryMock) CreateClient(ip string, port uint16, target string) (network.Client, error)

CreateClient calls CreateClientFunc.

func (*ClientFactoryMock) CreateClientCalls added in v1.0.3

func (mock *ClientFactoryMock) CreateClientCalls() []struct {
	IP     string
	Port   uint16
	Target string
}

CreateClientCalls gets all the calls that were made to CreateClient. Check the length with:

len(mockedClientFactory.CreateClientCalls())

type ClientMock added in v1.0.3

type ClientMock struct {
	// SendFunc mocks the Send method.
	SendFunc func(topic string, req p2p.Data) (p2p.Data, error)
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked Client
	mockedClient := &ClientMock{
		SendFunc: func(topic string, req p2p.Data) (p2p.Data, error) {
			panic("mock out the Send method")
		},
	}

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

}

func (*ClientMock) Send added in v1.0.3

func (mock *ClientMock) Send(topic string, req p2p.Data) (p2p.Data, error)

Send calls SendFunc.

func (*ClientMock) SendCalls added in v1.0.3

func (mock *ClientMock) SendCalls() []struct {
	Topic string
	Req   p2p.Data
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedClient.SendCalls())

type ServerMock

type ServerMock struct {
	// ServeFunc mocks the Serve method.
	ServeFunc func() error

	// SetHandleFunc mocks the SetHandle method.
	SetHandleFunc func(topic string, handler p2p.Handler)
	// contains filtered or unexported fields
}

ServerMock is a mock implementation of Server.

func TestSomethingThatUsesServer(t *testing.T) {

	// make and configure a mocked Server
	mockedServer := &ServerMock{
		ServeFunc: func() error {
			panic("mock out the Serve method")
		},
		SetHandleFunc: func(topic string, handler p2p.Handler)  {
			panic("mock out the SetHandle method")
		},
	}

	// use mockedServer in code that requires Server
	// and then make assertions.

}

func (*ServerMock) Serve

func (mock *ServerMock) Serve() error

Serve calls ServeFunc.

func (*ServerMock) ServeCalls

func (mock *ServerMock) ServeCalls() []struct {
}

ServeCalls gets all the calls that were made to Serve. Check the length with:

len(mockedServer.ServeCalls())

func (*ServerMock) SetHandle

func (mock *ServerMock) SetHandle(topic string, handler p2p.Handler)

SetHandle calls SetHandleFunc.

func (*ServerMock) SetHandleCalls

func (mock *ServerMock) SetHandleCalls() []struct {
	Topic   string
	Handler p2p.Handler
}

SetHandleCalls gets all the calls that were made to SetHandle. Check the length with:

len(mockedServer.SetHandleCalls())

type TransactionsPoolMock

type TransactionsPoolMock struct {
	// AddTransactionFunc mocks the AddTransaction method.
	AddTransactionFunc func(transactionRequest *neighborhood.TransactionRequest, blockchain network.Blockchain, neighbors []neighborhood.Neighbor)

	// TransactionsFunc mocks the Transactions method.
	TransactionsFunc func() []*neighborhood.TransactionResponse
	// contains filtered or unexported fields
}

TransactionsPoolMock is a mock implementation of TransactionsPool.

func TestSomethingThatUsesTransactionsPool(t *testing.T) {

	// make and configure a mocked TransactionsPool
	mockedTransactionsPool := &TransactionsPoolMock{
		AddTransactionFunc: func(transactionRequest *neighborhood.TransactionRequest, blockchain Blockchain, neighbors []neighborhood.Neighbor)  {
			panic("mock out the AddTransaction method")
		},
		TransactionsFunc: func() []*neighborhood.TransactionResponse {
			panic("mock out the Transactions method")
		},
	}

	// use mockedTransactionsPool in code that requires TransactionsPool
	// and then make assertions.

}

func (*TransactionsPoolMock) AddTransaction

func (mock *TransactionsPoolMock) AddTransaction(transactionRequest *neighborhood.TransactionRequest, blockchain network.Blockchain, neighbors []neighborhood.Neighbor)

AddTransaction calls AddTransactionFunc.

func (*TransactionsPoolMock) AddTransactionCalls

func (mock *TransactionsPoolMock) AddTransactionCalls() []struct {
	TransactionRequest *neighborhood.TransactionRequest
	Blockchain         network.Blockchain
	Neighbors          []neighborhood.Neighbor
}

AddTransactionCalls gets all the calls that were made to AddTransaction. Check the length with:

len(mockedTransactionsPool.AddTransactionCalls())

func (*TransactionsPoolMock) Transactions

func (mock *TransactionsPoolMock) Transactions() []*neighborhood.TransactionResponse

Transactions calls TransactionsFunc.

func (*TransactionsPoolMock) TransactionsCalls

func (mock *TransactionsPoolMock) TransactionsCalls() []struct {
}

TransactionsCalls gets all the calls that were made to Transactions. Check the length with:

len(mockedTransactionsPool.TransactionsCalls())

type ValidatorMock

type ValidatorMock struct {
	// StartValidationFunc mocks the StartValidation method.
	StartValidationFunc func()

	// StopValidationFunc mocks the StopValidation method.
	StopValidationFunc func()

	// ValidateFunc mocks the Validate method.
	ValidateFunc func()
	// contains filtered or unexported fields
}

ValidatorMock is a mock implementation of Validator.

func TestSomethingThatUsesValidator(t *testing.T) {

	// make and configure a mocked Validator
	mockedValidator := &ValidatorMock{
		StartValidationFunc: func()  {
			panic("mock out the StartValidation method")
		},
		StopValidationFunc: func()  {
			panic("mock out the StopValidation method")
		},
		ValidateFunc: func()  {
			panic("mock out the Validate method")
		},
	}

	// use mockedValidator in code that requires Validator
	// and then make assertions.

}

func (*ValidatorMock) StartValidation

func (mock *ValidatorMock) StartValidation()

StartValidation calls StartValidationFunc.

func (*ValidatorMock) StartValidationCalls

func (mock *ValidatorMock) StartValidationCalls() []struct {
}

StartValidationCalls gets all the calls that were made to StartValidation. Check the length with:

len(mockedValidator.StartValidationCalls())

func (*ValidatorMock) StopValidation

func (mock *ValidatorMock) StopValidation()

StopValidation calls StopValidationFunc.

func (*ValidatorMock) StopValidationCalls

func (mock *ValidatorMock) StopValidationCalls() []struct {
}

StopValidationCalls gets all the calls that were made to StopValidation. Check the length with:

len(mockedValidator.StopValidationCalls())

func (*ValidatorMock) Validate

func (mock *ValidatorMock) Validate()

Validate calls ValidateFunc.

func (*ValidatorMock) ValidateCalls

func (mock *ValidatorMock) ValidateCalls() []struct {
}

ValidateCalls gets all the calls that were made to Validate. Check the length with:

len(mockedValidator.ValidateCalls())

Jump to

Keyboard shortcuts

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