github.com/yous1230/fabric@v2.0.0-beta.0.20191224111736-74345bee6ac2+incompatible/gossip/privdata/config_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package privdata_test
     8  
     9  import (
    10  	"testing"
    11  	"time"
    12  
    13  	"github.com/hyperledger/fabric/gossip/privdata"
    14  	"github.com/spf13/viper"
    15  	"github.com/stretchr/testify/assert"
    16  )
    17  
    18  func TestGlobalConfig(t *testing.T) {
    19  	viper.Reset()
    20  	// Capture the configuration from viper
    21  	viper.Set("peer.gossip.pvtData.reconcileSleepInterval", "10s")
    22  	viper.Set("peer.gossip.pvtData.reconcileBatchSize", 10)
    23  	viper.Set("peer.gossip.pvtData.reconciliationEnabled", true)
    24  
    25  	coreConfig := privdata.GlobalConfig()
    26  
    27  	expectedConfig := &privdata.PrivdataConfig{
    28  		ReconcileSleepInterval: 10 * time.Second,
    29  		ReconcileBatchSize:     10,
    30  		ReconciliationEnabled:  true,
    31  	}
    32  
    33  	assert.Equal(t, coreConfig, expectedConfig)
    34  }
    35  
    36  func TestGlobalConfigDefaults(t *testing.T) {
    37  	viper.Reset()
    38  
    39  	coreConfig := privdata.GlobalConfig()
    40  
    41  	expectedConfig := &privdata.PrivdataConfig{
    42  		ReconcileSleepInterval: time.Minute,
    43  		ReconcileBatchSize:     10,
    44  		ReconciliationEnabled:  false,
    45  	}
    46  
    47  	assert.Equal(t, coreConfig, expectedConfig)
    48  }