Skip to content

Commit 4ef0dc9

Browse files
committed
Do not panic when getting params.
1 parent adb29be commit 4ef0dc9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

modules/core/03-connection/keeper/keeper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ func (k Keeper) addConnectionToClient(ctx sdk.Context, clientID, connectionID st
226226
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
227227
store := ctx.KVStore(k.storeKey)
228228
bz := store.Get([]byte(types.ParamsKey))
229-
if bz == nil { // only panic on unset params and not on empty params
230-
panic("controller params are not set in store")
229+
if len(bz) == 0 {
230+
return types.Params{}
231231
}
232232

233233
var params types.Params

modules/core/03-connection/keeper/keeper_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,12 @@ func (suite *KeeperTestSuite) TestParams() {
217217
}
218218
}
219219

220-
// TestUnsetParams tests that trying to get params that are not set panics.
220+
// TestUnsetParams tests that trying to get params that are not set results in empty params.
221221
func (suite *KeeperTestSuite) TestUnsetParams() {
222222
suite.SetupTest()
223223
ctx := suite.chainA.GetContext()
224224
store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.StoreKey))
225225
store.Delete([]byte(types.ParamsKey))
226226

227-
suite.Require().Panics(func() {
228-
suite.chainA.GetSimApp().IBCKeeper.ConnectionKeeper.GetParams(ctx)
229-
})
227+
suite.Require().Equal(suite.chainA.GetSimApp().IBCKeeper.ConnectionKeeper.GetParams(ctx), types.Params{})
230228
}

0 commit comments

Comments
 (0)