Skip to content

Commit

Permalink
todo files, more impl tests, removed unused config param
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Aug 21, 2023
1 parent d4b2223 commit 2f0f9dc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
1 change: 0 additions & 1 deletion pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ pub mod pallet {
Ok::<(), DispatchError>(())
})?;

//TODO: Dust clearance
Self::deposit_event(Event::<T>::BriefContribution(who, brief_id));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions pallets/briefs/src/todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

add field on Brief for require fellowship
minimum contribution on a brief
2 changes: 2 additions & 0 deletions pallets/proposals/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ impl<T: Config> Pallet<T> {
let fee = <T as Config>::ImbueFee::get().mul_floor(withdrawable);
let withdrawn = withdrawable.saturating_sub(fee);
let project_account = Self::project_account_id(project_key);

//TODO: Fee is not taken.
let pallet_account = Self::account_id();

// Transfer to initiator
Expand Down
2 changes: 0 additions & 2 deletions pallets/proposals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ pub mod pallet {
type ProjectToVetter: for<'a> MaybeConvert<&'a AccountIdOf<Self>, VetterIdOf<Self>>;
/// Turn an account role into a fee percentage. Handled in the fellowship pallet usually.
type RoleToPercentFee: Convert<Role, Percent>;
/// Ensure that an accountId is in a given role.
type EnsureRole: EnsureRole<AccountIdOf<Self>, Role>;
/// The minimum percentage of votes, inclusive, that is required for a vote of no confidence to pass/finalize.
type PercentRequiredForVoteNoConfidenceToPass: Get<Percent>;
/// Maximum size of the accounts responsible for handling disputes.
Expand Down
2 changes: 1 addition & 1 deletion pallets/proposals/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ impl pallet_proposals::Config for Test {
type PercentRequiredForVoteNoConfidenceToPass = PercentRequiredForVoteNoConfidenceToPass;
type ProjectToVetter = pallet_fellowship::Pallet<Test>;
type RoleToPercentFee = pallet_fellowship::impls::RoleToPercentFee;
type EnsureRole = pallet_fellowship::impls::EnsureFellowshipRole<Self>;
type MaximumJurySize = MaximumJurySize;
}

Expand Down Expand Up @@ -279,6 +278,7 @@ pub static BOB: Lazy<sr25519::Public> = Lazy::new(|| sr25519::Public::from_raw([
pub static CHARLIE: Lazy<sr25519::Public> = Lazy::new(|| sr25519::Public::from_raw([127u8; 32]));
pub static DAVE: Lazy<sr25519::Public> = Lazy::new(|| sr25519::Public::from_raw([128u8; 32]));
pub static JOHN: Lazy<sr25519::Public> = Lazy::new(|| sr25519::Public::from_raw([255u8; 32]));
pub static EMPTY: Lazy<sr25519::Public> = Lazy::new(|| sr25519::Public::from_raw([123u8; 32]));

pub(crate) fn build_test_externality() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default()
Expand Down
33 changes: 22 additions & 11 deletions pallets/proposals/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use frame_support::{assert_noop, assert_ok};

use common_types::CurrencyId;
use test_utils::*;

use crate::{*, mock::*};

#[test]
Expand Down Expand Up @@ -367,6 +366,7 @@ fn withdraw_only_transfers_approved_milestones() {
let cont = get_contributions::<Test>(vec![*BOB, *CHARLIE], per_contribution);
let prop_milestones = get_milestones(10);
let project_key = create_and_fund_project::<Test>(*ALICE, cont, prop_milestones, CurrencyId::Native).unwrap();
let project_account = crate::Pallet::<Test>::project_account_id(project_key);
let milestone_key = 0;
let _ =
Proposals::submit_milestone(RuntimeOrigin::signed(*ALICE), project_key, milestone_key)
Expand All @@ -385,7 +385,6 @@ fn withdraw_only_transfers_approved_milestones() {
true,
)
.unwrap();

let alice_before =
<Test as Config>::MultiCurrency::free_balance(CurrencyId::Native, &ALICE);
assert_ok!(Proposals::withdraw(
Expand All @@ -401,9 +400,6 @@ fn withdraw_only_transfers_approved_milestones() {
alice_after, alice_expected_balance,
"Alice account is not the expected balance"
);

let project_account = crate::Pallet::<Test>::project_account_id(project_key);

assert_eq!(
<Test as Config>::MultiCurrency::free_balance(CurrencyId::Native, &project_account),
180_000,
Expand Down Expand Up @@ -949,12 +945,6 @@ fn auto_finalizing_vote_on_no_confidence_when_threshold_is_met() {
});
}

#[test]
fn convert_to_proposal_not_enough_for_storage_deposit() {
build_test_externality().execute_with(|| {
assert!(false);
});
}
#[test]
fn convert_to_proposal_too_many_contributions() {
build_test_externality().execute_with(|| {
Expand Down Expand Up @@ -993,6 +983,27 @@ fn try_convert_to_milestones_too_many_milestones() {
assert!(false);
});
}

#[test]
fn try_convert_to_milestones_works() {
build_test_externality().execute_with(|| {
assert!(false);
});
}

#[test]
fn convert_contributions_to_refund_locations_works() {
build_test_externality().execute_with(|| {
assert!(false);
});
}

fn convert_contributions_to_refund_locations_uses_treasury_for_dust_clearance() {
build_test_externality().execute_with(|| {
assert!(false);
});
}

// todo: finalise voteof no confidence tests.
// ^^ is connected to making the pallet generic over funding type.
// Todo: assert the last event of each extrinsic/
8 changes: 8 additions & 0 deletions pallets/proposals/src/todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Take fee from withdraws, to treasury or fee account
complete the tests for the new impls
remove all no confidence logic + tests
migration for project pallet
10% fee if a vetter exists for the project.


0 comments on commit 2f0f9dc

Please sign in to comment.