Skip to content

Commit

Permalink
Merge pull request #1032 from CosmWasm/revert_module_version
Browse files Browse the repository at this point in the history
Revert module version to 1 as there is no migration anymore
  • Loading branch information
alpe authored Oct 4, 2022
2 parents 84ba3f9 + 016e3bc commit f95e7c0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,17 @@ func NewWasmApp(
// Name returns the name of the App
func (app *WasmApp) Name() string { return app.BaseApp.Name() }

// application updates every begin block
// ModuleManager returns instance
func (app *WasmApp) ModuleManager() module.Manager {
return *app.mm
}

// ModuleConfigurator returns instance
func (app *WasmApp) ModuleConfigurator() module.Configurator {
return app.configurator
}

// BeginBlocker application updates every begin block
func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type AppModule struct {
// module. It should be incremented on each consensus-breaking change
// introduced by the module. To avoid wrong/empty versions, the initial version
// should be set to 1.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 1 }

// NewAppModule creates a new AppModule object
func NewAppModule(
Expand Down
31 changes: 31 additions & 0 deletions x/wasm/module_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package wasm_test

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm"
)

func TestModuleMigrations(t *testing.T) {
wasmApp := app.Setup(false)
ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{})
upgradeHandler := func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return wasmApp.ModuleManager().RunMigrations(ctx, wasmApp.ModuleConfigurator(), fromVM)
}
fromVM := wasmApp.UpgradeKeeper.GetModuleVersionMap(ctx)
fromVM[wasm.ModuleName] = 1 // start with initial version
upgradeHandler(ctx, upgradetypes.Plan{Name: "testing"}, fromVM)
// when
gotVM, err := wasmApp.ModuleManager().RunMigrations(ctx, wasmApp.ModuleConfigurator(), fromVM)
// then
require.NoError(t, err)
assert.Equal(t, uint64(1), gotVM[wasm.ModuleName])
}

0 comments on commit f95e7c0

Please sign in to comment.