testutil

package
v0.0.0-...-2d2252b Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructBlock

func ConstructBlock(t *testing.T, blockNum uint64, previousHash []byte, simulationResults [][]byte, sign bool) *common.Block

ConstructBlock constructs a single block

func ConstructBlockFromBlockDetails

func ConstructBlockFromBlockDetails(t *testing.T, blockDetails *BlockDetails, sign bool) *common.Block

func ConstructBlockWithTxid

func ConstructBlockWithTxid(t *testing.T, blockNum uint64, previousHash []byte, simulationResults [][]byte, txids []string, sign bool) *common.Block

func ConstructBytesProposalResponsePayload

func ConstructBytesProposalResponsePayload(version string, simulationResults []byte) ([]byte, error)

ConstructBytesProposalResponsePayload constructs a ProposalResponse byte with given chaincode version and simulationResults for testing

func ConstructRandomBytes

func ConstructRandomBytes(t testing.TB, size int) []byte

ConstructRandomBytes constructs random bytes of given size

func ConstructTestBlock

func ConstructTestBlock(t *testing.T, blockNum uint64, numTx int, txSize int) *common.Block

ConstructTestBlock constructs a single block with random contents

func ConstructTestBlocks

func ConstructTestBlocks(t *testing.T, numBlocks int) []*common.Block

ConstructTestBlocks returns a series of blocks starting with blockNum=0. The first block in the returned array is a config tx block that represents a genesis block Except the genesis block, the size of each of the block would be the same.

func ConstructTransaction

func ConstructTransaction(_ *testing.T, simulationResults []byte, txid string, sign bool) (*common.Envelope, string, error)

ConstructTransaction constructs a transaction for testing

func ConstructTransactionFromTxDetails

func ConstructTransactionFromTxDetails(txDetails *TxDetails, sign bool) (*common.Envelope, string, error)

func CopyDir

func CopyDir(srcroot, destroot string) error

CopyDir creates a copy of a dir

func CreateTarBytesForTest

func CreateTarBytesForTest(testFiles []*TarFileEntry) []byte

CreateTarBytesForTest creates a tar byte array for unit testing

func NewBlock

func NewBlock(env []*common.Envelope, blockNum uint64, previousHash []byte) *common.Block

func SetTxID

func SetTxID(t *testing.T, block *common.Block, txNum int, txID string)

Types

type BlockDetails

type BlockDetails struct {
	BlockNum     uint64
	PreviousHash []byte
	Txs          []*TxDetails
}

type BlockGenerator

type BlockGenerator struct {
	// contains filtered or unexported fields
}

BlockGenerator generates a series of blocks for testing

func NewBlockGenerator

func NewBlockGenerator(t *testing.T, ledgerID string, signTxs bool) (*BlockGenerator, *common.Block)

NewBlockGenerator instantiates new BlockGenerator for testing

func (*BlockGenerator) NextBlock

func (bg *BlockGenerator) NextBlock(simulationResults [][]byte) *common.Block

NextBlock constructs next block in sequence that includes a number of transactions - one per simulationResults

func (*BlockGenerator) NextBlockWithTxid

func (bg *BlockGenerator) NextBlockWithTxid(simulationResults [][]byte, txids []string) *common.Block

NextBlockWithTxid constructs next block in sequence that includes a number of transactions - one per simulationResults

func (*BlockGenerator) NextTestBlock

func (bg *BlockGenerator) NextTestBlock(numTx int, txSize int) *common.Block

NextTestBlock constructs next block in sequence block with 'numTx' number of transactions for testing

func (*BlockGenerator) NextTestBlocks

func (bg *BlockGenerator) NextTestBlocks(numBlocks int) []*common.Block

NextTestBlocks constructs 'numBlocks' number of blocks for testing

type TarFileEntry

type TarFileEntry struct {
	Name, Body string
}

TarFileEntry is a structure for adding test index files to an tar

type TxDetails

type TxDetails struct {
	TxID                            string
	ChaincodeName, ChaincodeVersion string
	SimulationResults               []byte
}

Jump to

Keyboard shortcuts

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