mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
9c69ee2fbf
* use kava antehandler * add authenticated mempool decorator * add get authorised address methods * hook antehandler into app * refactor address fetcher interface * tidy up args to NewApp * remove unused function * tidy up after removing address fetcher interface * read authorized addresses from config * fix error message, and minor tidy * update cosmos-sdk and tendermint * clarify function name * add flags for mempool options
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
db "github.com/tendermint/tm-db"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
)
|
|
|
|
func TestExport(t *testing.T) {
|
|
db := db.NewMemDB()
|
|
app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, AppOptions{})
|
|
setGenesis(app)
|
|
|
|
// 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, AppOptions{})
|
|
_, _, err := newApp.ExportAppStateAndValidators(false, []string{})
|
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
|
}
|
|
|
|
// 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, AppOptions{})
|
|
|
|
for acc := range mAccPerms {
|
|
require.Equal(t, !allowedReceivingModAcc[acc], app.bankKeeper.BlacklistedAddr(app.supplyKeeper.GetModuleAddress(acc)))
|
|
}
|
|
}
|
|
|
|
func setGenesis(app *App) error {
|
|
genesisState := NewDefaultGenesisState()
|
|
|
|
stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Initialize the chain
|
|
app.InitChain(
|
|
abci.RequestInitChain{
|
|
Validators: []abci.ValidatorUpdate{},
|
|
AppStateBytes: stateBytes,
|
|
},
|
|
)
|
|
app.Commit()
|
|
|
|
return nil
|
|
}
|