github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/mocks/validator/validator.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package validator
     8  
     9  import (
    10  	"github.com/hyperledger/fabric-protos-go/common"
    11  	"github.com/hyperledger/fabric-protos-go/peer"
    12  	"github.com/stretchr/testify/mock"
    13  )
    14  
    15  // MockValidator implements a mock validation useful for testing
    16  type MockValidator struct {
    17  	mock.Mock
    18  }
    19  
    20  // Validate does nothing, returning no error
    21  func (m *MockValidator) Validate(block *common.Block) error {
    22  	if len(m.ExpectedCalls) == 0 {
    23  		return nil
    24  	}
    25  	return m.Called().Error(0)
    26  }
    27  
    28  // MockVsccValidator is a mock implementation of the VSCC validation interface
    29  type MockVsccValidator struct{}
    30  
    31  // VSCCValidateTx does nothing
    32  func (v *MockVsccValidator) VSCCValidateTx(seq int, payload *common.Payload, envBytes []byte, block *common.Block) (peer.TxValidationCode, error) {
    33  	return peer.TxValidationCode_VALID, nil
    34  }