Documentation ¶
Index ¶
- Variables
- func MakeTestCodec() *codec.LegacyAmino
- func MakeTestMarshaler() codec.Codec
- func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey ccrypto.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator
- func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt sdk.Int) *stakingtypes.MsgUndelegate
- type AlwaysPanicStakingMock
- func (s AlwaysPanicStakingMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator
- func (s AlwaysPanicStakingMock) GetLastTotalPower(ctx sdk.Context) (power sdk.Int)
- func (s AlwaysPanicStakingMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64
- func (s AlwaysPanicStakingMock) IterateBondedValidatorsByPower(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
- func (s AlwaysPanicStakingMock) IterateLastValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
- func (s AlwaysPanicStakingMock) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
- func (s AlwaysPanicStakingMock) Jail(sdk.Context, sdk.ConsAddress)
- func (s AlwaysPanicStakingMock) Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
- func (s AlwaysPanicStakingMock) Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI
- func (s AlwaysPanicStakingMock) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI
- type MockStakingValidatorData
- type StakingKeeperMock
- func (s *StakingKeeperMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator
- func (s *StakingKeeperMock) GetLastTotalPower(ctx sdk.Context) (power sdk.Int)
- func (s *StakingKeeperMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64
- func (s *StakingKeeperMock) GetParams(ctx sdk.Context) stakingtypes.Params
- func (s *StakingKeeperMock) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)
- func (s *StakingKeeperMock) IterateBondedValidatorsByPower(ctx sdk.Context, ...)
- func (s *StakingKeeperMock) IterateLastValidators(ctx sdk.Context, ...)
- func (s *StakingKeeperMock) IterateValidators(ctx sdk.Context, ...)
- func (s *StakingKeeperMock) Jail(sdk.Context, sdk.ConsAddress)
- func (s *StakingKeeperMock) PowerReduction(ctx sdk.Context) (res sdk.Int)
- func (s *StakingKeeperMock) Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
- func (s *StakingKeeperMock) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI
- func (s *StakingKeeperMock) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) stakingtypes.ValidatorI
- func (s *StakingKeeperMock) ValidatorQueueIterator(ctx sdk.Context, endTime time.Time, endHeight int64) sdk.Iterator
- type TestInput
Constants ¶
This section is empty.
Variables ¶
var ( // ConsPrivKeys generate ed25519 ConsPrivKeys to be used for validator operator keys ConsPrivKeys = []ccrypto.PrivKey{ ed25519.GenPrivKey(), ed25519.GenPrivKey(), ed25519.GenPrivKey(), ed25519.GenPrivKey(), ed25519.GenPrivKey(), } // ConsPubKeys holds the consensus public keys to be used for validator operator keys ConsPubKeys = []ccrypto.PubKey{ ConsPrivKeys[0].PubKey(), ConsPrivKeys[1].PubKey(), ConsPrivKeys[2].PubKey(), ConsPrivKeys[3].PubKey(), ConsPrivKeys[4].PubKey(), } // AccPrivKeys generate secp256k1 pubkeys to be used for account pub keys AccPrivKeys = []ccrypto.PrivKey{ secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), } // AccPubKeys holds the pub keys for the account keys AccPubKeys = []ccrypto.PubKey{ AccPrivKeys[0].PubKey(), AccPrivKeys[1].PubKey(), AccPrivKeys[2].PubKey(), AccPrivKeys[3].PubKey(), AccPrivKeys[4].PubKey(), } // AccAddrs holds the sdk.AccAddresses AccAddrs = []sdk.AccAddress{ sdk.AccAddress(AccPubKeys[0].Address()), sdk.AccAddress(AccPubKeys[1].Address()), sdk.AccAddress(AccPubKeys[2].Address()), sdk.AccAddress(AccPubKeys[3].Address()), sdk.AccAddress(AccPubKeys[4].Address()), } // ValAddrs holds the sdk.ValAddresses ValAddrs = []sdk.ValAddress{ sdk.ValAddress(AccPubKeys[0].Address()), sdk.ValAddress(AccPubKeys[1].Address()), sdk.ValAddress(AccPubKeys[2].Address()), sdk.ValAddress(AccPubKeys[3].Address()), sdk.ValAddress(AccPubKeys[4].Address()), } // EthAddrs holds etheruem addresses EthAddrs = []common.Address{ common.BytesToAddress(bytes.Repeat([]byte{byte(1)}, 20)), common.BytesToAddress(bytes.Repeat([]byte{byte(2)}, 20)), common.BytesToAddress(bytes.Repeat([]byte{byte(3)}, 20)), common.BytesToAddress(bytes.Repeat([]byte{byte(4)}, 20)), common.BytesToAddress(bytes.Repeat([]byte{byte(5)}, 20)), } // TokenContractAddrs holds example token contract addresses TokenContractAddrs = []string{ common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f").Hex(), common.HexToAddress("0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e").Hex(), common.HexToAddress("0x1f9840a85d5af5bf1d1762f925bdaddc4201f984").Hex(), common.HexToAddress("0xc00e94cb662c3520282e6f5717214004a7f26888").Hex(), common.HexToAddress("0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f").Hex(), } // InitTokens holds the number of tokens to initialize an account with InitTokens = sdk.TokensFromConsensusPower(110, sdk.DefaultPowerReduction) // InitCoins holds the number of coins to initialize an account with InitCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, InitTokens)) // StakingAmount holds the staking power to start a validator with StakingAmount = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) // StakingCoins holds the staking coins to start a validator with StakingCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, StakingAmount)) // TestingStakeParams is a set of staking params for testing TestingStakeParams = stakingtypes.Params{ UnbondingTime: 100, MaxValidators: 10, MaxEntries: 10, HistoricalEntries: 10000, BondDenom: "stake", } // TestingPeggyParams is a set of peggy params for testing TestingPeggyParams = &types.Params{ PeggyId: "testpeggyid", ContractSourceHash: "62328f7bc12efb28f86111d08c29b39285680a906ea0e524e0209d6f6657b713", BridgeEthereumAddress: common.HexToAddress("0x8858eeb3dfffa017d4bce9801d340d36cf895ccf").Hex(), BridgeChainId: 11, SignedBatchesWindow: 10, SignedValsetsWindow: 10, UnbondSlashingValsetsWindow: 15, SignedClaimsWindow: 10, TargetBatchTimeout: 60001, AverageBlockTime: 5000, AverageEthereumBlockTime: 15000, SlashFractionValset: sdk.NewDecWithPrec(1, 2), SlashFractionBatch: sdk.NewDecWithPrec(1, 2), SlashFractionClaim: sdk.NewDecWithPrec(1, 2), SlashFractionConflictingClaim: sdk.NewDecWithPrec(1, 2), SlashFractionBadEthSignature: sdk.NewDecWithPrec(1, 2), } )
var ( // ModuleBasics is a mock module basic manager for testing ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, genutil.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, staking.AppModuleBasic{}, mint.AppModuleBasic{}, distribution.AppModuleBasic{}, gov.NewAppModuleBasic( paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, vesting.AppModuleBasic{}, ) )
Functions ¶
func MakeTestCodec ¶
func MakeTestCodec() *codec.LegacyAmino
MakeTestCodec creates a legacy amino codec for testing
func MakeTestMarshaler ¶
MakeTestMarshaler creates a proto codec for use in testing
func NewTestMsgCreateValidator ¶
func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey ccrypto.PubKey, amt sdk.Int) *stakingtypes.MsgCreateValidator
func NewTestMsgUnDelegateValidator ¶
func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt sdk.Int) *stakingtypes.MsgUndelegate
Types ¶
type AlwaysPanicStakingMock ¶
type AlwaysPanicStakingMock struct{}
AlwaysPanicStakingMock is a mock staking keeper that panics on usage
func (AlwaysPanicStakingMock) GetBondedValidatorsByPower ¶
func (s AlwaysPanicStakingMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator
GetBondedValidatorsByPower implements the interface for staking keeper required by peggy
func (AlwaysPanicStakingMock) GetLastTotalPower ¶
func (s AlwaysPanicStakingMock) GetLastTotalPower(ctx sdk.Context) (power sdk.Int)
GetLastTotalPower implements the interface for staking keeper required by peggy
func (AlwaysPanicStakingMock) GetLastValidatorPower ¶
func (s AlwaysPanicStakingMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64
GetLastValidatorPower implements the interface for staking keeper required by peggy
func (AlwaysPanicStakingMock) IterateBondedValidatorsByPower ¶
func (s AlwaysPanicStakingMock) IterateBondedValidatorsByPower(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateBondedValidatorsByPower staisfies the interface
func (AlwaysPanicStakingMock) IterateLastValidators ¶
func (s AlwaysPanicStakingMock) IterateLastValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateLastValidators staisfies the interface
func (AlwaysPanicStakingMock) IterateValidators ¶
func (s AlwaysPanicStakingMock) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateValidators staisfies the interface
func (AlwaysPanicStakingMock) Jail ¶
func (s AlwaysPanicStakingMock) Jail(sdk.Context, sdk.ConsAddress)
Jail staisfies the interface
func (AlwaysPanicStakingMock) Slash ¶
func (s AlwaysPanicStakingMock) Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
Slash staisfies the interface
func (AlwaysPanicStakingMock) Validator ¶
func (s AlwaysPanicStakingMock) Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI
Validator staisfies the interface
func (AlwaysPanicStakingMock) ValidatorByConsAddr ¶
func (s AlwaysPanicStakingMock) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI
ValidatorByConsAddr staisfies the interface
type MockStakingValidatorData ¶
type MockStakingValidatorData struct { Operator sdk.ValAddress Power int64 }
MockStakingValidatorData creates mock validator data
type StakingKeeperMock ¶
type StakingKeeperMock struct { BondedValidators []stakingtypes.Validator ValidatorPower map[string]int64 }
StakingKeeperMock is a mock staking keeper for use in the tests
func NewStakingKeeperMock ¶
func NewStakingKeeperMock(operators ...sdk.ValAddress) *StakingKeeperMock
NewStakingKeeperMock creates a new mock staking keeper
func NewStakingKeeperWeightedMock ¶
func NewStakingKeeperWeightedMock(t ...MockStakingValidatorData) *StakingKeeperMock
NewStakingKeeperWeightedMock creates a new mock staking keeper with some mock validator data
func (*StakingKeeperMock) GetBondedValidatorsByPower ¶
func (s *StakingKeeperMock) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator
GetBondedValidatorsByPower implements the interface for staking keeper required by peggy
func (*StakingKeeperMock) GetLastTotalPower ¶
func (s *StakingKeeperMock) GetLastTotalPower(ctx sdk.Context) (power sdk.Int)
GetLastTotalPower implements the interface for staking keeper required by peggy
func (*StakingKeeperMock) GetLastValidatorPower ¶
func (s *StakingKeeperMock) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64
GetLastValidatorPower implements the interface for staking keeper required by peggy
func (*StakingKeeperMock) GetParams ¶
func (s *StakingKeeperMock) GetParams(ctx sdk.Context) stakingtypes.Params
func (*StakingKeeperMock) GetValidator ¶
func (s *StakingKeeperMock) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)
func (*StakingKeeperMock) IterateBondedValidatorsByPower ¶
func (s *StakingKeeperMock) IterateBondedValidatorsByPower(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateBondedValidatorsByPower staisfies the interface
func (*StakingKeeperMock) IterateLastValidators ¶
func (s *StakingKeeperMock) IterateLastValidators(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateLastValidators staisfies the interface
func (*StakingKeeperMock) IterateValidators ¶
func (s *StakingKeeperMock) IterateValidators(ctx sdk.Context, cb func(index int64, validator stakingtypes.ValidatorI) (stop bool))
IterateValidators staisfies the interface
func (*StakingKeeperMock) Jail ¶
func (s *StakingKeeperMock) Jail(sdk.Context, sdk.ConsAddress)
Jail staisfies the interface
func (*StakingKeeperMock) PowerReduction ¶
func (s *StakingKeeperMock) PowerReduction(ctx sdk.Context) (res sdk.Int)
func (*StakingKeeperMock) Slash ¶
func (s *StakingKeeperMock) Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
Slash staisfies the interface
func (*StakingKeeperMock) Validator ¶
func (s *StakingKeeperMock) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI
Validator staisfies the interface
func (*StakingKeeperMock) ValidatorByConsAddr ¶
func (s *StakingKeeperMock) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) stakingtypes.ValidatorI
ValidatorByConsAddr staisfies the interface
func (*StakingKeeperMock) ValidatorQueueIterator ¶
type TestInput ¶
type TestInput struct { PeggyKeeper peggyKeeper.Keeper AccountKeeper authkeeper.AccountKeeper StakingKeeper stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper DistKeeper distrkeeper.Keeper BankKeeper bankkeeper.BaseKeeper GovKeeper govkeeper.Keeper Context sdk.Context Marshaler codec.Codec LegacyAmino *codec.LegacyAmino }
TestInput stores the various keepers required to test peggy
func CreateTestEnv ¶
CreateTestEnv creates the keeper testing environment for peggy