2019-06-20 13:37:57 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2020-04-30 14:23:41 +00:00
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
2020-04-30 14:27:28 +00:00
|
|
|
db "github.com/tendermint/tm-db"
|
2020-04-30 14:23:41 +00:00
|
|
|
|
2019-06-20 13:37:57 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
)
|
|
|
|
|
2019-07-18 17:36:31 +00:00
|
|
|
func TestExport(t *testing.T) {
|
|
|
|
db := db.NewMemDB()
|
2020-12-02 17:37:11 +00:00
|
|
|
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, AppOptions{})
|
2019-07-18 17:36:31 +00:00
|
|
|
setGenesis(app)
|
2019-06-20 13:37:57 +00:00
|
|
|
|
2019-07-18 17:36:31 +00:00
|
|
|
// Making a new app object with the db, so that initchain hasn't been called
|
2020-12-02 17:37:11 +00:00
|
|
|
newApp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, AppOptions{})
|
2019-07-18 17:36:31 +00:00
|
|
|
_, _, err := newApp.ExportAppStateAndValidators(false, []string{})
|
|
|
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
|
|
|
}
|
|
|
|
|
2019-09-11 22:33:20 +00:00
|
|
|
// ensure that black listed addresses are properly set in bank keeper
|
|
|
|
func TestBlackListedAddrs(t *testing.T) {
|
|
|
|
db := db.NewMemDB()
|
2020-12-02 17:37:11 +00:00
|
|
|
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, AppOptions{})
|
2019-09-11 22:33:20 +00:00
|
|
|
|
|
|
|
for acc := range mAccPerms {
|
2020-05-21 04:50:12 +00:00
|
|
|
require.Equal(t, !allowedReceivingModAcc[acc], app.bankKeeper.BlacklistedAddr(app.supplyKeeper.GetModuleAddress(acc)))
|
2019-09-11 22:33:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-18 17:36:31 +00:00
|
|
|
func setGenesis(app *App) error {
|
|
|
|
genesisState := NewDefaultGenesisState()
|
2019-06-20 13:37:57 +00:00
|
|
|
|
2019-06-20 17:28:21 +00:00
|
|
|
stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState)
|
2019-06-20 13:37:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the chain
|
2019-07-18 17:36:31 +00:00
|
|
|
app.InitChain(
|
|
|
|
abci.RequestInitChain{
|
|
|
|
Validators: []abci.ValidatorUpdate{},
|
|
|
|
AppStateBytes: stateBytes,
|
|
|
|
},
|
|
|
|
)
|
2019-06-20 17:28:21 +00:00
|
|
|
app.Commit()
|
2019-06-20 13:37:57 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|