From 2c6f53e17fb4a5ffba277dace7145f98bfc547f4 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 2 Nov 2023 13:53:45 -0400 Subject: [PATCH] Add updateIbcMarkerDenomMetadata to saffron and add logs to method. Create test for rc2 and update existing tests to have logs. --- app/upgrades.go | 8 ++++++-- app/upgrades_test.go | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index e52df8dbc8..1784bdc491 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -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) @@ -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 @@ -153,6 +153,7 @@ var upgrades = map[string]appUpgrade{ setupICQ(ctx, app) updateMaxSupply(ctx, app) setExchangeParams(ctx, app) + updateIbcMarkerDenomMetadata(ctx, app) return vm, nil }, @@ -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(), @@ -402,4 +405,5 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { } return false }) + ctx.Logger().Info("Done updating ibc marker denom metadata") } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index f264b24dee..1a7aa2a0bc 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -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. @@ -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)