Skip to content

Commit

Permalink
test: remove unused setup method
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpioborn committed Aug 9, 2023
1 parent 211562d commit 803c067
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 45 deletions.
23 changes: 0 additions & 23 deletions testutil/simapp/simapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,6 @@ func setup(withGenesis bool, invCheckPeriod uint) (*TestApp, app.GenesisState) {
return &TestApp{SgeApp: *appInstance}, app.GenesisState{}
}

// Setup initializes genesis the same as simapp
func Setup(isCheckTx bool) *TestApp {
app, genesisState := setup(!isCheckTx, 5)
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}

// Initialize the chain
app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
}

return app
}

// SetupWithGenesisAccounts sets up the genesis accounts for testing
func SetupWithGenesisAccounts(
genAccs []authtypes.GenesisAccount,
Expand Down
8 changes: 0 additions & 8 deletions testutil/simapp/simapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,3 @@ func TestGetTestObjects(t *testing.T) {
_, _, err := simappUtil.GetTestObjects()
require.NoError(t, err)
}

func TestSetup(t *testing.T) {
panicFunc := func() {
simappUtil.Setup(true)
simappUtil.Setup(false)
}
require.NotPanics(t, panicFunc)
}
20 changes: 6 additions & 14 deletions x/mint/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@ package mint_test
import (
"testing"

sdksimapp "github.com/cosmos/cosmos-sdk/simapp"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/sge-network/sge/x/mint/types"
"github.com/stretchr/testify/require"
abcitypes "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

simappUtil "github.com/sge-network/sge/testutil/simapp"
"github.com/sge-network/sge/x/mint/types"
)

func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
app := sdksimapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

app.InitChain(
abcitypes.RequestInitChain{
AppStateBytes: []byte("{}"),
ChainId: "test-chain-id",
},
)
tApp, ctx, err := simappUtil.GetTestObjects()
require.NoError(t, err)

acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
acc := tApp.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
require.NotNil(t, acc)
}

0 comments on commit 803c067

Please sign in to comment.