github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/ledger/kvledger/benchmark/mocks/msp.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  	mspprotos "github.com/hyperledger/fabric-protos-go/msp"
    14  )
    15  
    16  type noopmsp struct{}
    17  
    18  // NewNoopMsp returns a no-op implementation of the MSP interface
    19  func NewNoopMsp() msp.MSP {
    20  	return &noopmsp{}
    21  }
    22  
    23  func (msp *noopmsp) Setup(*mspprotos.MSPConfig) error {
    24  	return nil
    25  }
    26  
    27  func (msp *noopmsp) GetVersion() msp.MSPVersion {
    28  	return 1
    29  }
    30  
    31  func (msp *noopmsp) GetType() msp.ProviderType {
    32  	return 0
    33  }
    34  
    35  func (msp *noopmsp) GetIdentifier() (string, error) {
    36  	return "NOOP", nil
    37  }
    38  
    39  func (msp *noopmsp) GetDefaultSigningIdentity() (msp.SigningIdentity, error) {
    40  	id, _ := newNoopSigningIdentity()
    41  	return id, nil
    42  }
    43  
    44  // GetRootCerts returns the root certificates for this MSP
    45  func (msp *noopmsp) GetRootCerts() []msp.Identity {
    46  	return nil
    47  }
    48  
    49  // GetIntermediateCerts returns the intermediate root certificates for this MSP
    50  func (msp *noopmsp) GetIntermediateCerts() []msp.Identity {
    51  	return nil
    52  }
    53  
    54  // GetTLSRootCerts returns the root certificates for this MSP
    55  func (msp *noopmsp) GetTLSRootCerts() [][]byte {
    56  	return nil
    57  }
    58  
    59  // GetTLSIntermediateCerts returns the intermediate root certificates for this MSP
    60  func (msp *noopmsp) GetTLSIntermediateCerts() [][]byte {
    61  	return nil
    62  }
    63  
    64  func (msp *noopmsp) DeserializeIdentity(serializedID []byte) (msp.Identity, error) {
    65  	id, _ := newNoopIdentity()
    66  	return id, nil
    67  }
    68  
    69  func (msp *noopmsp) Validate(id msp.Identity) error {
    70  	return nil
    71  }
    72  
    73  func (msp *noopmsp) SatisfiesPrincipal(id msp.Identity, principal *mspprotos.MSPPrincipal) error {
    74  	return nil
    75  }
    76  
    77  // IsWellFormed checks if the given identity can be deserialized into its provider-specific form
    78  func (msp *noopmsp) IsWellFormed(_ *mspprotos.SerializedIdentity) error {
    79  	return nil
    80  }
    81  
    82  type noopidentity struct{}
    83  
    84  func newNoopIdentity() (msp.Identity, error) {
    85  	return &noopidentity{}, nil
    86  }
    87  
    88  func (id *noopidentity) Anonymous() bool {
    89  	panic("implement me")
    90  }
    91  
    92  func (id *noopidentity) SatisfiesPrincipal(*mspprotos.MSPPrincipal) error {
    93  	return nil
    94  }
    95  
    96  func (id *noopidentity) ExpiresAt() time.Time {
    97  	return time.Time{}
    98  }
    99  
   100  func (id *noopidentity) GetIdentifier() *msp.IdentityIdentifier {
   101  	return &msp.IdentityIdentifier{Mspid: "NOOP", Id: "Bob"}
   102  }
   103  
   104  func (id *noopidentity) GetMSPIdentifier() string {
   105  	return "MSPID"
   106  }
   107  
   108  func (id *noopidentity) Validate() error {
   109  	return nil
   110  }
   111  
   112  func (id *noopidentity) GetOrganizationalUnits() []*msp.OUIdentifier {
   113  	return nil
   114  }
   115  
   116  func (id *noopidentity) Verify(msg []byte, sig []byte) error {
   117  	return nil
   118  }
   119  
   120  func (id *noopidentity) Serialize() ([]byte, error) {
   121  	return []byte("cert"), nil
   122  }
   123  
   124  type noopsigningidentity struct {
   125  	noopidentity
   126  }
   127  
   128  func newNoopSigningIdentity() (msp.SigningIdentity, error) {
   129  	return &noopsigningidentity{}, nil
   130  }
   131  
   132  func (id *noopsigningidentity) Sign(msg []byte) ([]byte, error) {
   133  	return []byte("signature"), nil
   134  }
   135  
   136  func (id *noopsigningidentity) GetPublicVersion() msp.Identity {
   137  	return id
   138  }