github.com/true-sqn/fabric@v2.1.1+incompatible/core/ledger/kvledger/tests/ledger_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package tests 8 9 import ( 10 "fmt" 11 "os" 12 "testing" 13 14 "github.com/hyperledger/fabric/common/flogging" 15 msptesttools "github.com/hyperledger/fabric/msp/mgmt/testtools" 16 ) 17 18 func TestMain(m *testing.M) { 19 flogging.ActivateSpec("lockbasedtxmgr,statevalidator,statebasedval,statecouchdb,valimpl,pvtstatepurgemgmt,confighistory,kvledger,leveldbhelper=debug") 20 if err := msptesttools.LoadMSPSetupForTesting(); err != nil { 21 panic(fmt.Errorf("Could not load msp config, err %s", err)) 22 } 23 os.Exit(m.Run()) 24 } 25 26 func TestLedgerAPIs(t *testing.T) { 27 env := newEnv(t) 28 defer env.cleanup() 29 env.initLedgerMgmt() 30 31 // create two ledgers 32 h1 := env.newTestHelperCreateLgr("ledger1", t) 33 h2 := env.newTestHelperCreateLgr("ledger2", t) 34 35 // populate ledgers with sample data 36 dataHelper := newSampleDataHelper(t) 37 dataHelper.populateLedger(h1) 38 dataHelper.populateLedger(h2) 39 40 // verify contents in both the ledgers 41 dataHelper.verifyLedgerContent(h1) 42 dataHelper.verifyLedgerContent(h2) 43 }