0g-chain/app/app_test.go

57 lines
1.4 KiB
Go
Raw Normal View History

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()
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
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
newApp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
_, _, 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()
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
for acc := range mAccPerms {
require.True(t, app.bankKeeper.BlacklistedAddr(app.supplyKeeper.GetModuleAddress(acc)))
}
}
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
}