forked from cosmos/interchain-security
-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfaces.go
163 lines (139 loc) · 7.4 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package integration
import (
"context"
"time"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"cosmossdk.io/core/comet"
"cosmossdk.io/math"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/cometbft/cometbft/abci/types"
consumerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/consumer/keeper"
providerkeeper "github.com/cosmos/interchain-security/v6/x/ccv/provider/keeper"
ccvtypes "github.com/cosmos/interchain-security/v6/x/ccv/types"
)
// The interface that any provider app must implement to be compatible with ccv integration tests.
// This is a wrapper around the ibc testing app interface with additional constraints.
type ProviderApp interface {
ibctesting.TestingApp
GetSubspace(moduleName string) paramstypes.Subspace
//
// Keeper getters
//
GetProviderKeeper() providerkeeper.Keeper
// Returns a staking keeper interface with more capabilities than the expected_keepers interface
GetTestStakingKeeper() TestStakingKeeper
// Returns a bank keeper interface with more capabilities than the expected_keepers interface
GetTestBankKeeper() TestBankKeeper
// Returns a slashing keeper interface with more capabilities than the expected_keepers interface
GetTestSlashingKeeper() TestSlashingKeeper
// Returns a distribution keeper interface with more capabilities than the expected_keepers interface
GetTestDistributionKeeper() TestDistributionKeeper
// Returns an account keeper interface with more capabilities than the expected_keepers interface
GetTestAccountKeeper() TestAccountKeeper
GetTestGovKeeper() *govkeeper.Keeper
}
// The interface that any consumer app must implement to be compatible with integration tests
// This is a wrapper around the ibc testing app interface with additional constraints.
type ConsumerApp interface {
ibctesting.TestingApp
// BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
GetConsumerKeeper() consumerkeeper.Keeper
GetSubspace(moduleName string) paramstypes.Subspace
//
// Keeper getters
//
// Returns a bank keeper interface with more capabilities than the expected_keepers interface
GetTestBankKeeper() TestBankKeeper
// Tests an account keeper interface with more capabilities than the expected_keepers interface
GetTestAccountKeeper() TestAccountKeeper
// Tests a slashing keeper interface with more capabilities than the expected_keepers interface
GetTestSlashingKeeper() TestSlashingKeeper
// Tests an evidence keeper interface with more capabilities than the expected_keepers interface
GetTestEvidenceKeeper() evidencekeeper.Keeper
}
type DemocConsumerApp interface {
ConsumerApp
// Returns a distribution keeper interface with more capabilities than the expected_keepers interface
GetTestDistributionKeeper() TestDistributionKeeper
// Tests a staking keeper interface with more capabilities than the expected_keepers interface
GetTestStakingKeeper() TestStakingKeeper
// Tests a mint keeper interface with more capabilities than the expected_keepers interface
GetTestMintKeeper() mintkeeper.Keeper
// @MSalopek -> on v50 we need to access the Params collection which does not have a getter
GetTestGovKeeper() govkeeper.Keeper
}
//
// The following keeper interfaces are wrappers around the expected keepers for ccv modules,
// since integration tests require extra functionality from external keepers.
//
type TestStakingKeeper interface {
ccvtypes.StakingKeeper
Delegate(
ctx context.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc stakingtypes.BondStatus,
validator stakingtypes.Validator, subtractAccount bool,
) (newShares math.LegacyDec, err error)
Undelegate(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount math.LegacyDec,
) (time.Time, math.Int, error)
BeginRedelegation(
ctx context.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount math.LegacyDec,
) (completionTime time.Time, err error)
GetUnbondingDelegationByUnbondingID(ctx context.Context, id uint64) (ubd stakingtypes.UnbondingDelegation, err error)
GetRedelegations(ctx context.Context, delegator sdk.AccAddress, maxRetrieve uint16) (redelegations []stakingtypes.Redelegation, err error)
GetUnbondingDelegation(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (ubd stakingtypes.UnbondingDelegation, err error)
GetAllValidators(ctx context.Context) (validators []stakingtypes.Validator, err error)
GetValidatorSet() stakingtypes.ValidatorSet
GetParams(ctx context.Context) (stakingtypes.Params, error)
SetParams(ctx context.Context, p stakingtypes.Params) error
ApplyAndReturnValidatorSetUpdates(ctx context.Context) (updates []abci.ValidatorUpdate, err error)
}
type TestBankKeeper interface {
ccvtypes.BankKeeper
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress,
recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string,
recipientAddr sdk.AccAddress, amt sdk.Coins) error
}
type TestAccountKeeper interface {
ccvtypes.AccountKeeper
GetParams(context.Context) authtypes.Params
}
type TestSlashingKeeper interface {
ccvtypes.SlashingKeeper
SetValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) error
SignedBlocksWindow(ctx context.Context) (int64, error)
HandleValidatorSignature(ctx context.Context, addr cryptotypes.Address, power int64, signed comet.BlockIDFlag) error
MinSignedPerWindow(ctx context.Context) (int64, error)
// NOTE: @MSalopek deprecated in v50
// IterateValidatorMissedBlockBitArray(ctx sdk.Context,
// address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool))
IterateMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress, cb func(index int64, missed bool) (stop bool)) error
}
type TestDistributionKeeper interface {
// NOTE: @MSalopek deprecated in v50
// GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins
GetDistributionAccount(ctx context.Context) sdk.ModuleAccountI
GetValidatorOutstandingRewards(ctx context.Context, val sdk.ValAddress) (rewards distributiontypes.ValidatorOutstandingRewards, err error)
GetCommunityTax(ctx context.Context) (math.LegacyDec, error)
WithdrawValidatorCommission(ctx context.Context, valAddr sdk.ValAddress) (sdk.Coins, error)
}
type TestMintKeeper interface {
GetParams(ctx sdk.Context) (params minttypes.Params)
}
type TestGovKeeper interface {
GetParams(ctx sdk.Context) govv1.Params
SetParams(ctx sdk.Context, params govv1.Params) error
SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata, title, summary string, proposer sdk.AccAddress) (govv1.Proposal, error)
AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (bool, error)
AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, options govv1.WeightedVoteOptions, metadata string) error
}