|
@@ -1,3 +1,6 @@
|
|
|
+#![allow(unnameable_test_items)]
|
|
|
+#![allow(dead_code)]
|
|
|
+
|
|
|
use super::*;
|
|
|
|
|
|
use system::RawOrigin;
|
|
@@ -13,7 +16,7 @@ use crate::{
|
|
|
};
|
|
|
use sp_std::collections::btree_set::BTreeSet;
|
|
|
|
|
|
-use crate::primitives::{AccountId, ActorId, MemberId};
|
|
|
+use crate::primitives::{ActorId, MemberId};
|
|
|
use frame_support::traits;
|
|
|
use strum::IntoEnumIterator;
|
|
|
|
|
@@ -53,7 +56,7 @@ fn add_opening(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_add_working_group_leader_opening_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id as u64,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -88,7 +91,7 @@ fn begin_review_applications(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_begin_review_working_group_leader_applications_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -118,7 +121,7 @@ fn fill_opening(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_fill_working_group_leader_opening_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -159,7 +162,7 @@ fn decrease_stake(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_decrease_working_group_leader_stake_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -189,7 +192,7 @@ fn slash_stake(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_slash_working_group_leader_stake_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -219,7 +222,7 @@ fn set_reward(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_set_working_group_leader_reward_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id as u64,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -236,27 +239,33 @@ fn set_reward(
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
|
|
|
|
-fn set_mint_capacity(
|
|
|
+fn set_mint_capacity<
|
|
|
+ T: working_group::Trait<I> + system::Trait + minting::Trait,
|
|
|
+ I: working_group::Instance,
|
|
|
+>(
|
|
|
member_id: MemberId,
|
|
|
account_id: [u8; 32],
|
|
|
mint_capacity: Balance,
|
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
setup_environment: bool,
|
|
|
working_group: WorkingGroup,
|
|
|
-) {
|
|
|
+) where
|
|
|
+ <T as minting::Trait>::MintId: From<u64>,
|
|
|
+{
|
|
|
let expected_proposal_id = sequence_number;
|
|
|
let run_to_block = sequence_number * 2;
|
|
|
|
|
|
let mint_id_result = <minting::Module<Runtime>>::add_mint(0, None);
|
|
|
|
|
|
if let Ok(mint_id) = mint_id_result {
|
|
|
- <working_group::Mint<Runtime, ContentDirectoryWorkingGroupInstance>>::put(mint_id);
|
|
|
+ let mint_id: <T as minting::Trait>::MintId = mint_id.into();
|
|
|
+ <working_group::Mint<T, I>>::put(mint_id);
|
|
|
}
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_set_working_group_mint_capacity_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
- member_id as u64,
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
+ member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
@@ -284,7 +293,7 @@ fn terminate_role(
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_terminate_working_group_leader_role_proposal(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
|
b"body".to_vec(),
|
|
@@ -331,7 +340,6 @@ fn run_create_add_working_group_leader_opening_proposal_execution_succeeds<
|
|
|
>(
|
|
|
working_group: WorkingGroup,
|
|
|
) where
|
|
|
- <T as system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
<T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
{
|
|
@@ -398,7 +406,7 @@ fn run_create_begin_review_working_group_leader_applications_proposal_execution_
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
None,
|
|
|
1,
|
|
@@ -409,7 +417,8 @@ fn run_create_begin_review_working_group_leader_applications_proposal_execution_
|
|
|
<T as hiring::Trait>::OpeningId::from(opening_id),
|
|
|
);
|
|
|
|
|
|
- let hiring_opening = Hiring::opening_by_id(opening.hiring_opening_id.into());
|
|
|
+ let hiring_opening_id: u64 = opening.hiring_opening_id.into();
|
|
|
+ let hiring_opening = Hiring::opening_by_id(hiring_opening_id);
|
|
|
assert_eq!(
|
|
|
hiring_opening.stage,
|
|
|
hiring::OpeningStage::Active {
|
|
@@ -425,7 +434,7 @@ fn run_create_begin_review_working_group_leader_applications_proposal_execution_
|
|
|
|
|
|
begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
- let hiring_opening = Hiring::opening_by_id(opening.hiring_opening_id.into());
|
|
|
+ let hiring_opening = Hiring::opening_by_id(hiring_opening_id);
|
|
|
assert_eq!(
|
|
|
hiring_opening.stage,
|
|
|
hiring::OpeningStage::Active {
|
|
@@ -478,7 +487,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
None,
|
|
|
1,
|
|
@@ -486,10 +495,10 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
);
|
|
|
|
|
|
let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id.into(),
|
|
|
opening_id.into(),
|
|
|
- account_id.clone().into(),
|
|
|
+ account_id.into(),
|
|
|
None,
|
|
|
None,
|
|
|
Vec::new(),
|
|
@@ -570,7 +579,7 @@ fn run_create_decrease_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
1,
|
|
@@ -578,10 +587,10 @@ fn run_create_decrease_group_leader_stake_proposal_execution_succeeds<
|
|
|
);
|
|
|
|
|
|
let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id.into(),
|
|
|
opening_id.into(),
|
|
|
- account_id.clone().into(),
|
|
|
+ account_id.into(),
|
|
|
Some(stake_amount.into()),
|
|
|
None,
|
|
|
Vec::new(),
|
|
@@ -686,7 +695,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
1,
|
|
@@ -792,7 +801,14 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
assert_eq!(WorkingGroupInstance::<T, I>::mint(), 0.into());
|
|
|
|
|
|
let mint_capacity = 999999;
|
|
|
- set_mint_capacity(member_id, account_id, mint_capacity, 1, true, working_group);
|
|
|
+ set_mint_capacity::<T, I>(
|
|
|
+ member_id,
|
|
|
+ account_id,
|
|
|
+ mint_capacity,
|
|
|
+ 1,
|
|
|
+ true,
|
|
|
+ working_group,
|
|
|
+ );
|
|
|
|
|
|
let mint_id = WorkingGroupInstance::<T, I>::mint();
|
|
|
let mint = <minting::Module<T>>::mints(mint_id);
|
|
@@ -805,13 +821,38 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
// This uses strum crate for enum iteration
|
|
|
for group in WorkingGroup::iter() {
|
|
|
- run_create_set_group_leader_reward_proposal_execution_succeeds(group);
|
|
|
+ match group {
|
|
|
+ WorkingGroup::Content => {
|
|
|
+ run_create_set_working_group_mint_capacity_proposal_execution_succeeds::<
|
|
|
+ Runtime,
|
|
|
+ ContentDirectoryWorkingGroupInstance,
|
|
|
+ >(group);
|
|
|
+ }
|
|
|
+ WorkingGroup::Storage => {
|
|
|
+ run_create_set_working_group_mint_capacity_proposal_execution_succeeds::<
|
|
|
+ Runtime,
|
|
|
+ StorageWorkingGroupInstance,
|
|
|
+ >(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn run_create_set_group_leader_reward_proposal_execution_succeeds(
|
|
|
+ fn run_create_set_group_leader_reward_proposal_execution_succeeds<
|
|
|
+ T: working_group::Trait<I> + system::Trait + minting::Trait,
|
|
|
+ I: working_group::Instance,
|
|
|
+ >(
|
|
|
working_group: WorkingGroup,
|
|
|
- ) {
|
|
|
+ ) where
|
|
|
+ <T as system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
+ <T as membership::Trait>::MemberId: From<u64>,
|
|
|
+ <T as membership::Trait>::ActorId: Into<u64>,
|
|
|
+ <T as minting::Trait>::MintId: From<u64>,
|
|
|
+ <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
+ <<T as minting::Trait>::Currency as traits::Currency<
|
|
|
+ <T as system::Trait>::AccountId,
|
|
|
+ >>::Balance: From<u128>,
|
|
|
+ {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
@@ -829,19 +870,19 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
1,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
- member_id as u64,
|
|
|
- opening_id,
|
|
|
- account_id.clone().into(),
|
|
|
- Some(stake_amount),
|
|
|
+ let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
+ member_id.into(),
|
|
|
+ opening_id.into(),
|
|
|
+ account_id.into(),
|
|
|
+ Some(stake_amount.into()),
|
|
|
None,
|
|
|
Vec::new(),
|
|
|
);
|
|
@@ -852,7 +893,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
- let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
+ let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
let old_reward_amount = 100;
|
|
@@ -862,7 +903,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
payout_interval: None,
|
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
+ set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
|
member_id,
|
|
@@ -874,28 +915,28 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
+ let leader_worker_id = WorkingGroupInstance::<T, I>::current_lead().unwrap();
|
|
|
|
|
|
- let worker = ContentDirectoryWorkingGroup::worker_by_id(leader_worker_id);
|
|
|
+ let worker = WorkingGroupInstance::<T, I>::worker_by_id(leader_worker_id);
|
|
|
let relationship_id = worker.reward_relationship.unwrap();
|
|
|
|
|
|
let relationship =
|
|
|
- recurring_rewards::RewardRelationships::<Runtime>::get(relationship_id);
|
|
|
- assert_eq!(relationship.amount_per_payout, old_reward_amount);
|
|
|
+ recurring_rewards::RewardRelationships::<T>::get(relationship_id);
|
|
|
+ assert_eq!(relationship.amount_per_payout, old_reward_amount.into());
|
|
|
|
|
|
let new_reward_amount = 999;
|
|
|
set_reward(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
- leader_worker_id,
|
|
|
+ leader_worker_id.into(),
|
|
|
new_reward_amount,
|
|
|
5,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
let relationship =
|
|
|
- recurring_rewards::RewardRelationships::<Runtime>::get(relationship_id);
|
|
|
- assert_eq!(relationship.amount_per_payout, new_reward_amount);
|
|
|
+ recurring_rewards::RewardRelationships::<T>::get(relationship_id);
|
|
|
+ assert_eq!(relationship.amount_per_payout, new_reward_amount.into());
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -903,17 +944,42 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
|
// This uses strum crate for enum iteration
|
|
|
for group in WorkingGroup::iter() {
|
|
|
- run_create_terminate_group_leader_role_proposal_execution_succeeds(group);
|
|
|
+ match group {
|
|
|
+ WorkingGroup::Content => {
|
|
|
+ run_create_terminate_group_leader_role_proposal_execution_succeeds::<
|
|
|
+ Runtime,
|
|
|
+ ContentDirectoryWorkingGroupInstance,
|
|
|
+ >(group);
|
|
|
+ }
|
|
|
+ WorkingGroup::Storage => {
|
|
|
+ run_create_terminate_group_leader_role_proposal_execution_succeeds::<
|
|
|
+ Runtime,
|
|
|
+ StorageWorkingGroupInstance,
|
|
|
+ >(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn run_create_terminate_group_leader_role_proposal_execution_succeeds(
|
|
|
+ fn run_create_terminate_group_leader_role_proposal_execution_succeeds<
|
|
|
+ T: working_group::Trait<I> + system::Trait + minting::Trait,
|
|
|
+ I: working_group::Instance,
|
|
|
+ >(
|
|
|
working_group: WorkingGroup,
|
|
|
- ) {
|
|
|
+ ) where
|
|
|
+ <T as system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
+ <T as membership::Trait>::MemberId: From<u64>,
|
|
|
+ <T as membership::Trait>::ActorId: Into<u64>,
|
|
|
+ <T as minting::Trait>::MintId: From<u64>,
|
|
|
+ <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
+ <<T as stake::Trait>::Currency as traits::Currency<
|
|
|
+ <T as system::Trait>::AccountId,
|
|
|
+ >>::Balance: From<u128>,
|
|
|
+ {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
|
let account_id: [u8; 32] = [0; 32];
|
|
|
- let stake_amount = 100;
|
|
|
+ let stake_amount = 100_u128;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
role_staking_policy: Some(hiring::StakingPolicy {
|
|
@@ -926,20 +992,20 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
};
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id.clone(),
|
|
|
+ member_id.into(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
1,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
- member_id as u64,
|
|
|
- opening_id,
|
|
|
- account_id.clone().into(),
|
|
|
- Some(stake_amount),
|
|
|
+ let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
+ member_id.into(),
|
|
|
+ opening_id.into(),
|
|
|
+ account_id.into(),
|
|
|
+ Some(stake_amount.into()),
|
|
|
None,
|
|
|
Vec::new(),
|
|
|
);
|
|
@@ -950,7 +1016,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
- let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
+ let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
let old_reward_amount = 100;
|
|
@@ -960,7 +1026,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
payout_interval: None,
|
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
+ set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
|
member_id,
|
|
@@ -978,18 +1044,18 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
+ let leader_worker_id = WorkingGroupInstance::<T, I>::current_lead().unwrap();
|
|
|
|
|
|
terminate_role(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
- leader_worker_id,
|
|
|
+ leader_worker_id.into(),
|
|
|
false,
|
|
|
5,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
|
+ assert!(WorkingGroupInstance::<T, I>::current_lead().is_none());
|
|
|
|
|
|
let new_balance = Balances::free_balance(&account_id.into());
|
|
|
let new_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
@@ -1003,19 +1069,36 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds() {
|
|
|
// This uses strum crate for enum iteration
|
|
|
for group in WorkingGroup::iter() {
|
|
|
- run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
|
- group,
|
|
|
- );
|
|
|
+ match group {
|
|
|
+ WorkingGroup::Content => {
|
|
|
+ run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds::<Runtime, ContentDirectoryWorkingGroupInstance>(group);
|
|
|
+ }
|
|
|
+ WorkingGroup::Storage => {
|
|
|
+ run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds::<Runtime, StorageWorkingGroupInstance>(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
|
+ fn run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds<
|
|
|
+ T: working_group::Trait<I> + system::Trait + minting::Trait,
|
|
|
+ I: working_group::Instance,
|
|
|
+ >(
|
|
|
working_group: WorkingGroup,
|
|
|
- ) {
|
|
|
+ ) where
|
|
|
+ <T as system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
+ <T as membership::Trait>::MemberId: From<u64>,
|
|
|
+ <T as membership::Trait>::ActorId: Into<u64>,
|
|
|
+ <T as minting::Trait>::MintId: From<u64>,
|
|
|
+ <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
+ <<T as stake::Trait>::Currency as traits::Currency<
|
|
|
+ <T as system::Trait>::AccountId,
|
|
|
+ >>::Balance: From<u128>,
|
|
|
+ {
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
|
let account_id: [u8; 32] = [0; 32];
|
|
|
- let stake_amount = 100;
|
|
|
+ let stake_amount = 100_u128;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
role_staking_policy: Some(hiring::StakingPolicy {
|
|
@@ -1029,19 +1112,19 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
- account_id.clone(),
|
|
|
+ account_id,
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
1,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
|
- RawOrigin::Signed(account_id.clone().into()).into(),
|
|
|
- member_id,
|
|
|
- opening_id,
|
|
|
- account_id.clone().into(),
|
|
|
- Some(stake_amount),
|
|
|
+ let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
+ RawOrigin::Signed(account_id.into()).into(),
|
|
|
+ member_id.into(),
|
|
|
+ opening_id.into(),
|
|
|
+ account_id.into(),
|
|
|
+ Some(stake_amount.into()),
|
|
|
None,
|
|
|
Vec::new(),
|
|
|
);
|
|
@@ -1050,9 +1133,15 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
+ begin_review_applications(
|
|
|
+ member_id,
|
|
|
+ account_id,
|
|
|
+ opening_id.into(),
|
|
|
+ 2,
|
|
|
+ working_group,
|
|
|
+ );
|
|
|
|
|
|
- let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
+ let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
let old_reward_amount = 100;
|
|
@@ -1062,7 +1151,7 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
payout_interval: None,
|
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
+ set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
|
member_id,
|
|
@@ -1080,18 +1169,18 @@ fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
+ let leader_worker_id = WorkingGroupInstance::<T, I>::current_lead().unwrap();
|
|
|
|
|
|
terminate_role(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
- leader_worker_id,
|
|
|
+ leader_worker_id.into(),
|
|
|
true,
|
|
|
5,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
|
+ assert!(WorkingGroupInstance::<T, I>::current_lead().is_none());
|
|
|
|
|
|
let new_balance = Balances::free_balance(&account_id.into());
|
|
|
let new_stake = <stake::Module<Runtime>>::stakes(stake_id);
|