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

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package mocks
     8  
     9  import (
    10  	"time"
    11  
    12  	"github.com/hechain20/hechain/msp"
    13  	pmsp "github.com/hyperledger/fabric-protos-go/msp"
    14  	"github.com/stretchr/testify/mock"
    15  )
    16  
    17  type MockMSP struct {
    18  	mock.Mock
    19  }
    20  
    21  func (m *MockMSP) IsWellFormed(_ *pmsp.SerializedIdentity) error {
    22  	return nil
    23  }
    24  
    25  func (m *MockMSP) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error) {
    26  	args := m.Called(serializedIdentity)
    27  	return args.Get(0).(msp.Identity), args.Error(1)
    28  }
    29  
    30  func (m *MockMSP) Setup(config *pmsp.MSPConfig) error {
    31  	args := m.Called(config)
    32  	return args.Error(0)
    33  }
    34  
    35  func (m *MockMSP) GetVersion() msp.MSPVersion {
    36  	args := m.Called()
    37  	return args.Get(0).(msp.MSPVersion)
    38  }
    39  
    40  func (m *MockMSP) GetType() msp.ProviderType {
    41  	args := m.Called()
    42  	return args.Get(0).(msp.ProviderType)
    43  }
    44  
    45  func (m *MockMSP) GetIdentifier() (string, error) {
    46  	args := m.Called()
    47  	return args.String(0), args.Error(1)
    48  }
    49  
    50  func (m *MockMSP) GetDefaultSigningIdentity() (msp.SigningIdentity, error) {
    51  	args := m.Called()
    52  	return args.Get(0).(msp.SigningIdentity), args.Error(1)
    53  }
    54  
    55  func (m *MockMSP) GetTLSRootCerts() [][]byte {
    56  	args := m.Called()
    57  	return args.Get(0).([][]byte)
    58  }
    59  
    60  func (m *MockMSP) GetTLSIntermediateCerts() [][]byte {
    61  	args := m.Called()
    62  	return args.Get(0).([][]byte)
    63  }
    64  
    65  func (m *MockMSP) Validate(id msp.Identity) error {
    66  	args := m.Called(id)
    67  	return args.Error(0)
    68  }
    69  
    70  func (m *MockMSP) SatisfiesPrincipal(id msp.Identity, principal *pmsp.MSPPrincipal) error {
    71  	args := m.Called(id, principal)
    72  	return args.Error(0)
    73  }
    74  
    75  type MockIdentity struct {
    76  	mock.Mock
    77  
    78  	ID string
    79  }
    80  
    81  func (m *MockIdentity) Anonymous() bool {
    82  	panic("implement me")
    83  }
    84  
    85  func (m *MockIdentity) ExpiresAt() time.Time {
    86  	panic("implement me")
    87  }
    88  
    89  func (m *MockIdentity) GetIdentifier() *msp.IdentityIdentifier {
    90  	args := m.Called()
    91  	return args.Get(0).(*msp.IdentityIdentifier)
    92  }
    93  
    94  func (*MockIdentity) GetMSPIdentifier() string {
    95  	panic("implement me")
    96  }
    97  
    98  func (m *MockIdentity) Validate() error {
    99  	return m.Called().Error(0)
   100  }
   101  
   102  func (*MockIdentity) GetOrganizationalUnits() []*msp.OUIdentifier {
   103  	panic("implement me")
   104  }
   105  
   106  func (*MockIdentity) Verify(msg []byte, sig []byte) error {
   107  	return nil
   108  }
   109  
   110  func (*MockIdentity) Serialize() ([]byte, error) {
   111  	panic("implement me")
   112  }
   113  
   114  func (m *MockIdentity) SatisfiesPrincipal(principal *pmsp.MSPPrincipal) error {
   115  	return m.Called(principal).Error(0)
   116  }
   117  
   118  type MockSigningIdentity struct {
   119  	mock.Mock
   120  	*MockIdentity
   121  }
   122  
   123  func (*MockSigningIdentity) Sign(msg []byte) ([]byte, error) {
   124  	panic("implement me")
   125  }
   126  
   127  func (*MockSigningIdentity) GetPublicVersion() msp.Identity {
   128  	panic("implement me")
   129  }