github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/simapp/app_test.go (about)

     1  package simapp
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/fibonacci-chain/fbc/libs/tendermint/libs/log"
     8  	dbm "github.com/fibonacci-chain/fbc/libs/tm-db"
     9  	"github.com/stretchr/testify/require"
    10  
    11  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
    12  
    13  	abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types"
    14  )
    15  
    16  func TestSimAppExport(t *testing.T) {
    17  	db := dbm.NewMemDB()
    18  	app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, 0)
    19  
    20  	genesisState := NewDefaultGenesisState()
    21  	stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
    22  	require.NoError(t, err)
    23  
    24  	// Initialize the chain
    25  	app.InitChain(
    26  		abci.RequestInitChain{
    27  			Validators:    []abci.ValidatorUpdate{},
    28  			AppStateBytes: stateBytes,
    29  		},
    30  	)
    31  	app.Commit(abci.RequestCommit{})
    32  
    33  	// Making a new app object with the db, so that initchain hasn't been called
    34  	app2 := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, 0)
    35  	_, _, err = app2.ExportAppStateAndValidators(false, []string{})
    36  	require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
    37  }
    38  
    39  // ensure that black listed addresses are properly set in bank keeper
    40  func TestBlackListedAddrs(t *testing.T) {
    41  	db := dbm.NewMemDB()
    42  	app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, 0)
    43  
    44  	for acc := range maccPerms {
    45  		require.Equal(t, !allowedReceivingModAcc[acc], app.BankKeeper.BlacklistedAddr(app.SupplyKeeper.GetModuleAddress(acc)))
    46  	}
    47  }
    48  
    49  func TestGetMaccPerms(t *testing.T) {
    50  	dup := GetMaccPerms()
    51  	require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions")
    52  }