github.com/true-sqn/fabric@v2.1.1+incompatible/core/ledger/kvledger/benchmark/chainmgmt/sanity_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package chainmgmt
     8  
     9  import (
    10  	"io/ioutil"
    11  	"os"
    12  	"testing"
    13  
    14  	"github.com/stretchr/testify/require"
    15  )
    16  
    17  // TestChainMgmt is a basic sanity check test to catch any errors that could be caused by changes in the ledgermgmt or kvledger packages
    18  func TestChainMgmt(t *testing.T) {
    19  	dataDir, err := ioutil.TempDir("", "ledgerbenchmark_sanitycheck")
    20  	require.NoError(t, err)
    21  	require.NoError(t, os.RemoveAll(dataDir))
    22  	defer os.RemoveAll(dataDir)
    23  
    24  	mgrConf := &ChainMgrConf{
    25  		DataDir:   dataDir,
    26  		NumChains: 1,
    27  	}
    28  	batchConf := &BatchConf{BatchSize: 1}
    29  	env := InitTestEnv(mgrConf, batchConf, ChainInitOpCreate)
    30  	require.NotNil(t, env.mgr)
    31  	require.Len(t, env.Chains(), 1)
    32  	bcInfo, err := env.Chains()[0].PeerLedger.GetBlockchainInfo()
    33  	require.NoError(t, err)
    34  	require.Equal(t, uint64(1), bcInfo.Height)
    35  }