Skip to content

Commit 1279870

Browse files
denyeartmastersingh24
authored andcommitted
Fix txmgr test failure - CouchDB query limit
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 <[email protected]>
1 parent e9fa9ad commit 1279870

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

core/ledger/kvledger/txmgmt/txmgr/commontests/txmgr_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ import (
2424
"github.com/hyperledger/fabric/common/ledger/testutil"
2525
"github.com/hyperledger/fabric/core/ledger"
2626
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/version"
27+
ledgertestutil "github.com/hyperledger/fabric/core/ledger/testutil"
2728
)
2829

30+
func TestMain(m *testing.M) {
31+
ledgertestutil.SetupCoreYAMLConfig("./../../../../../../peer")
32+
}
33+
2934
func TestTxSimulatorWithNoExistingData(t *testing.T) {
3035
// run the tests for each environment configured in pkg_test.go
3136
for _, testEnv := range testEnvs {
@@ -390,7 +395,6 @@ func testIteratorWithDeletes(t *testing.T, env testEnv) {
390395
defer itr.Close()
391396
kv, _ := itr.Next()
392397
testutil.AssertEquals(t, kv.(*ledger.KV).Key, createTestKey(3))
393-
394398
kv, _ = itr.Next()
395399
testutil.AssertEquals(t, kv.(*ledger.KV).Key, createTestKey(5))
396400
}

core/ledger/ledgerconfig/ledger_config.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ func GetCouchDBDefinition() *CouchDBDef {
9191

9292
//GetQueryLimit exposes the queryLimit variable
9393
func GetQueryLimit() int {
94-
return viper.GetInt("ledger.state.queryLimit")
94+
queryLimit := viper.GetInt("ledger.state.queryLimit")
95+
// if queryLimit was unset, default to 10000
96+
if queryLimit == 0 {
97+
queryLimit = 10000
98+
}
99+
return queryLimit
95100
}
96101

97102
//IsHistoryDBEnabled exposes the historyDatabase variable

0 commit comments

Comments
 (0)