simapp, types: fix benchmarks panics by honoring skip if set (#8763)
- BenchmarkAccAddressString must initialize the index less than ed25519.PubKeySize to avoid panics - BenchmarkFullAppSimulation should be skipped as it has the same logic as tests Fixes #8762
This commit is contained in:
parent
eb8aaf9395
commit
91affb5167
|
@ -15,11 +15,15 @@ import (
|
|||
// /usr/local/go/bin/go test -benchmem -run=^$ github.com/cosmos/cosmos-sdk/simapp -bench ^BenchmarkFullAppSimulation$ -Commit=true -cpuprofile cpu.out
|
||||
func BenchmarkFullAppSimulation(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
config, db, dir, logger, _, err := SetupSimulation("goleveldb-app-sim", "Simulation")
|
||||
config, db, dir, logger, skip, err := SetupSimulation("goleveldb-app-sim", "Simulation")
|
||||
if err != nil {
|
||||
b.Fatalf("simulation setup failed: %s", err.Error())
|
||||
}
|
||||
|
||||
if skip {
|
||||
b.Skip("skipping benchmark application simulation")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
db.Close()
|
||||
err = os.RemoveAll(dir)
|
||||
|
@ -59,11 +63,15 @@ func BenchmarkFullAppSimulation(b *testing.B) {
|
|||
|
||||
func BenchmarkInvariants(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
config, db, dir, logger, _, err := SetupSimulation("leveldb-app-invariant-bench", "Simulation")
|
||||
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-invariant-bench", "Simulation")
|
||||
if err != nil {
|
||||
b.Fatalf("simulation setup failed: %s", err.Error())
|
||||
}
|
||||
|
||||
if skip {
|
||||
b.Skip("skipping benchmark application simulation")
|
||||
}
|
||||
|
||||
config.AllInvariants = false
|
||||
|
||||
defer func() {
|
||||
|
|
|
@ -17,7 +17,7 @@ func BenchmarkAccAddressString(b *testing.B) {
|
|||
pk := &ed25519.PubKey{Key: pkBz}
|
||||
a := pk.Address()
|
||||
pk2 := make([]byte, ed25519.PubKeySize)
|
||||
for i := 1; i <= ed25519.PubKeySize; i++ {
|
||||
for i := 1; i < ed25519.PubKeySize; i++ {
|
||||
pk2[i] = byte(i)
|
||||
}
|
||||
a2 := pk.Address()
|
||||
|
|
Loading…
Reference in New Issue