protocoltest

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBlockResponse

func NewBlockResponse(timestamp int64, hash [32]byte, transactionResponses []*network.TransactionResponse, registeredAddresses []string) *network.BlockResponse

func NewEmptyBlockResponse

func NewEmptyBlockResponse(timestamp int64) *network.BlockResponse

func NewGenesisBlockResponse

func NewGenesisBlockResponse(validatorWalletAddress string) *network.BlockResponse

func NewRewardedBlockResponse

func NewRewardedBlockResponse(previousHash [32]byte, timestamp int64) *network.BlockResponse

Types

type BlockchainMock

type BlockchainMock struct {
	// AddBlockFunc mocks the AddBlock method.
	AddBlockFunc func(timestamp int64, transactions []*network.TransactionResponse, registeredAddresses []string)

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

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

	// CopyFunc mocks the Copy method.
	CopyFunc func() protocol.Blockchain

	// IsEmptyFunc mocks the IsEmpty method.
	IsEmptyFunc func() bool

	// VerifyFunc mocks the Verify method.
	VerifyFunc func(timestamp int64)
	// 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(timestamp int64, transactions []*network.TransactionResponse, registeredAddresses []string)  {
			panic("mock out the AddBlock method")
		},
		BlocksFunc: func() []*network.BlockResponse {
			panic("mock out the Blocks method")
		},
		CalculateTotalAmountFunc: func(currentTimestamp int64, blockchainAddress string) uint64 {
			panic("mock out the CalculateTotalAmount method")
		},
		CopyFunc: func() Blockchain {
			panic("mock out the Copy method")
		},
		IsEmptyFunc: func() bool {
			panic("mock out the IsEmpty method")
		},
		VerifyFunc: func(timestamp int64)  {
			panic("mock out the Verify method")
		},
	}

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

}

func (*BlockchainMock) AddBlock

func (mock *BlockchainMock) AddBlock(timestamp int64, transactions []*network.TransactionResponse, registeredAddresses []string)

AddBlock calls AddBlockFunc.

func (*BlockchainMock) AddBlockCalls

func (mock *BlockchainMock) AddBlockCalls() []struct {
	Timestamp           int64
	Transactions        []*network.TransactionResponse
	RegisteredAddresses []string
}

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

len(mockedBlockchain.AddBlockCalls())

func (*BlockchainMock) Blocks

func (mock *BlockchainMock) Blocks() []*network.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) Copy

func (mock *BlockchainMock) Copy() protocol.Blockchain

Copy calls CopyFunc.

func (*BlockchainMock) CopyCalls

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

CopyCalls gets all the calls that were made to Copy. Check the length with:

len(mockedBlockchain.CopyCalls())

func (*BlockchainMock) IsEmpty

func (mock *BlockchainMock) IsEmpty() bool

IsEmpty calls IsEmptyFunc.

func (*BlockchainMock) IsEmptyCalls

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

IsEmptyCalls gets all the calls that were made to IsEmpty. Check the length with:

len(mockedBlockchain.IsEmptyCalls())

func (*BlockchainMock) Verify

func (mock *BlockchainMock) Verify(timestamp int64)

Verify calls VerifyFunc.

func (*BlockchainMock) VerifyCalls

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

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

len(mockedBlockchain.VerifyCalls())

type RegistryMock

type RegistryMock struct {
	// IsRegisteredFunc mocks the IsRegistered method.
	IsRegisteredFunc func(address string) (bool, error)
	// contains filtered or unexported fields
}

RegistryMock is a mock implementation of Registry.

func TestSomethingThatUsesRegistry(t *testing.T) {

	// make and configure a mocked Registry
	mockedRegistry := &RegistryMock{
		IsRegisteredFunc: func(address string) (bool, error) {
			panic("mock out the IsRegistered method")
		},
	}

	// use mockedRegistry in code that requires Registry
	// and then make assertions.

}

func (*RegistryMock) IsRegistered

func (mock *RegistryMock) IsRegistered(address string) (bool, error)

IsRegistered calls IsRegisteredFunc.

func (*RegistryMock) IsRegisteredCalls

func (mock *RegistryMock) IsRegisteredCalls() []struct {
	Address string
}

IsRegisteredCalls gets all the calls that were made to IsRegistered. Check the length with:

len(mockedRegistry.IsRegisteredCalls())

type TransactionsPoolMock

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

	// TransactionsFunc mocks the Transactions method.
	TransactionsFunc func() []*network.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 *network.TransactionRequest, neighbors []network.Neighbor)  {
			panic("mock out the AddTransaction method")
		},
		TransactionsFunc: func() []*network.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 *network.TransactionRequest, neighbors []network.Neighbor)

AddTransaction calls AddTransactionFunc.

func (*TransactionsPoolMock) AddTransactionCalls

func (mock *TransactionsPoolMock) AddTransactionCalls() []struct {
	TransactionRequest *network.TransactionRequest
	Neighbors          []network.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() []*network.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())

Jump to

Keyboard shortcuts

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