2018-04-06 22:12:00 -07:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
2018-07-25 14:10:07 -07:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2018-12-10 06:27:25 -08:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/libs/db"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
|
2018-09-13 11:17:32 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2018-04-06 22:12:00 -07:00
|
|
|
|
2018-06-28 17:54:47 -07:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2018-04-06 22:12:00 -07:00
|
|
|
)
|
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
func TestGaiadExport(t *testing.T) {
|
|
|
|
db := db.NewMemDB()
|
|
|
|
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
|
|
|
|
setGenesis(gapp)
|
2018-04-06 22:12:00 -07:00
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
// 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, 0)
|
|
|
|
_, _, err := newGapp.ExportAppStateAndValidators(false, []string{})
|
|
|
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func setGenesis(gapp *GaiaApp) error {
|
2018-04-06 22:12:00 -07:00
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
genesisState := NewDefaultGenesisState()
|
2018-09-13 11:17:32 -07:00
|
|
|
stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState)
|
2018-04-06 22:12:00 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the chain
|
2019-05-16 08:25:32 -07:00
|
|
|
gapp.InitChain(
|
|
|
|
abci.RequestInitChain{
|
|
|
|
Validators: []abci.ValidatorUpdate{},
|
|
|
|
AppStateBytes: stateBytes,
|
|
|
|
},
|
|
|
|
)
|
2018-04-06 22:12:00 -07:00
|
|
|
gapp.Commit()
|
|
|
|
return nil
|
|
|
|
}
|