Skip to content

Commit

Permalink
Merge PR CosmWasm#221: Hide unnecessarily exported function to better…
Browse files Browse the repository at this point in the history
… coverage report
  • Loading branch information
Alessio Treglia authored and alexanderbez committed Dec 12, 2019
1 parent ed036f6 commit dcbddd9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
21 changes: 16 additions & 5 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {

// export state and params before the simulation error is checked
if config.ExportStatePath != "" {
if err := ExportStateToJSON(app, config.ExportStatePath); err != nil {
if err := exportStateToJSON(app, config.ExportStatePath); err != nil {
fmt.Println(err)
b.Fail()
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestFullAppSimulation(t *testing.T) {

// export state and params before the simulation error is checked
if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath)
err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err)
}

Expand Down Expand Up @@ -197,7 +197,7 @@ func TestAppImportExport(t *testing.T) {

// export state and simParams before the simulation error is checked
if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath)
err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err)
}

Expand Down Expand Up @@ -319,7 +319,7 @@ func TestAppSimulationAfterImport(t *testing.T) {

// export state and params before the simulation error is checked
if config.ExportStatePath != "" {
err := ExportStateToJSON(app, config.ExportStatePath)
err := exportStateToJSON(app, config.ExportStatePath)
require.NoError(t, err)
}

Expand Down Expand Up @@ -463,7 +463,7 @@ func BenchmarkInvariants(b *testing.B) {

// export state and params before the simulation error is checked
if config.ExportStatePath != "" {
if err := ExportStateToJSON(app, config.ExportStatePath); err != nil {
if err := exportStateToJSON(app, config.ExportStatePath); err != nil {
fmt.Println(err)
b.Fail()
}
Expand Down Expand Up @@ -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)
}
12 changes: 0 additions & 12 deletions app/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app

import (
"fmt"
"io/ioutil"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -30,14 +29,3 @@ func SimulationOperations(app *GaiaApp, cdc *codec.Codec, config simulation.Conf
simState.Contents = app.sm.GetProposalContents(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)
}

0 comments on commit dcbddd9

Please sign in to comment.