Skip to content

Commit

Permalink
Fix txmgr test failure - CouchDB query limit
Browse files Browse the repository at this point in the history
Test failure:
FAIL: TestIteratorWithDeletes
panic: interface conversion: ledger.QueryResult is nil, not *ledger.KV

Fix is to set the default ledger.state.queryLimit,
which was changed in https://gerrit.hyperledger.org/r/#/c/6683/.

Change-Id: Ic8f2f2057e75d5fdab7982214b022875f3888a8f
Signed-off-by: denyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart authored and mastersingh24 committed Mar 26, 2017
1 parent e9fa9ad commit 1279870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/ledger/kvledger/txmgmt/txmgr/commontests/txmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ import (
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil"
)

func TestMain(m *testing.M) {
ledgertestutil.SetupCoreYAMLConfig("./../../../../../../peer")
}

func TestTxSimulatorWithNoExistingData(t *testing.T) {
// run the tests for each environment configured in pkg_test.go
for _, testEnv := range testEnvs {
Expand Down Expand Up @@ -390,7 +395,6 @@ func testIteratorWithDeletes(t *testing.T, env testEnv) {
defer itr.Close()
kv, _ := itr.Next()
testutil.AssertEquals(t, kv.(*ledger.KV).Key, createTestKey(3))

kv, _ = itr.Next()
testutil.AssertEquals(t, kv.(*ledger.KV).Key, createTestKey(5))
}
Expand Down
7 changes: 6 additions & 1 deletion core/ledger/ledgerconfig/ledger_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ func GetCouchDBDefinition() *CouchDBDef {

//GetQueryLimit exposes the queryLimit variable
func GetQueryLimit() int {
return viper.GetInt("ledger.state.queryLimit")
queryLimit := viper.GetInt("ledger.state.queryLimit")
// if queryLimit was unset, default to 10000
if queryLimit == 0 {
queryLimit = 10000
}
return queryLimit
}

//IsHistoryDBEnabled exposes the historyDatabase variable
Expand Down

0 comments on commit 1279870

Please sign in to comment.