github.com/Finschia/finschia-sdk@v0.48.1/x/staking/common_test.go (about) 1 package staking_test 2 3 import ( 4 "math/big" 5 6 tmproto "github.com/tendermint/tendermint/proto/tendermint/types" 7 8 "github.com/Finschia/finschia-sdk/codec" 9 "github.com/Finschia/finschia-sdk/crypto/keys/ed25519" 10 "github.com/Finschia/finschia-sdk/crypto/keys/secp256k1" 11 "github.com/Finschia/finschia-sdk/simapp" 12 sdk "github.com/Finschia/finschia-sdk/types" 13 "github.com/Finschia/finschia-sdk/x/staking/keeper" 14 "github.com/Finschia/finschia-sdk/x/staking/types" 15 ) 16 17 func init() { 18 sdk.DefaultPowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) 19 } 20 21 // nolint:deadcode,unused,varcheck 22 var ( 23 priv1 = secp256k1.GenPrivKey() 24 addr1 = sdk.AccAddress(priv1.PubKey().Address()) 25 priv2 = secp256k1.GenPrivKey() 26 addr2 = sdk.AccAddress(priv2.PubKey().Address()) 27 28 valKey = ed25519.GenPrivKey() 29 valAddr = sdk.AccAddress(valKey.PubKey().Address()) 30 31 commissionRates = types.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) 32 33 PKs = simapp.CreateTestPubKeys(500) 34 ) 35 36 // getBaseSimappWithCustomKeeper Returns a simapp with custom StakingKeeper 37 // to avoid messing with the hooks. 38 func getBaseSimappWithCustomKeeper() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { 39 app := simapp.Setup(false) 40 ctx := app.BaseApp.NewContext(false, tmproto.Header{}) 41 42 appCodec := app.AppCodec() 43 44 app.StakingKeeper = keeper.NewKeeper( 45 appCodec, 46 app.GetKey(types.StoreKey), 47 app.AccountKeeper, 48 app.BankKeeper, 49 app.GetSubspace(types.ModuleName), 50 ) 51 app.StakingKeeper.SetParams(ctx, types.DefaultParams()) 52 53 return codec.NewLegacyAmino(), app, ctx 54 } 55 56 // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs 57 func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int, accAmount sdk.Int) ([]sdk.AccAddress, []sdk.ValAddress) { 58 addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, accAmount) 59 addrVals := simapp.ConvertAddrsToValAddrs(addrDels) 60 61 return addrDels, addrVals 62 }