Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 25ef379

Browse files
committed
[FAB-6767] mock utils for SDK go
- Added mock util in mockdata for create mock block with CCEvent and TxStatus Change-Id: Ibbf7f4bbb456cb980dd6ca7e32b05cf5cb99ec00 Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
1 parent e3ec402 commit 25ef379

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/fabric-client/mocks/mockdata.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ func marshalOrPanic(pb proto.Message) []byte {
468468
// CreateBlockWithCCEvent creates a mock block
469469
func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string,
470470
channelID string) (*common.Block, error) {
471+
return CreateBlockWithCCEventAndTxStatus(events, txID, channelID, pp.TxValidationCode_VALID)
472+
}
473+
474+
// CreateBlockWithCCEventAndTxStatus creates a mock block with the given CC event and TX validation code
475+
func CreateBlockWithCCEventAndTxStatus(events *pp.ChaincodeEvent, txID string,
476+
channelID string, txValidationCode pp.TxValidationCode) (*common.Block, error) {
471477
chdr := &common.ChannelHeader{
472478
Type: int32(common.HeaderType_ENDORSER_TRANSACTION),
473479
Version: 1,
@@ -522,6 +528,9 @@ func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string,
522528
block.Header.DataHash = cutil.ComputeSHA256(blockbytes)
523529

524530
txsfltr := ledger_util.NewTxValidationFlags(len(block.Data.Data))
531+
for i := 0; i < len(block.Data.Data); i++ {
532+
txsfltr[i] = uint8(txValidationCode)
533+
}
525534

526535
block.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = txsfltr
527536

0 commit comments

Comments
 (0)