diff --git a/pallets/briefs/src/mock.rs b/pallets/briefs/src/mock.rs index 96a84f44..de4b9ec1 100644 --- a/pallets/briefs/src/mock.rs +++ b/pallets/briefs/src/mock.rs @@ -308,6 +308,8 @@ pub static BOB: AccountId = 126; pub static CHARLIE: AccountId = 127; pub static FREELANCER: AccountId = 1270; pub static TREASURY: AccountId = 200; +pub static JURY_1: AccountId = 1002; +pub static JURY_2: AccountId = 1001; pub(crate) fn build_test_externality() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default() @@ -340,7 +342,9 @@ pub struct MockJurySelector; impl pallet_fellowship::traits::SelectJury for MockJurySelector { type JurySize = MaxJuryMembers; fn select_jury() -> BoundedVec { - BoundedVec::new() + vec![JURY_1, JURY_2] + .try_into() + .expect("should be below bound.") } } diff --git a/pallets/disputes/src/impls.rs b/pallets/disputes/src/impls.rs index 1393bdea..b9181d1d 100644 --- a/pallets/disputes/src/impls.rs +++ b/pallets/disputes/src/impls.rs @@ -3,7 +3,7 @@ use frame_support::BoundedVec; use sp_runtime::DispatchError; use crate::pallet::{AccountIdOf, Config, Dispute}; -use traits::DisputeRaiser; +use crate::traits::{DisputeHooks, DisputeRaiser}; impl DisputeRaiser> for Pallet { type DisputeKey = T::DisputeKey; diff --git a/pallets/proposals/src/benchmarking.rs b/pallets/proposals/src/benchmarking.rs index b3deb780..be1f3a07 100644 --- a/pallets/proposals/src/benchmarking.rs +++ b/pallets/proposals/src/benchmarking.rs @@ -29,6 +29,8 @@ mod benchmarks { create_funded_user::("contributor", 1, 1_000_000_000_000_000_000u128); let bob: T::AccountId = create_funded_user::("initiator", 1, 1_000_000_000_000_000_000u128); + let jury = get_funded_jury::(10); + let contributions = get_contributions::(vec![alice], 100_000_000_000_000_000u128); let prop_milestones = get_max_milestones::(); let project_key = create_and_fund_project::( @@ -36,6 +38,7 @@ mod benchmarks { contributions, prop_milestones, CurrencyId::Native, + jury, ) .unwrap(); @@ -50,6 +53,8 @@ mod benchmarks { create_funded_user::("initiator", 1, 1_000_000_000_000_000_000u128); let bob: T::AccountId = create_funded_user::("contributor", 1, 1_000_000_000_000_000_000u128); + let jury = get_funded_jury::(10); + // TODO: should update the contributors list to have maximum available length let contributions = get_contributions::(vec![bob.clone()], 1_000_000_000_000u128); let prop_milestones = get_max_milestones::(); @@ -58,6 +63,7 @@ mod benchmarks { contributions, prop_milestones, CurrencyId::Native, + jury, ) .unwrap(); @@ -81,9 +87,9 @@ mod benchmarks { create_funded_user::("initiator", 1, 1_000_000_000_000_000_000u128); let bob: T::AccountId = create_funded_user::("contributor", 1, 1_000_000_000_000_000_000u128); + let jury = get_funded_jury::(10); let contributions = get_contributions::(vec![bob.clone()], 100_000_000_000_000_000u128); let raised_funds = 100_000_000_000_000_000u128.saturated_into(); - let milestone_count = ::MaxMilestonesPerProject::get(); let prop_milestones = get_milestones(milestone_count as u8); @@ -92,6 +98,7 @@ mod benchmarks { contributions, prop_milestones, CurrencyId::Native, + jury, ) .unwrap(); @@ -145,6 +152,7 @@ mod benchmarks { create_funded_user::("initiator", 1, 1_000_000_000_000_000_000u128); let bob: T::AccountId = create_funded_user::("contributor", 0, 1_000_000_000_000_000_000u128); + let jury = get_funded_jury::(10); let contributors: Vec = (0 ..::MaximumContributorsPerProject::get()) @@ -160,9 +168,14 @@ mod benchmarks { .try_into() .unwrap(); - let project_key = - create_and_fund_project::(alice, contributions, prop_milestones, CurrencyId::Native) - .unwrap(); + let project_key = create_and_fund_project::( + alice, + contributions, + prop_milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); #[extrinsic_call] raise_dispute(RawOrigin::Signed(bob), project_key, milestone_keys); @@ -175,6 +188,7 @@ mod benchmarks { create_funded_user::("initiator", 1, 1_000_000_000_000_000_000u128); let bob: T::AccountId = create_funded_user::("contributor", 0, 1_000_000_000_000_000_000u128); + let jury = get_funded_jury::(10); let contributors: Vec = (0 ..::MaximumContributorsPerProject::get()) @@ -192,9 +206,14 @@ mod benchmarks { .try_into() .unwrap(); - let project_key = - create_and_fund_project::(alice, contributions, prop_milestones, CurrencyId::Native) - .unwrap(); + let project_key = create_and_fund_project::( + alice, + contributions, + prop_milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); assert_ok!(crate::Pallet::::raise_dispute( RawOrigin::Signed(bob.clone()).into(), @@ -224,3 +243,9 @@ mod benchmarks { crate::mock::Test ); } + +fn get_funded_jury(n: u32) -> Vec> { + (0..n) + .map(|n| create_funded_user::("jury member", n, 1_000_000_000_000_000_000u128)) + .collect::>>() +} diff --git a/pallets/proposals/src/lib.rs b/pallets/proposals/src/lib.rs index 057e3f01..3a1ef7aa 100644 --- a/pallets/proposals/src/lib.rs +++ b/pallets/proposals/src/lib.rs @@ -354,6 +354,8 @@ pub mod pallet { OnlyContributorsCanInitiateRefund, /// Only the ForeignAssetSigner can mint tokens RequireForeignAssetSigner, + /// A Jury is required to create a project. + JuryRequired, } #[pallet::hooks] @@ -468,13 +470,18 @@ pub mod pallet { Error::::CannotRaiseDisputeOnApprovedMilestone ); - ::DisputeRaiser::raise_dispute( - project_key, - who, - project.jury, - milestone_keys.clone(), - )?; - ProjectsInDispute::::insert(project_key, milestone_keys); + if project.jury.len() == 1 { + // https://github.com/ImbueNetwork/imbue/issues/270 + let _ = >::on_dispute_complete(project_key, milestone_keys.to_vec(), pallet_disputes::DisputeResult::Success); + } else { + ::DisputeRaiser::raise_dispute( + project_key, + who, + project.jury, + milestone_keys.clone(), + )?; + ProjectsInDispute::::insert(project_key, milestone_keys); + } Ok(()) } @@ -641,6 +648,7 @@ pub mod pallet { jury: BoundedVec, Self::MaxJuryMembers>, on_creation_funding: FundingPath, ) -> Result<(), DispatchError> { + ensure!(jury.len() > 0, Error::::JuryRequired); let project_key = crate::ProjectCount::::get().saturating_add(1); // Take storage deposit only for a Project. diff --git a/pallets/proposals/src/migration.rs b/pallets/proposals/src/migration.rs index ce142def..6d16e87e 100644 --- a/pallets/proposals/src/migration.rs +++ b/pallets/proposals/src/migration.rs @@ -1161,9 +1161,15 @@ mod test { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, DAVE], 100_000); let prop_milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) - .expect("project wasnt created!"); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( + ALICE, + cont, + prop_milestones, + CurrencyId::Native, + jury, + ) + .expect("project wasnt created!"); let milestone_key: MilestoneKey = 0; let expiry_block: BlockNumber = 10; let rounds_expiring: BoundedProjectKeysPerBlock = diff --git a/pallets/proposals/src/mock.rs b/pallets/proposals/src/mock.rs index db32a2ab..8ee00050 100644 --- a/pallets/proposals/src/mock.rs +++ b/pallets/proposals/src/mock.rs @@ -229,6 +229,9 @@ pub static DAVE: AccountId = 128; pub static TREASURY: AccountId = 222; pub static JOHN: AccountId = 255; +pub static JURY_1: AccountId = 1000; +pub static JURY_2: AccountId = 1001; + pub(crate) fn build_test_externality() -> sp_io::TestExternalities { let t = frame_system::GenesisConfig::::default() .build_storage() diff --git a/pallets/proposals/src/test_utils.rs b/pallets/proposals/src/test_utils.rs index f669b915..d697ec97 100644 --- a/pallets/proposals/src/test_utils.rs +++ b/pallets/proposals/src/test_utils.rs @@ -67,6 +67,7 @@ pub fn create_and_fund_project( contributions: ContributionsFor, proposed_milestones: Vec, currency_id: CurrencyId, + jury: Vec>, ) -> Result { contributions.iter().for_each(|(acc, c)| { ::MultiCurrency::reserve(currency_id, acc, c.value).unwrap(); @@ -86,7 +87,7 @@ pub fn create_and_fund_project( beneficiary, proposed_milestones.try_into().map_err(|_|Error::::TooManyMilestones)?, refund_locations, - BoundedVec::new(), + jury.try_into().expect("Too many Jury members."), FundingPath::TakeFromReserved, )?; diff --git a/pallets/proposals/src/tests/disputes.rs b/pallets/proposals/src/tests/disputes.rs index 3106528e..87a76afe 100644 --- a/pallets/proposals/src/tests/disputes.rs +++ b/pallets/proposals/src/tests/disputes.rs @@ -9,11 +9,14 @@ fn raise_dispute_not_contributor() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -48,11 +51,14 @@ fn raise_dispute_milestone_already_in_dispute() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -83,9 +89,16 @@ fn raise_dispute_invalid_milestone_key() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); assert_noop!( Proposals::raise_dispute( RuntimeOrigin::signed(BOB), @@ -118,9 +131,16 @@ fn raise_dispute_cant_raise_on_approved_milestone() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); let submitted_milestone_key = 0u32; assert_ok!(Proposals::submit_milestone( @@ -165,11 +185,14 @@ fn on_dispute_complete_success_removes_dispute_status() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -196,11 +219,14 @@ fn on_dispute_complete_failure_removes_dispute_status() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -227,11 +253,14 @@ fn dispute_success_does_not_cancel_project() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -261,11 +290,14 @@ fn dispute_success_approves_milestone_for_refund_but_only_ones_specified() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (1u32 @@ -293,11 +325,14 @@ fn raise_dispute_allows_milestone_voting() { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); let submitted_milestone_key = 0; + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); @@ -338,11 +373,14 @@ fn raise_dispute_allows_milestone_voting_on_non_disputed_milestones() { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); let submitted_milestone_keys = [0, 1]; + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); @@ -390,11 +428,14 @@ fn raise_dispute_allows_submission() { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); let milestone_key = 0; + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); @@ -422,11 +463,14 @@ fn failed_dispute_tests() { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); let _milestone_key = 0; + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); @@ -461,9 +505,16 @@ fn assert_can_recall_dispute_after_success() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); // Only call the dispute on part. let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32..5_u32).collect::>().try_into().unwrap(); @@ -493,9 +544,16 @@ fn assert_can_recall_dispute_after_failure() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); // Only call the dispute on part. let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32..5_u32).collect::>().try_into().unwrap(); @@ -519,3 +577,53 @@ fn assert_can_recall_dispute_after_failure() { )); }) } + +#[test] +fn raise_dispute_with_single_jury_auto_completes() { + build_test_externality().execute_with(|| { + let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); + let milestones = get_milestones(10); + let jury = vec![JURY_1]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones.clone(), + CurrencyId::Native, + jury, + ) + .unwrap(); + + let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 + ..milestones.len() as u32) + .collect::>() + .try_into() + .unwrap(); + + assert_ok!(Proposals::raise_dispute( + RuntimeOrigin::signed(BOB), + project_key, + milestone_keys.clone() + )); + + let project = Projects::::get(project_key).unwrap(); + + project.milestones.iter().for_each(|(key, ms)| { + // if its meant to be approved for refund then check + if milestone_keys.contains(key) { + assert!( + ms.can_refund, + "the dispute should have bypassed dispute pallet and autofinalised." + ); + } else { + assert!( + !ms.can_refund, + "This milestone should not have been approved for refund." + ); + } + + // They havent been transferred yet + assert_eq!(ms.transfer_status, None) + }); + }) +} diff --git a/pallets/proposals/src/tests/pallet.rs b/pallets/proposals/src/tests/pallet.rs index d7b85006..43ddaeef 100644 --- a/pallets/proposals/src/tests/pallet.rs +++ b/pallets/proposals/src/tests/pallet.rs @@ -21,8 +21,10 @@ fn submit_milestone_milestone_doesnt_exist() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_noop!( Proposals::submit_milestone(RuntimeOrigin::signed(ALICE), project_key, 11), @@ -46,8 +48,10 @@ fn submit_milestone_not_initiator() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_noop!( Proposals::submit_milestone(RuntimeOrigin::signed(BOB), project_key, 1), @@ -66,6 +70,7 @@ fn submit_milestones_too_many_this_block() { let max = ::ExpiringProjectRoundsPerBlock::get(); let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; (0..=max).for_each(|i| { let project_key = create_and_fund_project::( @@ -73,6 +78,7 @@ fn submit_milestones_too_many_this_block() { cont.clone(), prop_milestones.clone(), CurrencyId::Native, + jury.clone(), ) .unwrap(); if i != max { @@ -96,8 +102,10 @@ fn submit_milestone_creates_non_bias_vote() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( RuntimeOrigin::signed(ALICE), @@ -117,8 +125,10 @@ fn submit_milestone_can_resubmit_during_voting_round() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -163,8 +173,10 @@ fn submit_milestone_can_submit_again_after_failed_vote() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( RuntimeOrigin::signed(ALICE), @@ -187,8 +199,10 @@ fn submit_milestone_cannot_submit_again_after_success_vote() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -224,8 +238,10 @@ fn ensure_milestone_vote_data_is_cleaned_after_autofinalisation_for() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -291,8 +307,10 @@ fn ensure_milestone_vote_data_is_cleaned_after_autofinalisation_against() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -357,8 +375,10 @@ fn users_can_submit_multiple_milestones_and_vote_independantly() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key_0 = 0; let milestone_key_1 = 1; @@ -416,8 +436,10 @@ fn vote_on_milestone_before_round_starts_fails() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_noop!( @@ -437,8 +459,10 @@ fn vote_on_milestone_after_round_end_fails() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; let expiring_block = frame_system::Pallet::::block_number() @@ -466,8 +490,10 @@ fn vote_on_milestone_where_voting_round_is_active_but_not_the_correct_milestone( build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( RuntimeOrigin::signed(ALICE), @@ -486,8 +512,10 @@ fn if_double_submission_and_one_finalises_voting_on_the_second_can_vote() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let expiring_block = frame_system::Pallet::::block_number() + ::MilestoneVotingWindow::get(); @@ -517,8 +545,10 @@ fn vote_on_milestone_not_contributor() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -543,8 +573,10 @@ fn vote_on_milestone_actually_adds_to_vote() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -581,8 +613,10 @@ fn vote_on_milestone_autofinalises_on_all_voted_and_fail() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE, DAVE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -620,8 +654,10 @@ fn withdraw_not_initiator() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB, CHARLIE], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_ok!(Proposals::submit_milestone( @@ -659,8 +695,10 @@ fn withdraw_only_transfers_approved_milestones() { let per_contribution = 100_000; let cont = get_contributions::(vec![BOB, CHARLIE], per_contribution); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let project_account = crate::Pallet::::project_account_id(project_key); let milestone_key = 0; @@ -708,8 +746,10 @@ fn withdraw_removes_project_after_all_funds_taken() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(1); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; let _ = @@ -740,8 +780,10 @@ fn store_project_info_after_project_is_completed() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(1); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; let _ = @@ -773,6 +815,8 @@ fn store_too_many_projects_for_account() { let max = ::MaxProjectsPerAccount::get(); let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(1); + let jury = vec![JURY_1, JURY_2]; + let milestone_key = 0; (0..=max).for_each(|i| { let project_key = create_and_fund_project::( @@ -780,6 +824,7 @@ fn store_too_many_projects_for_account() { cont.clone(), prop_milestones.clone(), CurrencyId::Native, + jury.clone(), ) .unwrap(); let _ = Proposals::submit_milestone( @@ -816,8 +861,10 @@ fn withdraw_takes_imbue_fee() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; let fee_account: AccountId = ::ImbueFeeAccount::get(); @@ -855,8 +902,10 @@ fn withdraw_cannot_double_withdraw() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; let _ = @@ -885,8 +934,10 @@ fn withdraw_once_times_with_double_submissions() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let _ = Proposals::submit_milestone(RuntimeOrigin::signed(ALICE), project_key, 0).unwrap(); let _ = @@ -917,8 +968,10 @@ fn withdraw_twice_with_intermitent_submission() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); // The first submission and withdraw @@ -971,8 +1024,10 @@ fn withdraw_with_variable_percentage() { percentage_to_unlock: Percent::from_percent(30u8), }, ]; + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let _ = Proposals::submit_milestone(RuntimeOrigin::signed(ALICE), project_key, 0).unwrap(); let _ = @@ -998,8 +1053,10 @@ fn withdraw_fails_before_approval() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_noop!( @@ -1021,8 +1078,10 @@ fn withdraw_assert_milestone_state_change() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); let milestone_key = 0; assert_noop!( @@ -1079,8 +1138,10 @@ fn project_in_voting_is_saved_on_submission() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( @@ -1104,8 +1165,10 @@ fn project_in_voting_is_removed_on_init_hook() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( @@ -1130,8 +1193,10 @@ fn project_in_voting_is_removed_on_milestone_autofinalisation() { build_test_externality().execute_with(|| { let cont = get_contributions::(vec![BOB], 100_000); let prop_milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = - create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native) + create_and_fund_project::(ALICE, cont, prop_milestones, CurrencyId::Native, jury) .unwrap(); assert_ok!(Proposals::submit_milestone( diff --git a/pallets/proposals/src/tests/refunds.rs b/pallets/proposals/src/tests/refunds.rs index c61c6dab..bca95eec 100644 --- a/pallets/proposals/src/tests/refunds.rs +++ b/pallets/proposals/src/tests/refunds.rs @@ -8,11 +8,14 @@ fn you_can_actually_refund_after_dispute_success() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -41,9 +44,16 @@ fn refund_assert_milestone_state_change() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB], 1_000_000u128); let milestones = get_milestones(10); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); // Only dispute some keys so that we can let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32..5_u32).collect::>().try_into().unwrap(); @@ -85,11 +95,14 @@ fn refund_not_contributor() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -119,11 +132,14 @@ fn refund_deletes_project_when_all_funds_are_refunded() { build_test_externality().execute_with(|| { let contributions = get_contributions::(vec![BOB, CHARLIE], 1_000_000u128); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -161,11 +177,14 @@ fn withdraw_then_refund_no_double_spend() { ::MultiCurrency::free_balance(CurrencyId::Native, &ALICE); let bob_before_creation = ::MultiCurrency::free_balance(CurrencyId::Native, &ALICE); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -231,9 +250,16 @@ fn refund_then_withdraw_no_double_spend() { ::MultiCurrency::free_balance(CurrencyId::Native, &ALICE); let _bob_before_creation = ::MultiCurrency::free_balance(CurrencyId::Native, &ALICE); - let project_key = - create_and_fund_project::(ALICE, contributions, milestones, CurrencyId::Native) - .unwrap(); + let jury = vec![JURY_1, JURY_2]; + + let project_key = create_and_fund_project::( + ALICE, + contributions, + milestones, + CurrencyId::Native, + jury, + ) + .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32..5_u32).collect::>().try_into().unwrap(); let _ = Proposals::raise_dispute( @@ -275,11 +301,14 @@ fn refund_check_refund_amount() { let per_contribution = 100000u128; let contributions = get_contributions::(vec![BOB, CHARLIE], per_contribution); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32 @@ -333,11 +362,14 @@ fn refund_takes_imbue_fee() { let contributions = get_contributions::(vec![BOB, CHARLIE], per_contribution); let milestones = get_milestones(10); + let jury = vec![JURY_1, JURY_2]; + let project_key = create_and_fund_project::( ALICE, contributions, milestones.clone(), CurrencyId::Native, + jury, ) .unwrap(); let milestone_keys: BoundedVec::MaxMilestonesPerProject> = (0u32