64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/tendermint/tendermint/libs/db"
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
|
"github.com/cosmos/cosmos-sdk/x/slashing"
|
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
)
|
|
|
|
func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
|
|
genaccs := make([]GenesisAccount, len(accs))
|
|
for i, acc := range accs {
|
|
genaccs[i] = NewGenesisAccount(acc)
|
|
}
|
|
|
|
genesisState := NewGenesisState(
|
|
genaccs,
|
|
auth.DefaultGenesisState(),
|
|
bank.DefaultGenesisState(),
|
|
staking.DefaultGenesisState(),
|
|
mint.DefaultGenesisState(),
|
|
distr.DefaultGenesisState(),
|
|
gov.DefaultGenesisState(),
|
|
slashing.DefaultGenesisState(),
|
|
)
|
|
|
|
stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Initialize the chain
|
|
vals := []abci.ValidatorUpdate{}
|
|
gapp.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes})
|
|
gapp.Commit()
|
|
|
|
return nil
|
|
}
|
|
|
|
func TestGaiadExport(t *testing.T) {
|
|
db := db.NewMemDB()
|
|
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true)
|
|
setGenesis(gapp)
|
|
|
|
// Making a new app object with the db, so that initchain hasn't been called
|
|
newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true)
|
|
_, _, err := newGapp.ExportAppStateAndValidators(false, []string{})
|
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
|
}
|