Co-authored-by: mmsqe <tqd0800210105@gmail.com> Co-authored-by: aljo242 <alex@interchainlabs.io>
This commit is contained in:
parent
abbb0acf5a
commit
20c63a9d01
4
.github/workflows/dependabot-update-all.yml
vendored
4
.github/workflows/dependabot-update-all.yml
vendored
@ -14,11 +14,7 @@ jobs:
|
||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||
steps:
|
||||
- name: Generate Token
|
||||
<<<<<<< HEAD
|
||||
uses: actions/create-github-app-token@3ff1caaa28b64c9cc276ce0a02e2ff584f3900c5 # v1
|
||||
=======
|
||||
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v1
|
||||
>>>>>>> acb39aa52 (build(deps): Bump actions/create-github-app-token from 2.0.3 to 2.0.6 (#24673))
|
||||
id: app-token
|
||||
with:
|
||||
app-id: "${{ secrets.APP_ID }}"
|
||||
|
||||
@ -36,6 +36,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* (x/epochs) [#24770](https://github.com/cosmos/cosmos-sdk/pull/24770) Fix register of epoch hooks in `InvokeSetHooks`.
|
||||
|
||||
## [v0.53.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.53.0) - 2025-04-29
|
||||
|
||||
### Features
|
||||
|
||||
@ -49,8 +49,8 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
return ModuleOutputs{EpochKeeper: k, Module: m}
|
||||
}
|
||||
|
||||
func InvokeSetHooks(keeper keeper.Keeper, hooks map[string]types.EpochHooksWrapper) error {
|
||||
if hooks == nil {
|
||||
func InvokeSetHooks(keeper *keeper.Keeper, hooks map[string]types.EpochHooksWrapper) error {
|
||||
if keeper == nil || hooks == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
60
x/epochs/depinject_test.go
Normal file
60
x/epochs/depinject_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
package epochs_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/epochs"
|
||||
"github.com/cosmos/cosmos-sdk/x/epochs/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/epochs/types"
|
||||
)
|
||||
|
||||
type testEpochHooks struct{}
|
||||
|
||||
func (h testEpochHooks) AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h testEpochHooks) BeforeEpochStart(ctx context.Context, epochIdentifier string, epochNumber int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestInvokeSetHooks(t *testing.T) {
|
||||
// Create a mock keeper
|
||||
key := storetypes.NewKVStoreKey(types.StoreKey)
|
||||
storeService := runtime.NewKVStoreService(key)
|
||||
encCfg := testutil.MakeTestEncodingConfig()
|
||||
mockKeeper := keeper.NewKeeper(storeService, encCfg.Codec)
|
||||
|
||||
// Create mock hooks
|
||||
hook1 := types.EpochHooksWrapper{
|
||||
EpochHooks: testEpochHooks{},
|
||||
}
|
||||
hook2 := types.EpochHooksWrapper{
|
||||
EpochHooks: testEpochHooks{},
|
||||
}
|
||||
hooks := map[string]types.EpochHooksWrapper{
|
||||
"moduleA": hook1,
|
||||
"moduleB": hook2,
|
||||
}
|
||||
|
||||
// Call InvokeSetHooks
|
||||
err := epochs.InvokeSetHooks(&mockKeeper, hooks)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify that hooks were set correctly
|
||||
require.NotNil(t, mockKeeper.Hooks())
|
||||
require.IsType(t, types.MultiEpochHooks{}, mockKeeper.Hooks())
|
||||
|
||||
// Verify the order of hooks (lexical order by module name)
|
||||
multiHooks := mockKeeper.Hooks().(types.MultiEpochHooks)
|
||||
require.Equal(t, 2, len(multiHooks))
|
||||
require.Equal(t, hook1, multiHooks[0])
|
||||
require.Equal(t, hook2, multiHooks[1])
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user