fabric: github.com/hyperledger/fabric/common/ledger/testutil Index | Files | Directories

package testutil

import "github.com/hyperledger/fabric/common/ledger/testutil"

Index

Package Files

test_helper.go test_util.go

func ConstructBlock Uses

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

ConstructBlock constructs a single block

func ConstructBlockFromBlockDetails Uses

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

func ConstructBlockWithTxid Uses

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

func ConstructBlockWithTxidHeaderType Uses

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

func ConstructBytesProposalResponsePayload Uses

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

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

func ConstructRandomBytes Uses

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

ConstructRandomBytes constructs random bytes of given size

func ConstructSignedTxEnv Uses

func ConstructSignedTxEnv(
    channelID string,
    ccid *pb.ChaincodeID,
    pResponse *pb.Response,
    simulationResults []byte,
    txid string,
    events []byte,
    visibility []byte,
    signer msp.SigningIdentity,
    headerType common.HeaderType,
) (*common.Envelope, string, error)

ConstructSignedTxEnv constructs a transaction envelop for tests

func ConstructSignedTxEnvWithDefaultSigner Uses

func ConstructSignedTxEnvWithDefaultSigner(
    chainID string,
    ccid *pb.ChaincodeID,
    response *pb.Response,
    simulationResults []byte,
    txid string,
    events []byte,
    visibility []byte,
    headerType common.HeaderType,
) (*common.Envelope, string, error)

ConstructSignedTxEnvWithDefaultSigner constructs a transaction envelop for tests with a default signer. This method helps other modules to construct a transaction with supplied parameters

func ConstructTestBlock Uses

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

ConstructTestBlock constructs a single block with random contents

func ConstructTestBlocks Uses

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 Uses

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

ConstructTransaction constructs a transaction for testing

func ConstructTransactionFromTxDetails Uses

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

func ConstructTransactionWithHeaderType Uses

func ConstructTransactionWithHeaderType(
    t *testing.T,
    simulationResults []byte,
    txid string,
    sign bool,
    headerType common.HeaderType,
) (*common.Envelope, string, error)

ConstructTransaction constructs a transaction for testing with header type

func ConstructUnsignedTxEnv Uses

func ConstructUnsignedTxEnv(
    chainID string,
    ccid *pb.ChaincodeID,
    response *pb.Response,
    simulationResults []byte,
    txid string,
    events []byte,
    visibility []byte,
    headerType common.HeaderType,
) (*common.Envelope, string, error)

ConstructUnsignedTxEnv creates a Transaction envelope from given inputs

func CopyDir Uses

func CopyDir(srcroot, destroot string, copyOnlySubdirs bool) error

CopyDir creates a copy of a dir

func CreateTarBytesForTest Uses

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

CreateTarBytesForTest creates a tar byte array for unit testing

func NewBlock Uses

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

func SetTxID Uses

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

func Unzip Uses

func Unzip(src string, dest string, createTopLevelDirInZip bool) error

Unzip will decompress the src zip file to the dest directory. If createTopLevelDirInZip is true, it creates the top level dir when unzipped. Otherwise, it trims off the top level dir when unzipped. For example, ledersData/historydb/abc will become historydb/abc.

type BlockDetails Uses

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

type BlockGenerator Uses

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

BlockGenerator generates a series of blocks for testing

func NewBlockGenerator Uses

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

NewBlockGenerator instantiates new BlockGenerator for testing

func (*BlockGenerator) NextBlock Uses

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 Uses

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 Uses

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 Uses

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

NextTestBlocks constructs 'numBlocks' number of blocks for testing

type TarFileEntry Uses

type TarFileEntry struct {
    Name, Body string
}

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

type TxDetails Uses

type TxDetails struct {
    TxID                            string
    ChaincodeName, ChaincodeVersion string
    SimulationResults               []byte
    Type                            common.HeaderType
}

Directories

PathSynopsis
fakesCode generated by counterfeiter.

Package testutil imports 23 packages (graph) and is imported by 1 packages. Updated 2019-11-21. Refresh now. Tools for package owners.