diff --git a/app/app_test.go b/app/app_test.go index bd3769afdf..43e1909863 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -3,6 +3,7 @@ package app import ( "encoding/json" "fmt" + "os" "sort" "testing" @@ -23,6 +24,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "github.com/provenance-io/provenance/app/params" markermodule "github.com/provenance-io/provenance/x/marker" markertypes "github.com/provenance-io/provenance/x/marker/types" ) @@ -425,3 +427,22 @@ func TestFilterBeginBlockerEvents(t *testing.T) { }) } } + +// MakeTestEncodingConfig creates an encoding config suitable for unit tests. +func MakeTestEncodingConfig(t *testing.T) params.EncodingConfig { + tempDir, err := os.MkdirTemp("", "tempprovapp") + switch { + case t != nil: + require.NoError(t, err, "failed to create temp dir %q", tempDir) + case err != nil: + panic(fmt.Errorf("failed to create temp dir %q: %w", tempDir, err)) + } + defer os.RemoveAll(tempDir) + + tempApp := New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, + tempDir, + 0, + simtestutil.EmptyAppOptions{}, + ) + return tempApp.GetEncodingConfig() +}