Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multi-test] Add staking and distribution module #782

Merged
merged 25 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cef94c2
multi-test: WIP add staking and distribution modules
ueco-jb Aug 15, 2022
180d049
multi-test: WIP add distribution module implementation
ueco-jb Aug 18, 2022
e5318a6
multi-test: Replace FailingDistribution and FailingStaking with Distr…
ueco-jb Aug 18, 2022
2666aa5
multi-test: Add Distribution to CustomMsg matcher
ueco-jb Aug 19, 2022
ce4b4c7
multi-test: Fix bug by removing addition of stake at withdraw_rewards…
ueco-jb Aug 21, 2022
9c1cdb8
Show how to call "root" on Bank module from Staking
ethanfrey Sep 16, 2022
415ea75
Change event signatures to match cosmos-sdk
chipshort Sep 27, 2022
95f2830
Handle redelegation msg in StakeKeeper
chipshort Sep 27, 2022
947f965
Remove unnecessary clones
chipshort Sep 27, 2022
bd36ab1
Add staking reward config and more staking queries
chipshort Oct 4, 2022
d0030c9
Add multiple validators and slashing
chipshort Oct 5, 2022
8b11c7c
Process unbonding queue
chipshort Oct 5, 2022
294f4a2
Add (buggy) rewards calculation
chipshort Oct 6, 2022
735b38c
Fix multi-test staking rewards
chipshort Oct 6, 2022
cf3c94b
Cleanup
chipshort Oct 6, 2022
de1ae1f
Add more tests and small fixes
chipshort Oct 7, 2022
b4882f2
Add stake and distribution keeper to BasicApp
chipshort Oct 7, 2022
31aaa5e
Use Deque in staking test module
chipshort Oct 7, 2022
17d469c
Improve coverage
chipshort Oct 7, 2022
41b6432
Cleanup
chipshort Oct 7, 2022
31a872e
Export StakingInfo in multi-test
chipshort Oct 10, 2022
6e73809
Make StakingInfo fields public
chipshort Oct 10, 2022
fc956b0
Allow delegating / undelegating zero coins
chipshort Oct 10, 2022
f02f345
Apply suggestions from code review
chipshort Oct 11, 2022
f1e2ee2
Fix staking module
chipshort Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 21 additions & 19 deletions packages/multi-test/src/app.rs
Expand Up @@ -17,7 +17,7 @@ use crate::bank::{Bank, BankKeeper, BankSudo};
use crate::contracts::Contract;
use crate::executor::{AppResponse, Executor};
use crate::module::{FailingModule, Module};
use crate::staking::{Distribution, FailingDistribution, FailingStaking, Staking, StakingSudo};
use crate::staking::{Distribution, DistributionKeeper, StakeKeeper, Staking, StakingSudo};
use crate::transactions::transactional;
use crate::wasm::{ContractData, Wasm, WasmKeeper, WasmSudo};

Expand All @@ -33,6 +33,8 @@ pub type BasicApp<ExecC = Empty, QueryC = Empty> = App<
MockStorage,
FailingModule<ExecC, QueryC, Empty>,
WasmKeeper<ExecC, QueryC>,
StakeKeeper,
DistributionKeeper,
>;

/// Router is a persisted state. You can query this.
Expand All @@ -44,8 +46,8 @@ pub struct App<
Storage = MockStorage,
Custom = FailingModule<Empty, Empty, Empty>,
Wasm = WasmKeeper<Empty, Empty>,
Staking = FailingStaking,
Distr = FailingDistribution,
Staking = StakeKeeper,
Distr = DistributionKeeper,
> {
router: Router<Bank, Custom, Wasm, Staking, Distr>,
api: Api,
Expand Down Expand Up @@ -75,8 +77,8 @@ impl BasicApp {
BankKeeper,
FailingModule<Empty, Empty, Empty>,
WasmKeeper<Empty, Empty>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>,
&dyn Api,
&mut dyn Storage,
Expand All @@ -97,8 +99,8 @@ where
BankKeeper,
FailingModule<ExecC, QueryC, Empty>,
WasmKeeper<ExecC, QueryC>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>,
&dyn Api,
&mut dyn Storage,
Expand Down Expand Up @@ -159,8 +161,8 @@ pub type BasicAppBuilder<ExecC, QueryC> = AppBuilder<
MockStorage,
FailingModule<ExecC, QueryC, Empty>,
WasmKeeper<ExecC, QueryC>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>;

/// Utility to build App in stages. If particular items wont be set, defaults would be used
Expand All @@ -182,8 +184,8 @@ impl Default
MockStorage,
FailingModule<Empty, Empty, Empty>,
WasmKeeper<Empty, Empty>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>
{
fn default() -> Self {
Expand All @@ -198,8 +200,8 @@ impl
MockStorage,
FailingModule<Empty, Empty, Empty>,
WasmKeeper<Empty, Empty>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>
{
/// Creates builder with default components working with empty exec and query messages.
Expand All @@ -211,8 +213,8 @@ impl
bank: BankKeeper::new(),
wasm: WasmKeeper::new(),
custom: FailingModule::new(),
staking: FailingStaking::new(),
distribution: FailingDistribution::new(),
staking: StakeKeeper::new(),
distribution: DistributionKeeper::new(),
}
}
}
Expand All @@ -224,8 +226,8 @@ impl<ExecC, QueryC>
MockStorage,
FailingModule<ExecC, QueryC, Empty>,
WasmKeeper<ExecC, QueryC>,
FailingStaking,
FailingDistribution,
StakeKeeper,
DistributionKeeper,
>
where
ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static,
Expand All @@ -241,8 +243,8 @@ where
bank: BankKeeper::new(),
wasm: WasmKeeper::new(),
custom: FailingModule::new(),
staking: FailingStaking::new(),
distribution: FailingDistribution::new(),
staking: StakeKeeper::new(),
distribution: DistributionKeeper::new(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/multi-test/src/contracts.rs
Expand Up @@ -351,6 +351,7 @@ where
CosmosMsg::Wasm(wasm) => CosmosMsg::Wasm(wasm),
CosmosMsg::Bank(bank) => CosmosMsg::Bank(bank),
CosmosMsg::Staking(staking) => CosmosMsg::Staking(staking),
CosmosMsg::Distribution(distribution) => CosmosMsg::Distribution(distribution),
CosmosMsg::Custom(_) => unreachable!(),
#[cfg(feature = "stargate")]
CosmosMsg::Ibc(ibc) => CosmosMsg::Ibc(ibc),
Expand Down
2 changes: 1 addition & 1 deletion packages/multi-test/src/lib.rs
Expand Up @@ -28,5 +28,5 @@ pub use crate::bank::{Bank, BankKeeper, BankSudo};
pub use crate::contracts::{Contract, ContractWrapper};
pub use crate::executor::{AppResponse, Executor};
pub use crate::module::{FailingModule, Module};
pub use crate::staking::{FailingDistribution, FailingStaking, Staking, StakingSudo};
pub use crate::staking::{DistributionKeeper, StakeKeeper, Staking, StakingInfo, StakingSudo};
pub use crate::wasm::{Wasm, WasmKeeper, WasmSudo};