2019-05-18 01:42:24 -07:00
|
|
|
package simapp
|
2018-04-06 22:12:00 -07:00
|
|
|
|
|
|
|
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/log"
|
2019-08-02 06:20:39 -07:00
|
|
|
dbm "github.com/tendermint/tm-db"
|
2018-12-10 06:27:25 -08:00
|
|
|
|
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-18 01:42:24 -07:00
|
|
|
func TestSimAppExport(t *testing.T) {
|
2019-08-02 06:20:39 -07:00
|
|
|
db := dbm.NewMemDB()
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)
|
2018-04-06 22:12:00 -07:00
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
genesisState := NewDefaultGenesisState()
|
2019-12-17 10:28:52 -08:00
|
|
|
stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
|
2019-06-05 16:26:17 -07:00
|
|
|
require.NoError(t, err)
|
2018-04-06 22:12:00 -07:00
|
|
|
|
|
|
|
// Initialize the chain
|
2019-05-18 01:42:24 -07:00
|
|
|
app.InitChain(
|
2019-05-16 08:25:32 -07:00
|
|
|
abci.RequestInitChain{
|
|
|
|
Validators: []abci.ValidatorUpdate{},
|
|
|
|
AppStateBytes: stateBytes,
|
|
|
|
},
|
|
|
|
)
|
2019-05-18 01:42:24 -07:00
|
|
|
app.Commit()
|
2019-06-05 16:26:17 -07:00
|
|
|
|
|
|
|
// Making a new app object with the db, so that initchain hasn't been called
|
2020-02-27 22:26:04 -08:00
|
|
|
app2 := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)
|
2019-06-05 16:26:17 -07:00
|
|
|
_, _, err = app2.ExportAppStateAndValidators(false, []string{})
|
|
|
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
2018-04-06 22:12:00 -07:00
|
|
|
}
|
2019-08-13 13:59:01 -07:00
|
|
|
|
2019-08-15 15:29:21 -07:00
|
|
|
// ensure that black listed addresses are properly set in bank keeper
|
|
|
|
func TestBlackListedAddrs(t *testing.T) {
|
|
|
|
db := dbm.NewMemDB()
|
2020-02-27 22:26:04 -08:00
|
|
|
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)
|
2019-08-15 15:29:21 -07:00
|
|
|
|
|
|
|
for acc := range maccPerms {
|
2019-12-10 11:09:22 -08:00
|
|
|
require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlacklistedAddr(app.SupplyKeeper.GetModuleAddress(acc)))
|
2019-08-15 15:29:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-13 13:59:01 -07:00
|
|
|
func TestGetMaccPerms(t *testing.T) {
|
|
|
|
dup := GetMaccPerms()
|
|
|
|
require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions")
|
|
|
|
}
|