MCPcopy Create free account
hub / github.com/Sifchain/sifnode / TestIntegration

Function TestIntegration

integrationtest/integration_test.go:354–439  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

352}
353
354func TestIntegration(t *testing.T) {
355 overwriteFlag := flag.Bool("overwrite", false, "Overwrite test output")
356 flag.Parse()
357
358 tt := []TestCase{
359 TC1(t), TC2(t), TC3(t),
360 }
361
362 for _, tc := range tt {
363 t.Run(tc.Name, func(t *testing.T) {
364 ctx, app := test.CreateTestAppClpFromGenesis(false, func(app *sifapp.SifchainApp, genesisState sifapp.GenesisState) sifapp.GenesisState {
365 // Initialise token registry
366 trGs := &tokenregistrytypes.GenesisState{
367 Registry: &tokenregistrytypes.Registry{
368 Entries: []*tokenregistrytypes.RegistryEntry{
369 {Denom: "atom", BaseDenom: "atom", Decimals: 6, Permissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}},
370 {Denom: "cusdc", BaseDenom: "cusdc", Decimals: 6, Permissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}},
371 {Denom: "rowan", BaseDenom: "rowan", Decimals: 18, Permissions: []tokenregistrytypes.Permission{tokenregistrytypes.Permission_CLP}},
372 },
373 },
374 }
375 bz, _ := app.AppCodec().MarshalJSON(trGs)
376 genesisState["tokenregistry"] = bz
377
378 // Initialise wallet
379 bankGs := banktypes.DefaultGenesisState()
380 bankGs.Balances = append(bankGs.Balances, tc.Setup.Accounts...)
381 bz, _ = app.AppCodec().MarshalJSON(bankGs)
382 genesisState["bank"] = bz
383
384 // Set enabled margin pools
385 marginGs := margintypes.DefaultGenesis()
386 marginGs.Params.Pools = append(marginGs.Params.Pools, []string{"cusdc", "atom"}...)
387 bz, _ = app.AppCodec().MarshalJSON(marginGs)
388 genesisState["margin"] = bz
389
390 return genesisState
391 })
392
393 app.ClpKeeper.SetRewardParams(ctx, &tc.Setup.RewardsParams) //nolint
394 app.ClpKeeper.SetLiquidityProtectionParams(ctx, &tc.Setup.ProtectionParams) //nolint
395 app.ClpKeeper.SetPmtpParams(ctx, &tc.Setup.ShiftingParams) //nolint
396 app.ClpKeeper.SetProviderDistributionParams(ctx, &tc.Setup.ProviderParams) //nolint
397
398 clpSrv := clpkeeper.NewMsgServerImpl(app.ClpKeeper)
399 marginSrv := marginkeeper.NewMsgServerImpl(app.MarginKeeper)
400
401 for i, msg := range tc.Messages {
402 ctx = ctx.WithBlockHeight(int64(i))
403 app.BeginBlocker(ctx, abci.RequestBeginBlock{Header: types.Header{Height: ctx.BlockHeight()}})
404 switch msg := msg.(type) {
405 case *clptypes.MsgCreatePool:
406 _, err := clpSrv.CreatePool(sdk.WrapSDKContext(ctx), msg)
407 require.NoError(t, err)
408 case *clptypes.MsgAddLiquidity:
409 _, err := clpSrv.AddLiquidity(sdk.WrapSDKContext(ctx), msg)
410 require.NoError(t, err)
411 case *clptypes.MsgRemoveLiquidity:

Callers

nothing calls this directly

Calls 15

TC1Function · 0.85
TC2Function · 0.85
TC3Function · 0.85
endBlockFunction · 0.85
getResultsFunction · 0.85
writeResultsFunction · 0.85
getExpectedFunction · 0.85
AppCodecMethod · 0.80
SetRewardParamsMethod · 0.80
SetPmtpParamsMethod · 0.80

Tested by

no test coverage detected