Merge PR #221: Hide unnecessarily exported function to better coverage report

This commit is contained in:
Alessio Treglia
2019-12-12 14:59:48 +00:00
committed by Alexander Bezobchuk
parent ed036f6c83
commit dcbddd9f04
2 changed files with 16 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
// export state and params before the simulation error is checked // export state and params before the simulation error is checked
if config.ExportStatePath != "" { if config.ExportStatePath != "" {
if err := ExportStateToJSON(app, config.ExportStatePath); err != nil { if err := exportStateToJSON(app, config.ExportStatePath); err != nil {
fmt.Println(err) fmt.Println(err)
b.Fail() b.Fail()
} }
@@ -140,7 +140,7 @@ func TestFullAppSimulation(t *testing.T) {
// export state and params before the simulation error is checked // export state and params before the simulation error is checked
if config.ExportStatePath != "" { if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath) err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err) require.NoError(t, err)
} }
@@ -197,7 +197,7 @@ func TestAppImportExport(t *testing.T) {
// export state and simParams before the simulation error is checked // export state and simParams before the simulation error is checked
if config.ExportStatePath != "" { if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath) err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err) require.NoError(t, err)
} }
@@ -319,7 +319,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
// export state and params before the simulation error is checked // export state and params before the simulation error is checked
if config.ExportStatePath != "" { if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath) err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err) require.NoError(t, err)
} }
@@ -463,7 +463,7 @@ func BenchmarkInvariants(b *testing.B) {
// export state and params before the simulation error is checked // export state and params before the simulation error is checked
if config.ExportStatePath != "" { if config.ExportStatePath != "" {
if err := ExportStateToJSON(app, config.ExportStatePath); err != nil { if err := exportStateToJSON(app, config.ExportStatePath); err != nil {
fmt.Println(err) fmt.Println(err)
b.Fail() b.Fail()
} }
@@ -497,3 +497,14 @@ func BenchmarkInvariants(b *testing.B) {
}) })
} }
} }
// auxiliary function to export the app state to JSON
func exportStateToJSON(app *GaiaApp, path string) error {
fmt.Println("exporting app state...")
appState, _, err := app.ExportAppStateAndValidators(false, nil)
if err != nil {
return err
}
return ioutil.WriteFile(path, []byte(appState), 0644)
}

View File

@@ -1,7 +1,6 @@
package app package app
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
@@ -30,14 +29,3 @@ func SimulationOperations(app *GaiaApp, cdc *codec.Codec, config simulation.Conf
simState.Contents = app.sm.GetProposalContents(simState) simState.Contents = app.sm.GetProposalContents(simState)
return app.sm.WeightedOperations(simState) return app.sm.WeightedOperations(simState)
} }
// ExportStateToJSON util function to export the app state to JSON
func ExportStateToJSON(app *GaiaApp, path string) error {
fmt.Println("exporting app state...")
appState, _, err := app.ExportAppStateAndValidators(false, nil)
if err != nil {
return err
}
return ioutil.WriteFile(path, []byte(appState), 0644)
}