2019-05-18 01:42:24 -07:00
|
|
|
package simapp
|
2018-04-06 22:12:00 -07:00
|
|
|
|
|
|
|
import (
|
2020-08-13 06:20:02 -07:00
|
|
|
"encoding/json"
|
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-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-08-11 07:22:30 -07:00
|
|
|
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig())
|
2018-04-06 22:12:00 -07:00
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
genesisState := NewDefaultGenesisState()
|
2020-08-13 06:20:02 -07:00
|
|
|
stateBytes, err := json.MarshalIndent(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-08-11 07:22:30 -07:00
|
|
|
app2 := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig())
|
2020-09-03 03:11:46 -07:00
|
|
|
_, err = app2.ExportAppStateAndValidators(false, []string{})
|
2019-06-05 16:26:17 -07:00
|
|
|
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
|
|
|
|
2020-06-17 06:32:49 -07:00
|
|
|
// ensure that blocked addresses are properly set in bank keeper
|
|
|
|
func TestBlockedAddrs(t *testing.T) {
|
2019-08-15 15:29:21 -07:00
|
|
|
db := dbm.NewMemDB()
|
2020-08-11 07:22:30 -07:00
|
|
|
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, MakeEncodingConfig())
|
2019-08-15 15:29:21 -07:00
|
|
|
|
|
|
|
for acc := range maccPerms {
|
2020-06-17 06:32:49 -07:00
|
|
|
require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlockedAddr(app.AccountKeeper.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")
|
|
|
|
}
|