Skip to content

Commit f59dbcc

Browse files
authored
chore: remove mock from top level simapp app.go (#7444)
* chore: remove mock from top level simapp app.go * chore: remove memkey references
1 parent 710c71c commit f59dbcc

File tree

1 file changed

+4
-75
lines changed

1 file changed

+4
-75
lines changed

simapp/app.go

+4-75
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,10 @@ import (
123123
ibckeeper "github.com/cosmos/ibc-go/v9/modules/core/keeper"
124124
solomachine "github.com/cosmos/ibc-go/v9/modules/light-clients/06-solomachine"
125125
ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint"
126-
"github.com/cosmos/ibc-go/v9/testing/mock"
127126
)
128127

129128
const appName = "SimApp"
130129

131-
// IBC application testing ports
132-
const (
133-
MockFeePort string = mock.ModuleName + ibcfeetypes.ModuleName
134-
)
135-
136130
var (
137131
// DefaultNodeHome default home directories for the application daemon
138132
DefaultNodeHome string
@@ -148,7 +142,6 @@ var (
148142
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
149143
ibcfeetypes.ModuleName: nil,
150144
icatypes.ModuleName: nil,
151-
mock.ModuleName: nil,
152145
}
153146
)
154147

@@ -167,9 +160,8 @@ type SimApp struct {
167160
interfaceRegistry types.InterfaceRegistry
168161

169162
// keys to access the substores
170-
keys map[string]*storetypes.KVStoreKey
171-
tkeys map[string]*storetypes.TransientStoreKey
172-
memKeys map[string]*storetypes.MemoryStoreKey
163+
keys map[string]*storetypes.KVStoreKey
164+
tkeys map[string]*storetypes.TransientStoreKey
173165

174166
// keepers
175167
AccountKeeper authkeeper.AccountKeeper
@@ -194,12 +186,6 @@ type SimApp struct {
194186
ConsensusParamsKeeper consensusparamkeeper.Keeper
195187
CircuitKeeper circuitkeeper.Keeper
196188

197-
// make IBC modules public for test purposes
198-
// these modules are never directly routed to by the IBC Router
199-
IBCMockModule mock.IBCModule
200-
ICAAuthModule mock.IBCModule
201-
FeeMockModule mock.IBCModule
202-
203189
// the module manager
204190
ModuleManager *module.Manager
205191
BasicModuleManager module.BasicManager
@@ -293,7 +279,6 @@ func NewSimApp(
293279
}
294280

295281
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
296-
memKeys := storetypes.NewMemoryStoreKeys(mock.MemStoreKey)
297282

298283
app := &SimApp{
299284
BaseApp: bApp,
@@ -303,7 +288,6 @@ func NewSimApp(
303288
interfaceRegistry: interfaceRegistry,
304289
keys: keys,
305290
tkeys: tkeys,
306-
memKeys: memKeys,
307291
}
308292

309293
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
@@ -430,25 +414,6 @@ func NewSimApp(
430414
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
431415
)
432416

433-
// Mock Module Stack
434-
435-
// Mock Module setup for testing IBC and also acts as the interchain accounts authentication module
436-
// NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
437-
// not replicate if you do not need to test core IBC or light clients.
438-
mockModule := mock.NewAppModule()
439-
440-
// The mock module is used for testing IBC
441-
mockIBCModule := mock.NewIBCModule(&mockModule, mock.NewIBCApp(mock.ModuleName))
442-
app.IBCMockModule = mockIBCModule
443-
ibcRouter.AddRoute(mock.ModuleName, mockIBCModule)
444-
445-
// Mock IBC app wrapped with a middleware which does not implement the UpgradeableModule interface.
446-
// NOTE: this is used to test integration with apps which do not yet fulfill the UpgradeableModule interface and error when
447-
// an upgrade is tried on the channel.
448-
mockBlockUpgradeIBCModule := mock.NewIBCModule(&mockModule, mock.NewIBCApp(mock.MockBlockUpgrade))
449-
mockBlockUpgradeMw := mock.NewBlockUpgradeMiddleware(&mockModule, mockBlockUpgradeIBCModule.IBCApp)
450-
ibcRouter.AddRoute(mock.MockBlockUpgrade, mockBlockUpgradeMw)
451-
452417
// Create Transfer Stack
453418
// SendPacket, since it is originating from the application to core IBC:
454419
// transferKeeper.SendPacket -> fee.SendPacket -> channel.SendPacket
@@ -471,15 +436,7 @@ func NewSimApp(
471436
// Create Interchain Accounts Stack
472437
// SendPacket, since it is originating from the application to core IBC:
473438
// icaControllerKeeper.SendTx -> fee.SendPacket -> channel.SendPacket
474-
475-
// initialize ICA module with mock module as the authentication module on the controller side
476439
var icaControllerStack porttypes.IBCModule
477-
icaControllerStack = mock.NewIBCModule(&mockModule, mock.NewIBCApp(""))
478-
var ok bool
479-
app.ICAAuthModule, ok = icaControllerStack.(mock.IBCModule)
480-
if !ok {
481-
panic(fmt.Errorf("cannot convert %T into %T", icaControllerStack, app.ICAAuthModule))
482-
}
483440
icaControllerStack = icacontroller.NewIBCMiddleware(app.ICAControllerKeeper)
484441
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)
485442

@@ -493,23 +450,7 @@ func NewSimApp(
493450
// Add host, controller & ica auth modules to IBC router
494451
ibcRouter.
495452
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
496-
AddRoute(icahosttypes.SubModuleName, icaHostStack).
497-
AddRoute(mock.ModuleName+icacontrollertypes.SubModuleName, icaControllerStack) // ica with mock auth module stack route to ica (top level of middleware stack)
498-
499-
// Create Mock IBC Fee module stack for testing
500-
// SendPacket, mock module cannot send packets
501-
502-
// OnRecvPacket, message that originates from core IBC and goes down to app, the flow is the otherway
503-
// channel.RecvPacket -> fee.OnRecvPacket -> mockModule.OnRecvPacket
504-
505-
// OnAcknowledgementPacket as this is where fee's are paid out
506-
// mockModule.OnAcknowledgementPacket -> fee.OnAcknowledgementPacket -> channel.OnAcknowledgementPacket
507-
508-
// create fee wrapped mock module
509-
feeMockModule := mock.NewIBCModule(&mockModule, mock.NewIBCApp(MockFeePort))
510-
app.FeeMockModule = feeMockModule
511-
feeWithMockModule := ibcfee.NewIBCMiddleware(feeMockModule, app.IBCFeeKeeper)
512-
ibcRouter.AddRoute(MockFeePort, feeWithMockModule)
453+
AddRoute(icahosttypes.SubModuleName, icaHostStack)
513454

514455
// Seal the IBC Router
515456
app.IBCKeeper.SetRouter(ibcRouter)
@@ -566,7 +507,6 @@ func NewSimApp(
566507
transfer.NewAppModule(app.TransferKeeper),
567508
ibcfee.NewAppModule(app.IBCFeeKeeper),
568509
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
569-
mockModule,
570510

571511
// IBC light clients
572512
ibctm.NewAppModule(tmLightClientModule),
@@ -611,7 +551,6 @@ func NewSimApp(
611551
authz.ModuleName,
612552
icatypes.ModuleName,
613553
ibcfeetypes.ModuleName,
614-
mock.ModuleName,
615554
)
616555
app.ModuleManager.SetOrderEndBlockers(
617556
crisistypes.ModuleName,
@@ -623,7 +562,6 @@ func NewSimApp(
623562
feegrant.ModuleName,
624563
icatypes.ModuleName,
625564
ibcfeetypes.ModuleName,
626-
mock.ModuleName,
627565
group.ModuleName,
628566
)
629567

@@ -635,7 +573,7 @@ func NewSimApp(
635573
banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
636574
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
637575
ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName,
638-
icatypes.ModuleName, ibcfeetypes.ModuleName, mock.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
576+
icatypes.ModuleName, ibcfeetypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
639577
vestingtypes.ModuleName, group.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName,
640578
}
641579
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
@@ -680,7 +618,6 @@ func NewSimApp(
680618
// initialize stores
681619
app.MountKVStores(keys)
682620
app.MountTransientStores(tkeys)
683-
app.MountMemoryStores(memKeys)
684621

685622
// initialize BaseApp
686623
app.SetInitChainer(app.InitChainer)
@@ -949,7 +886,6 @@ func BlockedAddresses() map[string]bool {
949886

950887
// allow the following addresses to receive funds
951888
delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())
952-
delete(modAccAddrs, authtypes.NewModuleAddress(mock.ModuleName).String())
953889

954890
return modAccAddrs
955891
}
@@ -968,10 +904,3 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
968904

969905
return paramsKeeper
970906
}
971-
972-
// GetMemKey returns the MemStoreKey for the provided mem key.
973-
//
974-
// NOTE: This is solely used for testing purposes.
975-
func (app *SimApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
976-
return app.memKeys[storeKey]
977-
}

0 commit comments

Comments
 (0)