func (b *MockTxEventBuilder) BuildWithTxValidationCode(c pb.TxValidationCode) *pb.Event_Block {
	return &pb.Event_Block{
		Block: &common.Block{
			Header:   &common.BlockHeader{},
			Metadata: b.buildBlockMetadata(c),
			Data: &common.BlockData{
				Data: [][]byte{protos_utils.MarshalOrPanic(b.buildEnvelope())},
			},
		},
	}
}
BuildWithTxValidationCode Build builds a mock TX event block
package events
import (
	"time"
	"github.com/pkg/errors"
	"google.golang.org/grpc/keepalive"
	fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
	fcConsumer "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/events/consumer"
	client "github.com/hyperledger/fabric-sdk-go/pkg/fabric-client"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/mocks"
	ledger_util "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/core/ledger/util"
	"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
	pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
	protos_utils "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/utils"
	"github.com/hyperledger/fabric-sdk-go/internal/github.com/tjfoc/gmsm/sm2"
)
type mockEventClientMockEventRegistration struct {
	Action string
	ies    []*pb.Interest
}
type mockEventClient struct {
	PeerAddress string
	RegTimeout  time.Duration
	Adapter     fcConsumer.EventAdapter
	Started       int
	Stopped       int
	Registrations []mockEventClientMockEventRegistration
	events chan pb.Event
}
type mockEventClientFactory struct {
	clients []*mockEventClient
}
func (mecf *mockEventClientFactory) newEventsClient(provider fab.ProviderContext, identity fab.IdentityContext, peerAddress string, certificate *sm2.Certificate, serverHostOverride string, regTimeout time.Duration,
	adapter fcConsumer.EventAdapter, kap keepalive.ClientParameters, failFast bool) (fab.EventsClient, error) {
	mec := &mockEventClient{
		PeerAddress: peerAddress,
		RegTimeout:  regTimeout,
		Adapter:     adapter,
		events:      make(chan pb.Event),
	}
	mecf.clients = append(mecf.clients, mec)
	return mec, nil
}
func (mec *mockEventClient) MockEvent(msg *pb.Event) (bool, error) {
	if mec.Started > mec.Stopped {
		return mec.Adapter.Recv(msg)
	}
	mec.events <- *msg
	return true, nil
}
func (mec *mockEventClient) RegisterAsync(ies []*pb.Interest) error {
	mec.Registrations = append(mec.Registrations, mockEventClientMockEventRegistration{
		Action: "register",
		ies:    ies,
	})
	return nil
}
func (mec *mockEventClient) UnregisterAsync(ies []*pb.Interest) error {
	mec.Registrations = append(mec.Registrations, mockEventClientMockEventRegistration{
		Action: "register",
		ies:    ies,
	})
	return nil
}
func (mec *mockEventClient) Unregister(ies []*pb.Interest) error {
	return mec.UnregisterAsync(ies)
}
func (mec *mockEventClient) Recv() (*pb.Event, error) {
	event := <-mec.events
	return &event, nil
}
func (mec *mockEventClient) Start() error {
	mec.Started++
	return nil
}
func (mec *mockEventClient) Stop() error {
	mec.Stopped++
	return nil
}
func createMockedEventHub() (*EventHub, *mockEventClientFactory, error) {
	client := client.NewClient(mocks.NewMockConfig())
	ctx := Context{
		ProviderContext: client,
		IdentityContext: client.IdentityContext(),
	}
	eventHub, err := New(ctx)
	if err != nil {
		return nil, nil, errors.WithMessage(err, "Error creating event hub")
	}
	var clientFactory mockEventClientFactory
	eventHub.eventsClientFactory = &clientFactory
	eventHub.SetPeerAddr("mock://mock", nil, "")
	err = eventHub.Connect()
	if err != nil {
		return nil, nil, errors.WithMessage(err, "Failed to connect")
	}
	return eventHub, &clientFactory, nil
}
type MockTxEventBuilder struct {
	ChannelID string
	TxID      string
}
type MockCCEventBuilder struct {
	CCID      string
	EventName string
	Payload   []byte
}
type MockCCBlockEventBuilder struct {
	CCID      string
	EventName string
	ChannelID string
	TxID      string
	Payload   []byte
}
func (b *MockTxEventBuilder) Build() *pb.Event_Block {
	return &pb.Event_Block{
		Block: &common.Block{
			Header:   &common.BlockHeader{},
			Metadata: b.buildBlockMetadata(pb.TxValidationCode_VALID),
			Data: &common.BlockData{
				Data: [][]byte{protos_utils.MarshalOrPanic(b.buildEnvelope())},
			},
		},
	}
}