Commit 2a16532c authored by manish's avatar manish
Browse files

Move Blockstorage code under /fabric/common package

https://jira.hyperledger.org/browse/FAB-2022



This changes introduced by this CR
- Moves the block storage code from package
core/ledger/blkstorage to common/ledger/blkstorage

- Splits the ledger_interface.go so as to move common interfaces
and data type to common/ledger package

- Moves some of the util functions to common/ledger package

- Moves core/ledger/ordererledger package to orderer/ledger/fsledger
orderer folks can futher rename/refactor this as seems suitable to them

Change-Id: I759e16f00dc2ec9bb62196121083cf48eae76948
Signed-off-by: default avatarmanish <manish.sethi@gmail.com>
parent e67a2382
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"testing" "testing"
configtxtest "github.com/hyperledger/fabric/common/configtx/test" configtxtest "github.com/hyperledger/fabric/common/configtx/test"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/testutil"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
......
...@@ -20,13 +20,13 @@ import ( ...@@ -20,13 +20,13 @@ import (
"os" "os"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb" "github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/testutil"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
......
...@@ -20,8 +20,9 @@ import ( ...@@ -20,8 +20,9 @@ import (
"errors" "errors"
"fmt" "fmt"
commonledger "github.com/hyperledger/fabric/common/ledger"
"github.com/hyperledger/fabric/common/ledger/blkstorage"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/blkstorage"
"github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb" "github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
...@@ -31,7 +32,6 @@ import ( ...@@ -31,7 +32,6 @@ import (
logging "github.com/op/go-logging" logging "github.com/op/go-logging"
"github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/common"
pb "github.com/hyperledger/fabric/protos/peer"
) )
var logger = logging.MustGetLogger("kvledger") var logger = logging.MustGetLogger("kvledger")
...@@ -205,7 +205,7 @@ func (l *kvLedger) GetTransactionByID(txID string) (*common.Envelope, error) { ...@@ -205,7 +205,7 @@ func (l *kvLedger) GetTransactionByID(txID string) (*common.Envelope, error) {
} }
// GetBlockchainInfo returns basic info about blockchain // GetBlockchainInfo returns basic info about blockchain
func (l *kvLedger) GetBlockchainInfo() (*pb.BlockchainInfo, error) { func (l *kvLedger) GetBlockchainInfo() (*common.BlockchainInfo, error) {
return l.blockStore.GetBlockchainInfo() return l.blockStore.GetBlockchainInfo()
} }
...@@ -219,7 +219,7 @@ func (l *kvLedger) GetBlockByNumber(blockNumber uint64) (*common.Block, error) { ...@@ -219,7 +219,7 @@ func (l *kvLedger) GetBlockByNumber(blockNumber uint64) (*common.Block, error) {
// GetBlocksIterator returns an iterator that starts from `startBlockNumber`(inclusive). // GetBlocksIterator returns an iterator that starts from `startBlockNumber`(inclusive).
// The iterator is a blocking iterator i.e., it blocks till the next block gets available in the ledger // The iterator is a blocking iterator i.e., it blocks till the next block gets available in the ledger
// ResultsIterator contains type BlockHolder // ResultsIterator contains type BlockHolder
func (l *kvLedger) GetBlocksIterator(startBlockNumber uint64) (ledger.ResultsIterator, error) { func (l *kvLedger) GetBlocksIterator(startBlockNumber uint64) (commonledger.ResultsIterator, error) {
return l.blockStore.RetrieveBlocks(startBlockNumber) return l.blockStore.RetrieveBlocks(startBlockNumber)
} }
...@@ -230,7 +230,7 @@ func (l *kvLedger) GetBlockByHash(blockHash []byte) (*common.Block, error) { ...@@ -230,7 +230,7 @@ func (l *kvLedger) GetBlockByHash(blockHash []byte) (*common.Block, error) {
} }
//Prune prunes the blocks/transactions that satisfy the given policy //Prune prunes the blocks/transactions that satisfy the given policy
func (l *kvLedger) Prune(policy ledger.PrunePolicy) error { func (l *kvLedger) Prune(policy commonledger.PrunePolicy) error {
return errors.New("Not yet implemented") return errors.New("Not yet implemented")
} }
......
...@@ -19,16 +19,16 @@ package kvledger ...@@ -19,16 +19,16 @@ package kvledger
import ( import (
"errors" "errors"
"github.com/hyperledger/fabric/common/ledger/blkstorage"
"github.com/hyperledger/fabric/common/ledger/blkstorage/fsblkstorage"
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/blkstorage"
"github.com/hyperledger/fabric/core/ledger/blkstorage/fsblkstorage"
"github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb" "github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb"
"github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb/historyleveldb" "github.com/hyperledger/fabric/core/ledger/kvledger/history/historydb/historyleveldb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/util/leveldbhelper"
) )
var ( var (
......
...@@ -20,8 +20,8 @@ import ( ...@@ -20,8 +20,8 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
func TestLedgerProvider(t *testing.T) { func TestLedgerProvider(t *testing.T) {
......
...@@ -20,10 +20,11 @@ import ( ...@@ -20,10 +20,11 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
ledgerpackage "github.com/hyperledger/fabric/core/ledger" ledgerpackage "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/testutil" ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil"
pb "github.com/hyperledger/fabric/protos/peer" "github.com/hyperledger/fabric/protos/common"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
...@@ -36,7 +37,7 @@ func TestKVLedgerBlockStorage(t *testing.T) { ...@@ -36,7 +37,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
defer ledger.Close() defer ledger.Close()
bcInfo, _ := ledger.GetBlockchainInfo() bcInfo, _ := ledger.GetBlockchainInfo()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil}) Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil})
simulator, _ := ledger.NewTxSimulator() simulator, _ := ledger.NewTxSimulator()
...@@ -51,7 +52,7 @@ func TestKVLedgerBlockStorage(t *testing.T) { ...@@ -51,7 +52,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block1Hash := block1.Header.Hash() block1Hash := block1.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}}) Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}})
simulator, _ = ledger.NewTxSimulator() simulator, _ = ledger.NewTxSimulator()
...@@ -65,7 +66,7 @@ func TestKVLedgerBlockStorage(t *testing.T) { ...@@ -65,7 +66,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block2Hash := block2.Header.Hash() block2Hash := block2.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()}) Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()})
b1, _ := ledger.GetBlockByHash(block1Hash) b1, _ := ledger.GetBlockByHash(block1Hash)
...@@ -82,7 +83,7 @@ func TestKVLedgerBlockStorage(t *testing.T) { ...@@ -82,7 +83,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
} }
func TestKVLedgerDBRecovery(t *testing.T) { func TestKVLedgerDBRecovery(t *testing.T) {
testutil.SetupCoreYAMLConfig("./../../../peer") ledgertestutil.SetupCoreYAMLConfig("./../../../peer")
env := newTestEnv(t) env := newTestEnv(t)
defer env.cleanup() defer env.cleanup()
provider, _ := NewProvider() provider, _ := NewProvider()
...@@ -91,7 +92,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -91,7 +92,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
defer ledger.Close() defer ledger.Close()
bcInfo, _ := ledger.GetBlockchainInfo() bcInfo, _ := ledger.GetBlockchainInfo()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil}) Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil})
//creating and committing the first block //creating and committing the first block
simulator, _ := ledger.NewTxSimulator() simulator, _ := ledger.NewTxSimulator()
...@@ -108,7 +109,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -108,7 +109,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
ledger.Commit(block1) ledger.Commit(block1)
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block1Hash := block1.Header.Hash() block1Hash := block1.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}}) Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}})
//====================================================================================== //======================================================================================
...@@ -134,7 +135,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -134,7 +135,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block2Hash := block2.Header.Hash() block2Hash := block2.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()}) Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()})
simulator, _ = ledger.NewTxSimulator() simulator, _ = ledger.NewTxSimulator()
...@@ -234,7 +235,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -234,7 +235,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block3Hash := block3.Header.Hash() block3Hash := block3.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 3, CurrentBlockHash: block3Hash, PreviousBlockHash: block2.Header.Hash()}) Height: 3, CurrentBlockHash: block3Hash, PreviousBlockHash: block2.Header.Hash()})
simulator, _ = ledger.NewTxSimulator() simulator, _ = ledger.NewTxSimulator()
...@@ -325,7 +326,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -325,7 +326,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block4Hash := block4.Header.Hash() block4Hash := block4.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 4, CurrentBlockHash: block4Hash, PreviousBlockHash: block3.Header.Hash()}) Height: 4, CurrentBlockHash: block4Hash, PreviousBlockHash: block3.Header.Hash()})
simulator, _ = ledger.NewTxSimulator() simulator, _ = ledger.NewTxSimulator()
...@@ -385,7 +386,7 @@ func TestKVLedgerDBRecovery(t *testing.T) { ...@@ -385,7 +386,7 @@ func TestKVLedgerDBRecovery(t *testing.T) {
func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) { func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) {
//call a helper method to load the core.yaml //call a helper method to load the core.yaml
testutil.SetupCoreYAMLConfig("./../../../peer") ledgertestutil.SetupCoreYAMLConfig("./../../../peer")
logger.Debugf("TestLedgerWithCouchDbEnabledWithBinaryAndJSONData IsCouchDBEnabled()value: %v , IsHistoryDBEnabled()value: %v\n", logger.Debugf("TestLedgerWithCouchDbEnabledWithBinaryAndJSONData IsCouchDBEnabled()value: %v , IsHistoryDBEnabled()value: %v\n",
ledgerconfig.IsCouchDBEnabled(), ledgerconfig.IsHistoryDBEnabled()) ledgerconfig.IsCouchDBEnabled(), ledgerconfig.IsHistoryDBEnabled())
...@@ -398,7 +399,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) { ...@@ -398,7 +399,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) {
defer ledger.Close() defer ledger.Close()
bcInfo, _ := ledger.GetBlockchainInfo() bcInfo, _ := ledger.GetBlockchainInfo()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil}) Height: 0, CurrentBlockHash: nil, PreviousBlockHash: nil})
simulator, _ := ledger.NewTxSimulator() simulator, _ := ledger.NewTxSimulator()
...@@ -415,7 +416,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) { ...@@ -415,7 +416,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block1Hash := block1.Header.Hash() block1Hash := block1.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}}) Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}})
simulationResults := [][]byte{} simulationResults := [][]byte{}
...@@ -442,7 +443,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) { ...@@ -442,7 +443,7 @@ func TestLedgerWithCouchDbEnabledWithBinaryAndJSONData(t *testing.T) {
bcInfo, _ = ledger.GetBlockchainInfo() bcInfo, _ = ledger.GetBlockchainInfo()
block2Hash := block2.Header.Hash() block2Hash := block2.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{ testutil.AssertEquals(t, bcInfo, &common.BlockchainInfo{
Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()}) Height: 2, CurrentBlockHash: block2Hash, PreviousBlockHash: block1.Header.Hash()})
b1, _ := ledger.GetBlockByHash(block1Hash) b1, _ := ledger.GetBlockByHash(block1Hash)
......
...@@ -19,8 +19,8 @@ package rwset ...@@ -19,8 +19,8 @@ package rwset
import ( import (
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
func TestRWSetHolder(t *testing.T) { func TestRWSetHolder(t *testing.T) {
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"testing" "testing"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
func TestNilTxRWSet(t *testing.T) { func TestNilTxRWSet(t *testing.T) {
......
...@@ -20,9 +20,9 @@ import ( ...@@ -20,9 +20,9 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
// TestBasicRW tests basic read-write // TestBasicRW tests basic read-write
......
...@@ -20,18 +20,19 @@ import ( ...@@ -20,18 +20,19 @@ import (
"os" "os"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/commontests" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/commontests"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/testutil" ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
//call a helper method to load the core.yaml, will be used to detect if CouchDB is enabled //call a helper method to load the core.yaml, will be used to detect if CouchDB is enabled
testutil.SetupCoreYAMLConfig("./../../../../../../peer") ledgertestutil.SetupCoreYAMLConfig("./../../../../../../peer")
viper.Set("ledger.state.couchDBConfig.couchDBAddress", "127.0.0.1:5984") viper.Set("ledger.state.couchDBConfig.couchDBAddress", "127.0.0.1:5984")
viper.Set("peer.fileSystemPath", "/tmp/fabric/ledgertests/kvledger/txmgmt/statedb/statecouchdb") viper.Set("peer.fileSystemPath", "/tmp/fabric/ledgertests/kvledger/txmgmt/statedb/statecouchdb")
......
...@@ -19,8 +19,8 @@ package statedb ...@@ -19,8 +19,8 @@ package statedb
import ( import (
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
func TestUpdateBatchIterator(t *testing.T) { func TestUpdateBatchIterator(t *testing.T) {
......
...@@ -21,10 +21,10 @@ import ( ...@@ -21,10 +21,10 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/util/leveldbhelper"
logging "github.com/op/go-logging" logging "github.com/op/go-logging"
"github.com/syndtr/goleveldb/leveldb/iterator" "github.com/syndtr/goleveldb/leveldb/iterator"
) )
......
...@@ -20,10 +20,10 @@ import ( ...@@ -20,10 +20,10 @@ import (
"os" "os"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/commontests" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/commontests"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
......
...@@ -19,8 +19,8 @@ package statedb ...@@ -19,8 +19,8 @@ package statedb
import ( import (
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
// TestEncodeString tests encoding and decoding a string value // TestEncodeString tests encoding and decoding a string value
......
...@@ -19,13 +19,14 @@ package commontests ...@@ -19,13 +19,14 @@ package commontests
import ( import (
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/stateleveldb"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/testutil" ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger/util" "github.com/hyperledger/fabric/core/ledger/util"
"github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/common"
"github.com/spf13/viper" "github.com/spf13/viper"
...@@ -47,7 +48,7 @@ var testEnvs = []testEnv{} ...@@ -47,7 +48,7 @@ var testEnvs = []testEnv{}
func init() { func init() {
//call a helper method to load the core.yaml so that we can detect whether couch is configured //call a helper method to load the core.yaml so that we can detect whether couch is configured
testutil.SetupCoreYAMLConfig("./../../../../../../peer") ledgertestutil.SetupCoreYAMLConfig("./../../../../../../peer")
//Only run the tests if CouchDB is explitily enabled in the code, //Only run the tests if CouchDB is explitily enabled in the code,
//otherwise CouchDB may not be installed and all the tests would fail //otherwise CouchDB may not be installed and all the tests would fail
......
...@@ -21,10 +21,10 @@ import ( ...@@ -21,10 +21,10 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
"github.com/hyperledger/fabric/core/ledger/ledgerconfig" "github.com/hyperledger/fabric/core/ledger/ledgerconfig"
"github.com/hyperledger/fabric/core/ledger/testutil"
) )
func TestTxSimulatorWithNoExistingData(t *testing.T) { func TestTxSimulatorWithNoExistingData(t *testing.T) {
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package lockbasedtxmgr package lockbasedtxmgr
import ( import (
commonledger "github.com/hyperledger/fabric/common/ledger"
"github.com/hyperledger/fabric/core/ledger" "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwset" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwset"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb" "github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
...@@ -60,7 +61,7 @@ func (h *queryHelper) getStateMultipleKeys(namespace string, keys []string) ([][ ...@@ -60,7 +61,7 @@ func (h *queryHelper) getStateMultipleKeys(namespace string, keys []string) ([][
return values, nil return values, nil
} }
func (h *queryHelper) getStateRangeScanIterator(namespace string, startKey string, endKey string) (ledger.ResultsIterator, error) { func (h *queryHelper) getStateRangeScanIterator(namespace string, startKey string, endKey string) (commonledger.ResultsIterator, error) {
h.checkDone() h.checkDone()
itr, err := newResultsItr(namespace, startKey, endKey, h.txmgr.db, h.rwset) itr, err := newResultsItr(namespace, startKey, endKey, h.txmgr.db, h.rwset)