Skip to content

Commit

Permalink
change(pallet-communities): solve testing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed May 14, 2024
1 parent abe6837 commit d630577
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions pallets/communities/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
use super::*;

use self::{
origin::DecisionMethod,
types::{
AccountIdOf, AssetIdOf, CommunityIdOf, DecisionMethodFor, MembershipIdOf, NativeBalanceOf, PalletsOriginOf,
PollIndexOf, RuntimeCallFor, Vote,
},
CommunityDecisionMethod, Event, HoldReason, Pallet as Communities,
CommunityDecisionMethod, DecisionMethod, Event, HoldReason, Pallet as Communities,
};
use fc_traits_memberships::{Inspect, Rank};
use frame_benchmarking::v2::*;
use frame_support::traits::{
fungible::{InspectFreeze, Mutate},
fungibles::{Create, Mutate as FunsMutate},
fungibles::Mutate as FunsMutate,
OriginTrait,
};
use frame_system::{
Expand Down Expand Up @@ -197,7 +196,7 @@ mod benchmarks {
_(
admin_origin,
id,
DecisionMethod::CommunityAsset(T::BenchmarkHelper::community_asset_id()),
DecisionMethod::CommunityAsset(T::BenchmarkHelper::community_asset_id(), 10u128.into()),
);

// verification code
Expand Down Expand Up @@ -316,7 +315,7 @@ mod benchmarks {
// setup code
let (id, origin) = create_community::<T>(
RawOrigin::Root.into(),
Some(DecisionMethodFor::<T>::CommunityAsset(1u32.into())),
Some(DecisionMethodFor::<T>::CommunityAsset(1u32.into(), 1u128.into())),
)?;
let members = setup_members::<T>(origin.clone(), id)?;

Expand All @@ -325,9 +324,6 @@ mod benchmarks {
.expect("desired size of community to be equal or greather than 1")
.clone();

let community_account = Communities::<T>::community_account(&id);

T::Assets::create(1u32.into(), community_account, false, 1u128.into())?;
T::Assets::mint_into(1u32.into(), &who, 4u128.into())?;

prepare_track_and_prepare_poll::<T>(origin.into_caller(), who.clone())?;
Expand Down
2 changes: 1 addition & 1 deletion pallets/communities/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<T: Config> Pallet<T> {

let say = *match (vote, decision_method) {
(Vote::AssetBalance(say, asset, amount), DecisionMethod::CommunityAsset(a, min)) if asset == a => {
ensure!(amount > min, Error::<T>::VoteBelowMinimum);
ensure!(amount >= min, Error::<T>::VoteBelowMinimum);
say
}
(Vote::NativeBalance(say, ..), DecisionMethod::NativeToken)
Expand Down
4 changes: 2 additions & 2 deletions pallets/communities/src/tests/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ mod vote {
RuntimeOrigin::signed(BOB),
membership(COMMUNITY_B, 1),
1,
Vote::AssetBalance(true, COMMUNITY_B_ASSET_ID, 10)
Vote::AssetBalance(true, COMMUNITY_B_ASSET_ID, 9)
),
Error::VoteBelowMinimum
);
assert_ok!(Communities::vote(
RuntimeOrigin::signed(BOB),
membership(COMMUNITY_B, 1),
1,
Vote::AssetBalance(true, COMMUNITY_B_ASSET_ID, 11)
Vote::AssetBalance(true, COMMUNITY_B_ASSET_ID, 10)
));
});
}
Expand Down

0 comments on commit d630577

Please sign in to comment.