From 1975c98e3843f96d91f2769cfe855fac3d8a8e76 Mon Sep 17 00:00:00 2001 From: BabyHalimao Date: Sun, 2 Jun 2024 16:47:25 +0800 Subject: [PATCH 1/2] fix: append to slice with non-zero initialized length --- modules/capability/simulation/genesis_test.go | 2 +- testing/simapp/app.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/capability/simulation/genesis_test.go b/modules/capability/simulation/genesis_test.go index b4176fe25d5..18d2520533b 100644 --- a/modules/capability/simulation/genesis_test.go +++ b/modules/capability/simulation/genesis_test.go @@ -45,7 +45,7 @@ func TestRandomizedGenState(t *testing.T) { require.Len(t, capGenesis.Owners, 0) } -// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. +// TestRandomizedGenState1 tests abnormal scenarios of applying RandomizedGenState. func TestRandomizedGenState1(t *testing.T) { interfaceRegistry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(interfaceRegistry) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 5b52e5f1f52..8f6f4def7c6 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -934,7 +934,7 @@ func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { // GetStoreKeys returns all the stored store keys. func (app *SimApp) GetStoreKeys() []storetypes.StoreKey { - keys := make([]storetypes.StoreKey, len(app.keys)) + keys := make([]storetypes.StoreKey, 0, len(app.keys)) for _, key := range app.keys { keys = append(keys, key) } From ae3f860db663f63701599bb382bce6185101286e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 3 Jun 2024 16:30:22 +0200 Subject: [PATCH 2/2] set zero length for slices --- modules/apps/callbacks/testing/simapp/app.go | 2 +- modules/light-clients/08-wasm/testing/simapp/app.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index de62728bfa8..2cad843b1a8 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -949,7 +949,7 @@ func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { // GetStoreKeys returns all the stored store keys. func (app *SimApp) GetStoreKeys() []storetypes.StoreKey { - keys := make([]storetypes.StoreKey, len(app.keys)) + keys := make([]storetypes.StoreKey, 0, len(app.keys)) for _, key := range app.keys { keys = append(keys, key) } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 9370edef704..c663f035104 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -999,7 +999,7 @@ func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { // GetStoreKeys returns all the stored store keys. func (app *SimApp) GetStoreKeys() []storetypes.StoreKey { - keys := make([]storetypes.StoreKey, len(app.keys)) + keys := make([]storetypes.StoreKey, 0, len(app.keys)) for _, key := range app.keys { keys = append(keys, key) }