forked from cerc-io/laconicd-deprecated
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/cerc-io/laconicd/encoding"
|
|
"github.com/cosmos/cosmos-sdk/db/memdb"
|
|
"github.com/cosmos/cosmos-sdk/simapp"
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
)
|
|
|
|
func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
|
|
db := memdb.NewDB()
|
|
logger, _ := log.NewDefaultLogger("plain", "info", false)
|
|
app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
|
|
|
genesisState := NewDefaultGenesisState(app.appCodec)
|
|
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
|
|
// Initialize the chain
|
|
app.InitChain(
|
|
abci.RequestInitChain{
|
|
ChainId: "ethermint_9000-1",
|
|
Validators: []abci.ValidatorUpdate{},
|
|
AppStateBytes: stateBytes,
|
|
},
|
|
)
|
|
app.Commit()
|
|
|
|
b.ResetTimer()
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
// Making a new app object with the db, so that initchain hasn't been called
|
|
app2 := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
|
if _, err := app2.ExportAppStateAndValidators(false, []string{}); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
}
|