-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK v.0.44.3 & Tendrmint v0.34.14 & IBC v.1.2.3
- Loading branch information
1 parent
39d8910
commit 223c9ee
Showing
50 changed files
with
1,956 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package app_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/BitCannaGlobal/bcna/app" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
simulationtypes "github.com/cosmos/cosmos-sdk/types/simulation" | ||
"github.com/cosmos/cosmos-sdk/x/simulation" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tendermint/spm/cosmoscmd" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
) | ||
|
||
func init() { | ||
simapp.GetSimulatorFlags() | ||
} | ||
|
||
type SimApp interface { | ||
cosmoscmd.App | ||
GetBaseApp() *baseapp.BaseApp | ||
AppCodec() codec.Codec | ||
SimulationManager() *module.SimulationManager | ||
ModuleAccountAddrs() map[string]bool | ||
Name() string | ||
LegacyAmino() *codec.LegacyAmino | ||
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock | ||
EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock | ||
InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain | ||
} | ||
|
||
var defaultConsensusParams = &abci.ConsensusParams{ | ||
Block: &abci.BlockParams{ | ||
MaxBytes: 200000, | ||
MaxGas: 2000000, | ||
}, | ||
Evidence: &tmproto.EvidenceParams{ | ||
MaxAgeNumBlocks: 302400, | ||
MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration | ||
MaxBytes: 10000, | ||
}, | ||
Validator: &tmproto.ValidatorParams{ | ||
PubKeyTypes: []string{ | ||
tmtypes.ABCIPubKeyTypeEd25519, | ||
}, | ||
}, | ||
} | ||
|
||
// go test -benchmem -run=^$ -bench ^BenchmarkSimulation -Commit=true -cpuprofile cpu.out | ||
func BenchmarkSimulation(b *testing.B) { | ||
simapp.FlagEnabledValue = true | ||
simapp.FlagNumBlocksValue = 200 | ||
simapp.FlagBlockSizeValue = 50 | ||
simapp.FlagCommitValue = true | ||
simapp.FlagVerboseValue = true | ||
|
||
config, db, dir, logger, _, err := simapp.SetupSimulation("goleveldb-app-sim", "Simulation") | ||
require.NoError(b, err, "simulation setup failed") | ||
|
||
b.Cleanup(func() { | ||
db.Close() | ||
err = os.RemoveAll(dir) | ||
require.NoError(b, err) | ||
}) | ||
|
||
encoding := cosmoscmd.MakeEncodingConfig(app.ModuleBasics) | ||
|
||
app := app.New( | ||
logger, | ||
db, | ||
nil, | ||
true, | ||
map[int64]bool{}, | ||
app.DefaultNodeHome, | ||
0, | ||
encoding, | ||
simapp.EmptyAppOptions{}, | ||
) | ||
|
||
simApp, ok := app.(SimApp) | ||
require.True(b, ok, "can't use simapp") | ||
|
||
// Run randomized simulations | ||
_, simParams, simErr := simulation.SimulateFromSeed( | ||
b, | ||
os.Stdout, | ||
simApp.GetBaseApp(), | ||
simapp.AppStateFn(simApp.AppCodec(), simApp.SimulationManager()), | ||
simulationtypes.RandomAccounts, | ||
simapp.SimulationOperations(simApp, simApp.AppCodec(), config), | ||
simApp.ModuleAccountAddrs(), | ||
config, | ||
simApp.AppCodec(), | ||
) | ||
|
||
// export state and simParams before the simulation error is checked | ||
err = simapp.CheckExportSimulation(simApp, config, simParams) | ||
require.NoError(b, err) | ||
require.NoError(b, simErr) | ||
|
||
if config.Commit { | ||
simapp.PrintStats(db) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.