github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/mocks/configtx/configtx.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package configtx
     8  
     9  import (
    10  	cb "github.com/hyperledger/fabric-protos-go/common"
    11  )
    12  
    13  // Validator is a mock implementation of configtx.Validator
    14  type Validator struct {
    15  	// ChannelIDVal is returned as the result of ChannelID()
    16  	ChannelIDVal string
    17  
    18  	// SequenceVal is returned as the result of Sequence()
    19  	SequenceVal uint64
    20  
    21  	// ApplyVal is returned by Apply
    22  	ApplyVal error
    23  
    24  	// AppliedConfigUpdateEnvelope is set by Apply
    25  	AppliedConfigUpdateEnvelope *cb.ConfigEnvelope
    26  
    27  	// ValidateVal is returned by Validate
    28  	ValidateVal error
    29  
    30  	// ProposeConfigUpdateError is returned as the error value for ProposeConfigUpdate
    31  	ProposeConfigUpdateError error
    32  
    33  	// ProposeConfigUpdateVal is returns as the value for ProposeConfigUpdate
    34  	ProposeConfigUpdateVal *cb.ConfigEnvelope
    35  
    36  	// ConfigProtoVal is returned as the value for ConfigProtoVal()
    37  	ConfigProtoVal *cb.Config
    38  }
    39  
    40  // ConfigProto returns the ConfigProtoVal
    41  func (cm *Validator) ConfigProto() *cb.Config {
    42  	return cm.ConfigProtoVal
    43  }
    44  
    45  // ConsensusType returns the ConsensusTypeVal
    46  func (cm *Validator) ChannelID() string {
    47  	return cm.ChannelIDVal
    48  }
    49  
    50  // BatchSize returns the BatchSizeVal
    51  func (cm *Validator) Sequence() uint64 {
    52  	return cm.SequenceVal
    53  }
    54  
    55  // ProposeConfigUpdate
    56  func (cm *Validator) ProposeConfigUpdate(update *cb.Envelope) (*cb.ConfigEnvelope, error) {
    57  	return cm.ProposeConfigUpdateVal, cm.ProposeConfigUpdateError
    58  }
    59  
    60  // Apply returns ApplyVal
    61  func (cm *Validator) Apply(configEnv *cb.ConfigEnvelope) error {
    62  	cm.AppliedConfigUpdateEnvelope = configEnv
    63  	return cm.ApplyVal
    64  }
    65  
    66  // Validate returns ValidateVal
    67  func (cm *Validator) Validate(configEnv *cb.ConfigEnvelope) error {
    68  	return cm.ValidateVal
    69  }