Skip to content

Commit

Permalink
update home dir
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Apr 26, 2024
1 parent ba316e6 commit 4293ac4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package app

import (
"math/rand"
"os"
"path/filepath"
"strconv"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
Expand All @@ -20,7 +23,7 @@ import (

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig() params.EncodingConfig {
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, EmptyAppOptions{homeDir: os.TempDir()})
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, NewEmptyAppOptions())
encodingConfig := params.EncodingConfig{
InterfaceRegistry: tempApp.InterfaceRegistry(),
Codec: tempApp.AppCodec(),
Expand All @@ -32,7 +35,7 @@ func MakeEncodingConfig() params.EncodingConfig {
}

func AutoCliOpts() autocli.AppOptions {
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, EmptyAppOptions{homeDir: os.TempDir()})
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, NewEmptyAppOptions())

Check warning on line 38 in app/encoding.go

View check run for this annotation

Codecov / codecov/patch

app/encoding.go#L38

Added line #L38 was not covered by tests
modules := make(map[string]appmodule.AppModule, 0)
for _, m := range tempApp.ModuleManager.Modules {
if moduleWithName, ok := m.(module.HasName); ok {
Expand All @@ -53,7 +56,7 @@ func AutoCliOpts() autocli.AppOptions {
}

func BasicManager() module.BasicManager {
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, EmptyAppOptions{homeDir: os.TempDir()})
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, []wasmkeeper.Option{}, NewEmptyAppOptions())

Check warning on line 59 in app/encoding.go

View check run for this annotation

Codecov / codecov/patch

app/encoding.go#L59

Added line #L59 was not covered by tests
return tempApp.BasicModuleManager
}

Expand All @@ -62,6 +65,12 @@ type EmptyAppOptions struct {
homeDir string
}

func NewEmptyAppOptions() EmptyAppOptions {
return EmptyAppOptions{
homeDir: filepath.Join(os.TempDir(), strconv.Itoa(rand.Int())),
}
}

// Get implements AppOptions
func (ao EmptyAppOptions) Get(o string) interface{} {
if o == flags.FlagHome {
Expand Down

0 comments on commit 4293ac4

Please sign in to comment.