-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes celestiaorg/celestia-app#3392 Opens celestiaorg/celestia-app#3472 Fixes a few bugs: 1. Previously all modules had `ExportGenesis` invoked on them even if they weren't supported by the current app version. Now we only call `ExportGenesis` for the modules that are supported by the current app version 2. The export command wasn't updated to account for the changes in celestiaorg/celestia-app#3320 which force us to mount stores after `app.New()` based on the current app version 3. The minfee module couldn't be exported b/c it didn't register a key table in `ExportGenesis` ## Testing I could export an app on app version 1 and 2. See [output](https://gist.github.com/rootulp/dfea2b5b40f7366b03706fc39321ceee)
- Loading branch information
Showing
13 changed files
with
237 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package app_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/celestiaorg/celestia-app/v2/app" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmversion "github.com/tendermint/tendermint/proto/tendermint/version" | ||
) | ||
|
||
func TestExportAppStateAndValidators(t *testing.T) { | ||
t.Run("should return exported app for version 1", func(t *testing.T) { | ||
forZeroHeight := true | ||
jailAllowedAddrs := []string{} | ||
testApp, _ := SetupTestAppWithUpgradeHeight(t, 3) | ||
|
||
exported, err := testApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) | ||
require.NoError(t, err) | ||
assert.NotNil(t, exported) | ||
assert.Equal(t, uint64(1), exported.ConsensusParams.Version.AppVersion) | ||
}) | ||
t.Run("should return exported app for version 2", func(t *testing.T) { | ||
forZeroHeight := false | ||
jailAllowedAddrs := []string{} | ||
|
||
testApp, _ := SetupTestAppWithUpgradeHeight(t, 3) | ||
upgradeToV2(t, testApp) | ||
|
||
exported, err := testApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) | ||
require.NoError(t, err) | ||
assert.NotNil(t, exported) | ||
// TODO: the following assertion is commented out because the exported app does not populate consensus params.version | ||
// assert.Equal(t, uint64(2), exported.ConsensusParams.Version.AppVersion) | ||
}) | ||
} | ||
|
||
func upgradeToV2(t *testing.T, testApp *app.App) { | ||
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ | ||
Height: 2, | ||
Version: tmversion.Consensus{App: 1}, | ||
}}) | ||
// Upgrade from v1 -> v2 | ||
testApp.EndBlock(abci.RequestEndBlock{Height: 2}) | ||
testApp.Commit() | ||
require.EqualValues(t, 2, testApp.AppVersion()) | ||
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ | ||
Height: 3, | ||
Version: tmversion.Consensus{App: 2}, | ||
}}) | ||
testApp.EndBlock(abci.RequestEndBlock{Height: 3}) | ||
testApp.Commit() | ||
require.EqualValues(t, 3, testApp.LastBlockHeight()) | ||
} |
Oops, something went wrong.