More testing and fuzzing and docs for pools (#12624)

* move pools fuzzing to hongfuzz

* merge more small fixes

* fix all tests

* Update frame/nomination-pools/fuzzer/src/call.rs

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>

* remove transactional

* fmt

* fix CI

* fmt

* fix build again

* fix CI

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>
This commit is contained in:
Kian Paimani
2022-11-10 02:34:00 +00:00
committed by GitHub
parent ef0cc330ce
commit 9979acb1e7
9 changed files with 562 additions and 436 deletions
+12 -11
View File
@@ -259,44 +259,45 @@ impl Default for ExtBuilder {
}
}
#[cfg_attr(feature = "fuzzing", allow(dead_code))]
impl ExtBuilder {
// Add members to pool 0.
pub(crate) fn add_members(mut self, members: Vec<(AccountId, Balance)>) -> Self {
pub fn add_members(mut self, members: Vec<(AccountId, Balance)>) -> Self {
self.members = members;
self
}
pub(crate) fn ed(self, ed: Balance) -> Self {
pub fn ed(self, ed: Balance) -> Self {
ExistentialDeposit::set(ed);
self
}
pub(crate) fn min_bond(self, min: Balance) -> Self {
pub fn min_bond(self, min: Balance) -> Self {
StakingMinBond::set(min);
self
}
pub(crate) fn min_join_bond(self, min: Balance) -> Self {
pub fn min_join_bond(self, min: Balance) -> Self {
MinJoinBondConfig::set(min);
self
}
pub(crate) fn with_check(self, level: u8) -> Self {
pub fn with_check(self, level: u8) -> Self {
CheckLevel::set(level);
self
}
pub(crate) fn max_members(mut self, max: Option<u32>) -> Self {
pub fn max_members(mut self, max: Option<u32>) -> Self {
self.max_members = max;
self
}
pub(crate) fn max_members_per_pool(mut self, max: Option<u32>) -> Self {
pub fn max_members_per_pool(mut self, max: Option<u32>) -> Self {
self.max_members_per_pool = max;
self
}
pub(crate) fn build(self) -> sp_io::TestExternalities {
pub fn build(self) -> sp_io::TestExternalities {
sp_tracing::try_init_simple();
let mut storage =
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
@@ -339,7 +340,7 @@ impl ExtBuilder {
}
}
pub(crate) fn unsafe_set_state(pool_id: PoolId, state: PoolState) {
pub fn unsafe_set_state(pool_id: PoolId, state: PoolState) {
BondedPools::<Runtime>::try_mutate(pool_id, |maybe_bonded_pool| {
maybe_bonded_pool.as_mut().ok_or(()).map(|bonded_pool| {
bonded_pool.state = state;
@@ -354,7 +355,7 @@ parameter_types! {
}
/// All events of this pallet.
pub(crate) fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
pub fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
let events = System::events()
.into_iter()
.map(|r| r.event)
@@ -366,7 +367,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
}
/// All events of the `Balances` pallet.
pub(crate) fn balances_events_since_last_call() -> Vec<pallet_balances::Event<Runtime>> {
pub fn balances_events_since_last_call() -> Vec<pallet_balances::Event<Runtime>> {
let events = System::events()
.into_iter()
.map(|r| r.event)