|
@@ -6,17 +6,14 @@ use super::*;
|
|
|
use frame_system::RawOrigin;
|
|
|
|
|
|
use common::working_group::WorkingGroup;
|
|
|
-use hiring::ActivateOpeningAt;
|
|
|
use proposals_codex::AddOpeningParameters;
|
|
|
-use working_group::{OpeningPolicyCommitment, RewardPolicy};
|
|
|
+use working_group::Penalty;
|
|
|
|
|
|
+use crate::primitives::{ActorId, MemberId};
|
|
|
use crate::{
|
|
|
Balance, BlockNumber, ContentDirectoryWorkingGroup, ContentDirectoryWorkingGroupInstance,
|
|
|
StorageWorkingGroup, StorageWorkingGroupInstance,
|
|
|
};
|
|
|
-use sp_std::collections::btree_set::BTreeSet;
|
|
|
-
|
|
|
-use crate::primitives::{ActorId, MemberId};
|
|
|
use frame_support::traits;
|
|
|
use strum::IntoEnumIterator;
|
|
|
|
|
@@ -27,8 +24,7 @@ type Hiring = hiring::Module<Runtime>;
|
|
|
fn add_opening(
|
|
|
member_id: MemberId,
|
|
|
account_id: [u8; 32],
|
|
|
- activate_at: hiring::ActivateOpeningAt<BlockNumber>,
|
|
|
- opening_policy_commitment: Option<OpeningPolicyCommitment<BlockNumber, u128>>,
|
|
|
+ stake_policy: Option<working_group::StakePolicy<BlockNumber, Balance>>,
|
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
working_group: WorkingGroup,
|
|
|
) -> u64 {
|
|
@@ -62,11 +58,9 @@ fn add_opening(
|
|
|
b"body".to_vec(),
|
|
|
Some(account_id.into()),
|
|
|
AddOpeningParameters {
|
|
|
- activate_at: activate_at.clone(),
|
|
|
- commitment: opening_policy_commitment
|
|
|
- .clone()
|
|
|
- .unwrap_or(OpeningPolicyCommitment::default()),
|
|
|
- human_readable_text: Vec::new(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_policy: stake_policy.clone(),
|
|
|
+ reward_policy: None,
|
|
|
working_group,
|
|
|
},
|
|
|
None,
|
|
@@ -80,41 +74,11 @@ fn add_opening(
|
|
|
opening_id
|
|
|
}
|
|
|
|
|
|
-fn begin_review_applications(
|
|
|
- member_id: MemberId,
|
|
|
- account_id: [u8; 32],
|
|
|
- opening_id: u64,
|
|
|
- sequence_number: u32, // action sequence number to align with other actions
|
|
|
- working_group: WorkingGroup,
|
|
|
-) {
|
|
|
- let expected_proposal_id = sequence_number;
|
|
|
- let run_to_block = sequence_number * 2;
|
|
|
-
|
|
|
- let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
- ProposalCodex::create_begin_review_working_group_leader_applications_proposal(
|
|
|
- RawOrigin::Signed(account_id.into()).into(),
|
|
|
- member_id,
|
|
|
- b"title".to_vec(),
|
|
|
- b"body".to_vec(),
|
|
|
- Some(account_id.into()),
|
|
|
- opening_id,
|
|
|
- working_group,
|
|
|
- None,
|
|
|
- )
|
|
|
- })
|
|
|
- .disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(expected_proposal_id)
|
|
|
- .with_run_to_block(run_to_block);
|
|
|
-
|
|
|
- codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
-}
|
|
|
-
|
|
|
fn fill_opening(
|
|
|
member_id: MemberId,
|
|
|
account_id: [u8; 32],
|
|
|
opening_id: u64,
|
|
|
successful_application_id: u64,
|
|
|
- reward_policy: Option<RewardPolicy<Balance, BlockNumber>>,
|
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
working_group: WorkingGroup,
|
|
|
) {
|
|
@@ -131,7 +95,6 @@ fn fill_opening(
|
|
|
proposals_codex::FillOpeningParameters {
|
|
|
opening_id,
|
|
|
successful_application_id,
|
|
|
- reward_policy: reward_policy.clone(),
|
|
|
working_group,
|
|
|
},
|
|
|
None,
|
|
@@ -202,7 +165,10 @@ fn slash_stake(
|
|
|
b"body".to_vec(),
|
|
|
Some(account_id.into()),
|
|
|
leader_worker_id,
|
|
|
- stake_amount,
|
|
|
+ Penalty {
|
|
|
+ slashing_amount: stake_amount,
|
|
|
+ slashing_text: Vec::new(),
|
|
|
+ },
|
|
|
working_group,
|
|
|
None,
|
|
|
)
|
|
@@ -233,7 +199,7 @@ fn set_reward(
|
|
|
b"body".to_vec(),
|
|
|
Some(account_id.into()),
|
|
|
leader_worker_id,
|
|
|
- reward_amount,
|
|
|
+ Some(reward_amount),
|
|
|
working_group,
|
|
|
None,
|
|
|
)
|
|
@@ -246,7 +212,7 @@ fn set_reward(
|
|
|
}
|
|
|
|
|
|
fn set_mint_capacity<
|
|
|
- T: working_group::Trait<I> + frame_system::Trait + minting::Trait,
|
|
|
+ T: working_group::Trait<I> + frame_system::Trait,
|
|
|
I: frame_support::traits::Instance,
|
|
|
>(
|
|
|
member_id: MemberId,
|
|
@@ -255,21 +221,12 @@ fn set_mint_capacity<
|
|
|
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 {
|
|
|
- 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(
|
|
|
+ ProposalCodex::create_set_working_group_budget_capacity_proposal(
|
|
|
RawOrigin::Signed(account_id.into()).into(),
|
|
|
member_id,
|
|
|
b"title".to_vec(),
|
|
@@ -291,7 +248,6 @@ fn terminate_role(
|
|
|
member_id: MemberId,
|
|
|
account_id: [u8; 32],
|
|
|
leader_worker_id: u64,
|
|
|
- slash: bool,
|
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
working_group: WorkingGroup,
|
|
|
) {
|
|
@@ -307,8 +263,10 @@ fn terminate_role(
|
|
|
Some(account_id.into()),
|
|
|
proposals_codex::TerminateRoleParameters {
|
|
|
worker_id: leader_worker_id,
|
|
|
- rationale: Vec::new(),
|
|
|
- slash,
|
|
|
+ penalty: Some(Penalty {
|
|
|
+ slashing_amount: 100,
|
|
|
+ slashing_text: Vec::new(),
|
|
|
+ }),
|
|
|
working_group,
|
|
|
},
|
|
|
None,
|
|
@@ -349,7 +307,6 @@ fn run_create_add_working_group_leader_opening_proposal_execution_succeeds<
|
|
|
working_group: WorkingGroup,
|
|
|
) where
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
- <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
{
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
@@ -361,15 +318,8 @@ fn run_create_add_working_group_leader_opening_proposal_execution_succeeds<
|
|
|
next_opening_id
|
|
|
));
|
|
|
|
|
|
- let opening_id: <T as hiring::Trait>::OpeningId = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- None,
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- )
|
|
|
- .into();
|
|
|
+ let opening_id: working_group::OpeningId =
|
|
|
+ add_opening(member_id, account_id, None, 1, working_group).into();
|
|
|
|
|
|
// Check for expected opening id.
|
|
|
assert_eq!(opening_id, next_opening_id);
|
|
@@ -379,88 +329,6 @@ fn run_create_add_working_group_leader_opening_proposal_execution_succeeds<
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-#[test]
|
|
|
-fn create_begin_review_working_group_leader_applications_proposal_execution_succeeds() {
|
|
|
- // This uses strum crate for enum iteration
|
|
|
- for group in WorkingGroup::iter() {
|
|
|
- match group {
|
|
|
- WorkingGroup::Content => {
|
|
|
- run_create_begin_review_working_group_leader_applications_proposal_execution_succeeds::<
|
|
|
- Runtime,
|
|
|
- ContentDirectoryWorkingGroupInstance,
|
|
|
- >(group);
|
|
|
- }
|
|
|
- WorkingGroup::Storage => {
|
|
|
- run_create_begin_review_working_group_leader_applications_proposal_execution_succeeds::<
|
|
|
- Runtime,
|
|
|
- StorageWorkingGroupInstance,
|
|
|
- >(group);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-fn run_create_begin_review_working_group_leader_applications_proposal_execution_succeeds<
|
|
|
- T: working_group::Trait<I> + frame_system::Trait + stake::Trait,
|
|
|
- I: frame_support::traits::Instance,
|
|
|
->(
|
|
|
- working_group: WorkingGroup,
|
|
|
-) where
|
|
|
- <T as hiring::Trait>::OpeningId: From<u64> + Into<u64>,
|
|
|
-{
|
|
|
- initial_test_ext().execute_with(|| {
|
|
|
- let member_id: MemberId = 1;
|
|
|
- let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
-
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- None,
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
-
|
|
|
- let opening = WorkingGroupInstance::<T, I>::opening_by_id(
|
|
|
- <T as hiring::Trait>::OpeningId::from(opening_id),
|
|
|
- );
|
|
|
-
|
|
|
- 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 {
|
|
|
- stage: hiring::ActiveOpeningStage::AcceptingApplications {
|
|
|
- started_accepting_applicants_at_block: 0
|
|
|
- },
|
|
|
- applications_added: BTreeSet::new(),
|
|
|
- active_application_count: 0,
|
|
|
- unstaking_application_count: 0,
|
|
|
- deactivated_application_count: 0
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
- let grace_period = 14400;
|
|
|
- run_to_block(grace_period + 10);
|
|
|
-
|
|
|
- let hiring_opening = Hiring::opening_by_id(hiring_opening_id);
|
|
|
- assert_eq!(
|
|
|
- hiring_opening.stage,
|
|
|
- hiring::OpeningStage::Active {
|
|
|
- stage: hiring::ActiveOpeningStage::ReviewPeriod {
|
|
|
- started_accepting_applicants_at_block: 0,
|
|
|
- started_review_period_at_block: grace_period + 2,
|
|
|
- },
|
|
|
- applications_added: BTreeSet::new(),
|
|
|
- active_application_count: 0,
|
|
|
- unstaking_application_count: 0,
|
|
|
- deactivated_application_count: 0
|
|
|
- }
|
|
|
- );
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
#[test]
|
|
|
fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
// This uses strum crate for enum iteration
|
|
@@ -489,54 +357,43 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
) where
|
|
|
<T as frame_system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
- <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
+ working_group::MemberId<T>: From<u64>,
|
|
|
{
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
- let member_id: MemberId = 1;
|
|
|
+ let member_id: u64 = 1;
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- None,
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
+ let opening_id = add_opening(member_id, account_id, None, 1, working_group);
|
|
|
|
|
|
let apply_result = WorkingGroupInstance::<T, I>::apply_on_opening(
|
|
|
RawOrigin::Signed(account_id.into()).into(),
|
|
|
- member_id.into(),
|
|
|
- opening_id.into(),
|
|
|
- account_id.into(),
|
|
|
- None,
|
|
|
- None,
|
|
|
- Vec::new(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
- let grace_period_for_begin_application_proposal = 14400;
|
|
|
- run_to_block(grace_period_for_begin_application_proposal + 20);
|
|
|
-
|
|
|
fill_opening(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- None,
|
|
|
- 3,
|
|
|
+ 2,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- run_to_block(grace_period_for_begin_application_proposal + 30);
|
|
|
+ run_to_block(30);
|
|
|
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_some());
|
|
@@ -571,7 +428,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
working_group: WorkingGroup,
|
|
|
) where
|
|
|
<T as frame_system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
- <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
<T as membership::Trait>::ActorId: Into<u64>,
|
|
|
<<T as stake::Trait>::Currency as traits::Currency<
|
|
@@ -583,41 +439,29 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
let stake_amount: Balance = 100;
|
|
|
|
|
|
- let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
- role_staking_policy: Some(hiring::StakingPolicy {
|
|
|
- amount: 100,
|
|
|
- amount_mode: hiring::StakingAmountLimitMode::AtLeast,
|
|
|
- crowded_out_unstaking_period_length: None,
|
|
|
- review_period_expired_unstaking_period_length: None,
|
|
|
- }),
|
|
|
- ..OpeningPolicyCommitment::default()
|
|
|
- };
|
|
|
+ let stake_policy = Some(working_group::StakePolicy {
|
|
|
+ stake_amount: 100,
|
|
|
+ leaving_unstaking_period: 0,
|
|
|
+ });
|
|
|
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- Some(opening_policy_commitment),
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
+ let opening_id = add_opening(member_id, account_id, stake_policy, 1, working_group);
|
|
|
|
|
|
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(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
@@ -626,7 +470,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- None,
|
|
|
3,
|
|
|
working_group,
|
|
|
);
|
|
@@ -688,7 +531,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
working_group: WorkingGroup,
|
|
|
) where
|
|
|
<T as frame_system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
- <T as hiring::Trait>::OpeningId: From<u64>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
<T as membership::Trait>::ActorId: Into<u64>,
|
|
|
<<T as stake::Trait>::Currency as traits::Currency<
|
|
@@ -700,41 +542,29 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
let stake_amount: Balance = 100;
|
|
|
|
|
|
- let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
- role_staking_policy: Some(hiring::StakingPolicy {
|
|
|
- amount: 100,
|
|
|
- amount_mode: hiring::StakingAmountLimitMode::AtLeast,
|
|
|
- crowded_out_unstaking_period_length: None,
|
|
|
- review_period_expired_unstaking_period_length: None,
|
|
|
- }),
|
|
|
- ..OpeningPolicyCommitment::default()
|
|
|
- };
|
|
|
+ let stake_policy = Some(working_group::StakePolicy {
|
|
|
+ stake_amount: 100,
|
|
|
+ leaving_unstaking_period: 0,
|
|
|
+ });
|
|
|
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- Some(opening_policy_commitment),
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
+ let opening_id = add_opening(member_id, account_id, stake_policy, 1, working_group);
|
|
|
|
|
|
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(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
|
|
|
assert!(lead.is_none());
|
|
@@ -744,7 +574,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- None,
|
|
|
3,
|
|
|
working_group,
|
|
|
);
|
|
@@ -807,16 +636,12 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
<T as frame_system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
<T as minting::Trait>::MintId: From<u64>,
|
|
|
- <<T as minting::Trait>::Currency as traits::Currency<
|
|
|
- <T as frame_system::Trait>::AccountId,
|
|
|
- >>::Balance: From<u128>,
|
|
|
+ working_group::BalanceOf<T>: From<u128>,
|
|
|
{
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
|
|
|
- assert_eq!(WorkingGroupInstance::<T, I>::mint(), 0.into());
|
|
|
-
|
|
|
let mint_capacity = 999999;
|
|
|
set_mint_capacity::<T, I>(
|
|
|
member_id,
|
|
@@ -827,10 +652,10 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let mint_id = WorkingGroupInstance::<T, I>::mint();
|
|
|
- let mint = <minting::Module<T>>::mints(mint_id);
|
|
|
-
|
|
|
- assert_eq!(mint.capacity(), mint_capacity.into());
|
|
|
+ assert_eq!(
|
|
|
+ working_group::Module::<T, I>::budget(),
|
|
|
+ mint_capacity.into()
|
|
|
+ );
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -865,61 +690,38 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
<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 frame_system::Trait>::AccountId,
|
|
|
- >>::Balance: From<u128>,
|
|
|
+ working_group::BalanceOf<T>: From<u128>,
|
|
|
{
|
|
|
initial_test_ext().execute_with(|| {
|
|
|
let member_id: MemberId = 1;
|
|
|
let account_id: [u8; 32] = [member_id as u8; 32];
|
|
|
- let stake_amount = 100;
|
|
|
-
|
|
|
- let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
- role_staking_policy: Some(hiring::StakingPolicy {
|
|
|
- amount: 100,
|
|
|
- amount_mode: hiring::StakingAmountLimitMode::AtLeast,
|
|
|
- crowded_out_unstaking_period_length: None,
|
|
|
- review_period_expired_unstaking_period_length: None,
|
|
|
- }),
|
|
|
- ..OpeningPolicyCommitment::default()
|
|
|
- };
|
|
|
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- Some(opening_policy_commitment),
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
+ let stake_policy = Some(working_group::StakePolicy {
|
|
|
+ stake_amount: 100,
|
|
|
+ leaving_unstaking_period: 0,
|
|
|
+ });
|
|
|
+
|
|
|
+ let opening_id = add_opening(member_id, account_id, stake_policy, 1, working_group);
|
|
|
|
|
|
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(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
- let old_reward_amount = 100;
|
|
|
- let reward_policy = Some(RewardPolicy {
|
|
|
- amount_per_payout: old_reward_amount,
|
|
|
- next_payment_at_block: 9999,
|
|
|
- payout_interval: None,
|
|
|
- });
|
|
|
-
|
|
|
set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
@@ -927,20 +729,12 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- reward_policy,
|
|
|
4,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
let leader_worker_id = WorkingGroupInstance::<T, I>::current_lead().unwrap();
|
|
|
|
|
|
- let worker = WorkingGroupInstance::<T, I>::worker_by_id(leader_worker_id);
|
|
|
- let relationship_id = worker.reward_relationship.unwrap();
|
|
|
-
|
|
|
- let relationship =
|
|
|
- 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,
|
|
@@ -951,9 +745,9 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
- let relationship =
|
|
|
- recurring_rewards::RewardRelationships::<T>::get(relationship_id);
|
|
|
- assert_eq!(relationship.amount_per_payout, new_reward_amount.into());
|
|
|
+ let worker = WorkingGroupInstance::<T, I>::worker_by_id(leader_worker_id);
|
|
|
+
|
|
|
+ assert_eq!(worker.reward_per_block, Some(new_reward_amount.into()));
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -986,63 +780,41 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
) where
|
|
|
<T as frame_system::Trait>::AccountId: From<[u8; 32]>,
|
|
|
<T as membership::Trait>::MemberId: From<u64>,
|
|
|
+ working_group::MemberId<T>: 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 frame_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_u128;
|
|
|
|
|
|
- let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
- role_staking_policy: Some(hiring::StakingPolicy {
|
|
|
- amount: 100,
|
|
|
- amount_mode: hiring::StakingAmountLimitMode::AtLeast,
|
|
|
- crowded_out_unstaking_period_length: None,
|
|
|
- review_period_expired_unstaking_period_length: None,
|
|
|
- }),
|
|
|
- ..OpeningPolicyCommitment::default()
|
|
|
- };
|
|
|
+ let stake_policy = Some(working_group::StakePolicy {
|
|
|
+ stake_amount: 100,
|
|
|
+ leaving_unstaking_period: 0,
|
|
|
+ });
|
|
|
|
|
|
- let opening_id = add_opening(
|
|
|
- member_id.into(),
|
|
|
- account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- Some(opening_policy_commitment),
|
|
|
- 1,
|
|
|
- working_group,
|
|
|
- );
|
|
|
+ let opening_id = add_opening(member_id, account_id, stake_policy, 1, working_group);
|
|
|
|
|
|
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(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
- let old_reward_amount = 100;
|
|
|
- let reward_policy = Some(RewardPolicy {
|
|
|
- amount_per_payout: old_reward_amount,
|
|
|
- next_payment_at_block: 9999,
|
|
|
- payout_interval: None,
|
|
|
- });
|
|
|
-
|
|
|
set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
@@ -1050,7 +822,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- reward_policy,
|
|
|
4,
|
|
|
working_group,
|
|
|
);
|
|
@@ -1067,7 +838,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
member_id,
|
|
|
account_id,
|
|
|
leader_worker_id.into(),
|
|
|
- false,
|
|
|
5,
|
|
|
working_group,
|
|
|
);
|
|
@@ -1106,68 +876,44 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
<T as frame_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 frame_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_u128;
|
|
|
|
|
|
- let opening_policy_commitment = OpeningPolicyCommitment {
|
|
|
- role_staking_policy: Some(hiring::StakingPolicy {
|
|
|
- amount: 100,
|
|
|
- amount_mode: hiring::StakingAmountLimitMode::AtLeast,
|
|
|
- crowded_out_unstaking_period_length: None,
|
|
|
- review_period_expired_unstaking_period_length: None,
|
|
|
- }),
|
|
|
- ..OpeningPolicyCommitment::default()
|
|
|
+ let staking_policy = working_group::StakePolicy {
|
|
|
+ stake_amount: 100,
|
|
|
+ leaving_unstaking_period: 0,
|
|
|
};
|
|
|
|
|
|
let opening_id = add_opening(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
- Some(opening_policy_commitment),
|
|
|
+ Some(staking_policy),
|
|
|
1,
|
|
|
working_group,
|
|
|
);
|
|
|
|
|
|
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(),
|
|
|
+ working_group::ApplyOnOpeningParameters::<T> {
|
|
|
+ member_id: member_id.into(),
|
|
|
+ opening_id,
|
|
|
+ role_account_id: account_id.into(),
|
|
|
+ reward_account_id: account_id.into(),
|
|
|
+ description: Vec::new(),
|
|
|
+ stake_parameters: None,
|
|
|
+ },
|
|
|
);
|
|
|
|
|
|
assert_eq!(apply_result, Ok(()));
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(
|
|
|
- member_id,
|
|
|
- account_id,
|
|
|
- opening_id.into(),
|
|
|
- 2,
|
|
|
- working_group,
|
|
|
- );
|
|
|
-
|
|
|
let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
assert!(lead.is_none());
|
|
|
|
|
|
- let old_reward_amount = 100;
|
|
|
- let reward_policy = Some(RewardPolicy {
|
|
|
- amount_per_payout: old_reward_amount,
|
|
|
- next_payment_at_block: 9999,
|
|
|
- payout_interval: None,
|
|
|
- });
|
|
|
-
|
|
|
set_mint_capacity::<T, I>(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
@@ -1175,7 +921,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
- reward_policy,
|
|
|
4,
|
|
|
working_group,
|
|
|
);
|
|
@@ -1192,7 +937,6 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
member_id,
|
|
|
account_id,
|
|
|
leader_worker_id.into(),
|
|
|
- true,
|
|
|
5,
|
|
|
working_group,
|
|
|
);
|