Skip to content

Commit 4ba6fcd

Browse files
committed
feat: switch to testutil from chain-sdk
Signed-off-by: Artur Troian <[email protected]>
1 parent 3f4c1bc commit 4ba6fcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+245
-2238
lines changed

app/app.go

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import (
4848
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
4949
"github.com/cosmos/cosmos-sdk/x/authz"
5050
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
51-
"github.com/cosmos/cosmos-sdk/x/crisis"
5251
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
5352
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
5453
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
@@ -72,8 +71,6 @@ import (
7271

7372
apptypes "pkg.akt.dev/node/app/types"
7473
utypes "pkg.akt.dev/node/upgrades/types"
75-
astaking "pkg.akt.dev/node/x/staking"
76-
7774
// unnamed import of statik for swagger UI support
7875
_ "pkg.akt.dev/node/client/docs/statik"
7976
)
@@ -170,10 +167,6 @@ func NewApp(
170167
// because I believe the concept of Routes is going away.
171168
app.SetupHooks()
172169

173-
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment,
174-
// we prefer to be more strict in what arguments the modules expect.
175-
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
176-
177170
// NOTE: All module / keeper changes should happen prior to this module.NewManager line being called.
178171
// However, in the event any changes do need to happen after this call, ensure that that keeper
179172
// is only passed in its keeper form (not de-ref'd anywhere)
@@ -183,7 +176,7 @@ func NewApp(
183176
//
184177
// Any time a module requires a keeper de-ref'd that's not its native one,
185178
// its code-smell and should probably change. We should get the staking keeper dependencies fixed.
186-
modules := appModules(app, encodingConfig, skipGenesisInvariants)
179+
modules := appModules(app, encodingConfig)
187180

188181
app.MM = module.NewManager(modules...)
189182

@@ -194,18 +187,16 @@ func NewApp(
194187
// NOTE: capability module's begin-blocker must come before any modules using capabilities (e.g. IBC)
195188

196189
// Upgrades from v0.50.x onwards happen in pre block
197-
//app.MM.SetOrderPreBlockers(
198-
// upgradetypes.ModuleName,
199-
// authtypes.ModuleName,
200-
//)
190+
app.MM.SetOrderPreBlockers(
191+
upgradetypes.ModuleName,
192+
authtypes.ModuleName,
193+
)
201194

202195
// Tell the app's module manager how to set the order of BeginBlockers, which are run at the beginning of every block.
203196
app.MM.SetOrderBeginBlockers(orderBeginBlockers(app.MM.ModuleNames())...)
204197

205198
app.MM.SetOrderInitGenesis(OrderInitGenesis(app.MM.ModuleNames())...)
206199

207-
app.MM.RegisterInvariants(app.Keepers.Cosmos.Crisis)
208-
209200
app.Configurator = module.NewConfigurator(app.AppCodec(), app.MsgServiceRouter(), app.GRPCQueryRouter())
210201
err := app.MM.RegisterServices(app.Configurator)
211202
if err != nil {
@@ -217,16 +208,6 @@ func NewApp(
217208
panic(err)
218209
}
219210

220-
// Override the gov ModuleBasic with all the custom proposal handers, otherwise we lose them in the CLI.
221-
//app.ModuleBasics = module.NewBasicManagerFromManager(
222-
// app.MM,
223-
// map[string]module.AppModuleBasic{
224-
// "gov": gov.NewAppModuleBasic(
225-
// []govclient.ProposalHandler{},
226-
// ),
227-
// },
228-
//)
229-
230211
app.sm = module.NewSimulationManager(appSimModules(app, encodingConfig)...)
231212
app.sm.RegisterStoreDecoders()
232213

@@ -297,7 +278,6 @@ func orderBeginBlockers(_ []string) []string {
297278
audittypes.ModuleName,
298279
genutiltypes.ModuleName,
299280
vestingtypes.ModuleName,
300-
//crisistypes.ModuleName,
301281
authtypes.ModuleName,
302282
authz.ModuleName,
303283
taketypes.ModuleName,
@@ -307,7 +287,6 @@ func orderBeginBlockers(_ []string) []string {
307287
slashingtypes.ModuleName,
308288
evidencetypes.ModuleName,
309289
stakingtypes.ModuleName,
310-
//astaking.ModuleName,
311290
transfertypes.ModuleName,
312291
ibchost.ModuleName,
313292
feegrant.ModuleName,
@@ -317,10 +296,8 @@ func orderBeginBlockers(_ []string) []string {
317296
// OrderEndBlockers returns EndBlockers (crisis, govtypes, staking) with no relative order.
318297
func OrderEndBlockers(_ []string) []string {
319298
return []string{
320-
//crisistypes.ModuleName,
321299
govtypes.ModuleName,
322300
stakingtypes.ModuleName,
323-
astaking.ModuleName,
324301
upgradetypes.ModuleName,
325302
capabilitytypes.ModuleName,
326303
banktypes.ModuleName,

app/app_configure.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import (
99
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
1010
"github.com/cosmos/cosmos-sdk/x/authz"
1111
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
12-
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
13-
14-
//capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
1512
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
1613
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
1714
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
@@ -21,7 +18,7 @@ import (
2118
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
2219
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
2320
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
24-
21+
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
2522
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
2623
ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported"
2724

@@ -32,11 +29,8 @@ import (
3229
"pkg.akt.dev/node/x/cert"
3330
"pkg.akt.dev/node/x/deployment"
3431
"pkg.akt.dev/node/x/escrow"
35-
//agov "pkg.akt.dev/node/x/gov"
36-
//"pkg.akt.dev/node/x/inflation"
3732
"pkg.akt.dev/node/x/market"
3833
"pkg.akt.dev/node/x/provider"
39-
astaking "pkg.akt.dev/node/x/staking"
4034
"pkg.akt.dev/node/x/take"
4135
)
4236

@@ -49,8 +43,6 @@ func akashModuleBasics() []module.AppModuleBasic {
4943
provider.AppModuleBasic{},
5044
audit.AppModuleBasic{},
5145
cert.AppModuleBasic{},
52-
//astaking.AppModuleBasic{},
53-
//agov.AppModuleBasic{},
5446
}
5547
}
5648

@@ -87,9 +79,6 @@ func OrderInitGenesis(_ []string) []string {
8779
deployment.ModuleName,
8880
provider.ModuleName,
8981
market.ModuleName,
90-
//inflation.ModuleName,
91-
astaking.ModuleName,
92-
//agov.ModuleName,
9382
genutiltypes.ModuleName,
9483
}
9584
}

app/app_test.go

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
package app
22

3-
import (
4-
"testing"
5-
)
6-
7-
func TestAkashApp_Export(t *testing.T) {
8-
//app := Setup(
9-
// WithCheckTx(false),
10-
// WithHome(DefaultHome),
11-
// WithGenesis(GenesisStateWithValSet),
12-
//)
13-
//
14-
//_, err := app.ExportAppStateAndValidators(true, []string{}, []string{})
15-
//require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
16-
//db := dbm.NewMemDB()
17-
//app1 := NewApp(log.NewTestLogger(t),
18-
// db, nil, true, 0, map[int64]bool{}, DefaultHome, OptsWithGenesisTime(0))
19-
//
20-
//for acc := range MacPerms() {
21-
// require.Equal(t, !allowedReceivingModAcc[acc], app1.Keepers.Cosmos.Bank.BlockedAddr(app1.Keepers.Cosmos.Acct.GetModuleAddress(acc)),
22-
// "ensure that blocked addresses are properly set in bank keeper")
23-
//}
24-
//
25-
//genesisState := NewDefaultGenesisState()
26-
//stateBytes, err := json.MarshalIndent(genesisState, "", " ")
27-
//require.NoError(t, err)
28-
//
29-
//// Initialize the chain
30-
//app1.InitChain(
31-
// abci.RequestInitChain{
32-
// Validators: []abci.ValidatorUpdate{},
33-
// AppStateBytes: stateBytes,
34-
// },
35-
//)
36-
//app1.Commit()
37-
//
38-
//// Making a new app object with the db, so that initchain hasn't been called
39-
//app2 := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, map[int64]bool{}, DefaultHome, OptsWithGenesisTime(0))
40-
//_, err = app2.ExportAppStateAndValidators(false, []string{})
41-
//require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
42-
}
3+
//import (
4+
// "os"
5+
// "testing"
6+
//
7+
// "cosmossdk.io/log"
8+
// dbm "github.com/cosmos/cosmos-db"
9+
// "github.com/stretchr/testify/require"
10+
//)
11+
//
12+
//func TestAkashApp_Export(t *testing.T) {
13+
// app := Setup(
14+
// WithCheckTx(false),
15+
// WithHome(DefaultHome),
16+
// WithGenesis(GenesisStateWithValSet),
17+
// )
18+
//
19+
// _, err := app.ExportAppStateAndValidators(true, []string{}, []string{})
20+
// require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
21+
// db := dbm.NewMemDB()
22+
// app1 := NewApp(log.NewTestLogger(t),
23+
// db, nil, true, 0, map[int64]bool{}, DefaultHome, OptsWithGenesisTime(0))
24+
//
25+
// for acc := range MacPerms() {
26+
// require.Equal(t, !allowedReceivingModAcc[acc], app1.Keepers.Cosmos.Bank.BlockedAddr(app1.Keepers.Cosmos.Acct.GetModuleAddress(acc)),
27+
// "ensure that blocked addresses are properly set in bank keeper")
28+
// }
29+
//
30+
// genesisState := NewDefaultGenesisState()
31+
// stateBytes, err := json.MarshalIndent(genesisState, "", " ")
32+
// require.NoError(t, err)
33+
//
34+
// // Initialize the chain
35+
// app1.InitChain(
36+
// abci.RequestInitChain{
37+
// Validators: []abci.ValidatorUpdate{},
38+
// AppStateBytes: stateBytes,
39+
// },
40+
// )
41+
// app1.Commit()
42+
//
43+
// // Making a new app object with the db, so that initchain hasn't been called
44+
// app2 := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, map[int64]bool{}, DefaultHome, OptsWithGenesisTime(0))
45+
// _, err = app2.ExportAppStateAndValidators(false, []string{})
46+
// require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
47+
//}

app/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ var mbasics = module.NewBasicManager(
4848
gov.NewAppModuleBasic(
4949
[]govclient.ProposalHandler{
5050
paramsclient.ProposalHandler,
51-
// distrclient.ProposalHandler,
52-
//upgradeclient.LegacyProposalHandler,
53-
//upgradeclient.LegacyCancelProposalHandler,
54-
//ibcclient.UpdateClientProposalHandler,
55-
//ibcclient.UpgradeProposalHandler,
5651
},
5752
),
5853
// chain parameters

app/decorators/min_commision.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

app/export.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ func (app *AkashApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
8585
allowedAddrsMap[addr] = true
8686
}
8787

88-
/* Just to be safe, assert the invariants on current state. */
89-
app.Keepers.Cosmos.Crisis.AssertInvariants(ctx)
90-
9188
/* Handle fee distribution state. */
9289

9390
// withdraw all validator commission

0 commit comments

Comments
 (0)