Skip to content

Commit

Permalink
Add updateIbcMarkerDenomMetadata to saffron and add logs to method. C…
Browse files Browse the repository at this point in the history
…reate test for rc2 and update existing tests to have logs.
  • Loading branch information
Matthew Witkowski committed Nov 2, 2023
1 parent 3e71863 commit 2c6f53e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var upgrades = map[string]appUpgrade{
},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName},
},
"saffron-rc2": {
"saffron-rc2": { // upgrade for v1.17.0-rc2
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
vm, err = runModuleMigrations(ctx, app, vm)
Expand All @@ -137,7 +137,7 @@ var upgrades = map[string]appUpgrade{

return vm, nil
},
}, // upgrade for v1.17.0-rc2
},
"saffron": { // upgrade for v1.17.0,
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
Expand All @@ -153,6 +153,7 @@ var upgrades = map[string]appUpgrade{
setupICQ(ctx, app)
updateMaxSupply(ctx, app)
setExchangeParams(ctx, app)
updateIbcMarkerDenomMetadata(ctx, app)

return vm, nil
},
Expand Down Expand Up @@ -382,11 +383,13 @@ func setExchangeParams(ctx sdk.Context, app *App) {
// updateIbcMarkerDenomMetadata iterates markers and creates denom metadata for ibc markers
// TODO: Remove with the saffron handlers.
func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {
ctx.Logger().Info("Updating ibc marker denom metadata")
app.MarkerKeeper.IterateMarkers(ctx, func(record types.MarkerAccountI) bool {
if strings.HasSuffix(record.GetDenom(), "ibc/") {
denomTrace := transfertypes.ParseDenomTrace(record.GetDenom())
parts := strings.Split(denomTrace.Path, "/")
if len(parts) == 2 && parts[0] == "transfer" {
ctx.Logger().Info(fmt.Sprintf("Adding metadata to %s", record.GetDenom()))
chainID := app.Ics20MarkerHooks.GetChainID(ctx, parts[0], parts[1], app.IBCKeeper)
markerMetadata := banktypes.Metadata{
Base: record.GetDenom(),
Expand All @@ -402,4 +405,5 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {
}
return false

Check warning on line 406 in app/upgrades.go

View check run for this annotation

Codecov / codecov/patch

app/upgrades.go#L406

Added line #L406 was not covered by tests
})
ctx.Logger().Info("Done updating ibc marker denom metadata")
}
14 changes: 14 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,18 @@ func (s *UpgradeTestSuite) TestSaffronRC1() {
s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil)
}

func (s *UpgradeTestSuite) TestSaffronRC2() {
// Each part is (hopefully) tested thoroughly on its own.
// So for this test, just make sure there's log entries for each part being done.

expInLog := []string{
"INF Updating ibc marker denom metadata",
"INF Done updating ibc marker denom metadata",
}

s.AssertUpgradeHandlerLogs("saffron-rc2", expInLog, nil)
}

func (s *UpgradeTestSuite) TestSaffron() {
// Each part is (hopefully) tested thoroughly on its own.
// So for this test, just make sure there's log entries for each part being done.
Expand All @@ -445,6 +457,8 @@ func (s *UpgradeTestSuite) TestSaffron() {
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
"INF Ensuring exchange module params are set.",
"INF Updating ibc marker denom metadata",
"INF Done updating ibc marker denom metadata",
}

s.AssertUpgradeHandlerLogs("saffron", expInLog, nil)
Expand Down

0 comments on commit 2c6f53e

Please sign in to comment.