github.com/kaituanwang/hyperledger@v2.0.1+incompatible/core/mocks/validator/validator.go (about) 1 /* 2 Copyright IBM Corp. 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 32 // VSCCValidateTx does nothing 33 func (v *MockVsccValidator) VSCCValidateTx(seq int, payload *common.Payload, envBytes []byte, block *common.Block) (error, peer.TxValidationCode) { 34 return nil, peer.TxValidationCode_VALID 35 }