|
@@ -9,27 +9,46 @@ use working_group::{OpeningPolicyCommitment, RewardPolicy};
|
|
|
|
|
|
use crate::{
|
|
use crate::{
|
|
Balance, BlockNumber, ContentDirectoryWorkingGroup, ContentDirectoryWorkingGroupInstance,
|
|
Balance, BlockNumber, ContentDirectoryWorkingGroup, ContentDirectoryWorkingGroupInstance,
|
|
|
|
+ StorageWorkingGroup, StorageWorkingGroupInstance,
|
|
};
|
|
};
|
|
use sp_std::collections::btree_set::BTreeSet;
|
|
use sp_std::collections::btree_set::BTreeSet;
|
|
|
|
|
|
|
|
+use strum::IntoEnumIterator;
|
|
|
|
+use crate::primitives::{AccountId, ActorId, MemberId};
|
|
|
|
+
|
|
|
|
+type WorkingGroupInstance<T, I> = working_group::Module<T, I>;
|
|
|
|
+
|
|
type Hiring = hiring::Module<Runtime>;
|
|
type Hiring = hiring::Module<Runtime>;
|
|
|
|
|
|
fn add_opening(
|
|
fn add_opening(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
activate_at: hiring::ActivateOpeningAt<BlockNumber>,
|
|
activate_at: hiring::ActivateOpeningAt<BlockNumber>,
|
|
opening_policy_commitment: Option<OpeningPolicyCommitment<BlockNumber, u128>>,
|
|
opening_policy_commitment: Option<OpeningPolicyCommitment<BlockNumber, u128>>,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) -> u64 {
|
|
) -> u64 {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
|
|
|
|
- let opening_id = ContentDirectoryWorkingGroup::next_opening_id();
|
|
|
|
-
|
|
|
|
- assert!(!<working_group::OpeningById<
|
|
|
|
- Runtime,
|
|
|
|
- ContentDirectoryWorkingGroupInstance,
|
|
|
|
- >>::contains_key(opening_id));
|
|
|
|
|
|
+ let opening_id = match working_group {
|
|
|
|
+ WorkingGroup::Content => {
|
|
|
|
+ let opening_id = ContentDirectoryWorkingGroup::next_opening_id();
|
|
|
|
+ assert!(!<working_group::OpeningById<
|
|
|
|
+ Runtime,
|
|
|
|
+ ContentDirectoryWorkingGroupInstance,
|
|
|
|
+ >>::contains_key(opening_id));
|
|
|
|
+ opening_id
|
|
|
|
+ }
|
|
|
|
+ WorkingGroup::Storage => {
|
|
|
|
+ let opening_id = StorageWorkingGroup::next_opening_id();
|
|
|
|
+ assert!(!<working_group::OpeningById<
|
|
|
|
+ Runtime,
|
|
|
|
+ StorageWorkingGroupInstance,
|
|
|
|
+ >>::contains_key(opening_id));
|
|
|
|
+ opening_id
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
ProposalCodex::create_add_working_group_leader_opening_proposal(
|
|
ProposalCodex::create_add_working_group_leader_opening_proposal(
|
|
@@ -44,7 +63,7 @@ fn add_opening(
|
|
.clone()
|
|
.clone()
|
|
.unwrap_or(OpeningPolicyCommitment::default()),
|
|
.unwrap_or(OpeningPolicyCommitment::default()),
|
|
human_readable_text: Vec::new(),
|
|
human_readable_text: Vec::new(),
|
|
- working_group: WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
},
|
|
},
|
|
)
|
|
)
|
|
})
|
|
})
|
|
@@ -57,10 +76,11 @@ fn add_opening(
|
|
}
|
|
}
|
|
|
|
|
|
fn begin_review_applications(
|
|
fn begin_review_applications(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
opening_id: u64,
|
|
opening_id: u64,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -68,12 +88,12 @@ fn begin_review_applications(
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
ProposalCodex::create_begin_review_working_group_leader_applications_proposal(
|
|
ProposalCodex::create_begin_review_working_group_leader_applications_proposal(
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
- member_id as u64,
|
|
|
|
|
|
+ member_id,
|
|
b"title".to_vec(),
|
|
b"title".to_vec(),
|
|
b"body".to_vec(),
|
|
b"body".to_vec(),
|
|
Some(<BalanceOf<Runtime>>::from(25_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(25_000_u32)),
|
|
opening_id,
|
|
opening_id,
|
|
- WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
)
|
|
)
|
|
})
|
|
})
|
|
.disable_setup_enviroment()
|
|
.disable_setup_enviroment()
|
|
@@ -84,12 +104,13 @@ fn begin_review_applications(
|
|
}
|
|
}
|
|
|
|
|
|
fn fill_opening(
|
|
fn fill_opening(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
opening_id: u64,
|
|
opening_id: u64,
|
|
successful_application_id: u64,
|
|
successful_application_id: u64,
|
|
reward_policy: Option<RewardPolicy<Balance, BlockNumber>>,
|
|
reward_policy: Option<RewardPolicy<Balance, BlockNumber>>,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -97,7 +118,7 @@ fn fill_opening(
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
ProposalCodex::create_fill_working_group_leader_opening_proposal(
|
|
ProposalCodex::create_fill_working_group_leader_opening_proposal(
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
- member_id as u64,
|
|
|
|
|
|
+ member_id,
|
|
b"title".to_vec(),
|
|
b"title".to_vec(),
|
|
b"body".to_vec(),
|
|
b"body".to_vec(),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
@@ -105,7 +126,7 @@ fn fill_opening(
|
|
opening_id,
|
|
opening_id,
|
|
successful_application_id,
|
|
successful_application_id,
|
|
reward_policy: reward_policy.clone(),
|
|
reward_policy: reward_policy.clone(),
|
|
- working_group: WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
},
|
|
},
|
|
)
|
|
)
|
|
})
|
|
})
|
|
@@ -130,6 +151,7 @@ fn decrease_stake(
|
|
leader_worker_id: u64,
|
|
leader_worker_id: u64,
|
|
stake_amount: Balance,
|
|
stake_amount: Balance,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -143,7 +165,7 @@ fn decrease_stake(
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
leader_worker_id,
|
|
leader_worker_id,
|
|
stake_amount,
|
|
stake_amount,
|
|
- WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
)
|
|
)
|
|
})
|
|
})
|
|
.disable_setup_enviroment()
|
|
.disable_setup_enviroment()
|
|
@@ -154,11 +176,12 @@ fn decrease_stake(
|
|
}
|
|
}
|
|
|
|
|
|
fn slash_stake(
|
|
fn slash_stake(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: u64,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
- leader_worker_id: u64,
|
|
|
|
|
|
+ leader_worker_id: ActorId,
|
|
stake_amount: Balance,
|
|
stake_amount: Balance,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -166,13 +189,13 @@ fn slash_stake(
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
ProposalCodex::create_slash_working_group_leader_stake_proposal(
|
|
ProposalCodex::create_slash_working_group_leader_stake_proposal(
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
- member_id as u64,
|
|
|
|
|
|
+ member_id,
|
|
b"title".to_vec(),
|
|
b"title".to_vec(),
|
|
b"body".to_vec(),
|
|
b"body".to_vec(),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
leader_worker_id,
|
|
leader_worker_id,
|
|
stake_amount,
|
|
stake_amount,
|
|
- WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
)
|
|
)
|
|
})
|
|
})
|
|
.disable_setup_enviroment()
|
|
.disable_setup_enviroment()
|
|
@@ -183,11 +206,12 @@ fn slash_stake(
|
|
}
|
|
}
|
|
|
|
|
|
fn set_reward(
|
|
fn set_reward(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
leader_worker_id: u64,
|
|
leader_worker_id: u64,
|
|
reward_amount: Balance,
|
|
reward_amount: Balance,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -201,7 +225,7 @@ fn set_reward(
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
leader_worker_id,
|
|
leader_worker_id,
|
|
reward_amount,
|
|
reward_amount,
|
|
- WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
)
|
|
)
|
|
})
|
|
})
|
|
.disable_setup_enviroment()
|
|
.disable_setup_enviroment()
|
|
@@ -212,11 +236,12 @@ fn set_reward(
|
|
}
|
|
}
|
|
|
|
|
|
fn set_mint_capacity(
|
|
fn set_mint_capacity(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
mint_capacity: Balance,
|
|
mint_capacity: Balance,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
setup_environment: bool,
|
|
setup_environment: bool,
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -235,7 +260,7 @@ fn set_mint_capacity(
|
|
b"body".to_vec(),
|
|
b"body".to_vec(),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(50_000_u32)),
|
|
mint_capacity,
|
|
mint_capacity,
|
|
- WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
)
|
|
)
|
|
})
|
|
})
|
|
.with_setup_enviroment(setup_environment)
|
|
.with_setup_enviroment(setup_environment)
|
|
@@ -246,11 +271,12 @@ fn set_mint_capacity(
|
|
}
|
|
}
|
|
|
|
|
|
fn terminate_role(
|
|
fn terminate_role(
|
|
- member_id: u8,
|
|
|
|
|
|
+ member_id: MemberId,
|
|
account_id: [u8; 32],
|
|
account_id: [u8; 32],
|
|
leader_worker_id: u64,
|
|
leader_worker_id: u64,
|
|
slash: bool,
|
|
slash: bool,
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
sequence_number: u32, // action sequence number to align with other actions
|
|
|
|
+ working_group: WorkingGroup,
|
|
) {
|
|
) {
|
|
let expected_proposal_id = sequence_number;
|
|
let expected_proposal_id = sequence_number;
|
|
let run_to_block = sequence_number * 2;
|
|
let run_to_block = sequence_number * 2;
|
|
@@ -258,7 +284,7 @@ fn terminate_role(
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
ProposalCodex::create_terminate_working_group_leader_role_proposal(
|
|
ProposalCodex::create_terminate_working_group_leader_role_proposal(
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
- member_id as u64,
|
|
|
|
|
|
+ member_id,
|
|
b"title".to_vec(),
|
|
b"title".to_vec(),
|
|
b"body".to_vec(),
|
|
b"body".to_vec(),
|
|
Some(<BalanceOf<Runtime>>::from(100_000_u32)),
|
|
Some(<BalanceOf<Runtime>>::from(100_000_u32)),
|
|
@@ -266,7 +292,7 @@ fn terminate_role(
|
|
worker_id: leader_worker_id,
|
|
worker_id: leader_worker_id,
|
|
rationale: Vec::new(),
|
|
rationale: Vec::new(),
|
|
slash,
|
|
slash,
|
|
- working_group: WorkingGroup::Content,
|
|
|
|
|
|
+ working_group,
|
|
},
|
|
},
|
|
)
|
|
)
|
|
})
|
|
})
|
|
@@ -279,9 +305,18 @@ fn terminate_role(
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
|
|
fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
+ // This uses strum crate for enum iteration
|
|
|
|
+ for group in WorkingGroup::iter() {
|
|
|
|
+ run_create_add_working_group_leader_opening_proposal_execution_succeeds(group);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_add_working_group_leader_opening_proposal_execution_succeeds(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
|
|
|
|
let next_opening_id = ContentDirectoryWorkingGroup::next_opening_id();
|
|
let next_opening_id = ContentDirectoryWorkingGroup::next_opening_id();
|
|
|
|
|
|
@@ -296,6 +331,7 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
None,
|
|
None,
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
// Check for expected opening id.
|
|
// Check for expected opening id.
|
|
@@ -311,9 +347,20 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_begin_review_working_group_leader_applications_proposal_execution_succeeds() {
|
|
fn create_begin_review_working_group_leader_applications_proposal_execution_succeeds() {
|
|
|
|
+ // This uses strum crate for enum iteration
|
|
|
|
+ for group in WorkingGroup::iter() {
|
|
|
|
+ run_create_begin_review_working_group_leader_applications_proposal_execution_succeeds(
|
|
|
|
+ group,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_begin_review_working_group_leader_applications_proposal_execution_succeeds(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
|
|
|
|
let opening_id = add_opening(
|
|
let opening_id = add_opening(
|
|
member_id,
|
|
member_id,
|
|
@@ -321,6 +368,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
None,
|
|
None,
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let opening = ContentDirectoryWorkingGroup::opening_by_id(opening_id);
|
|
let opening = ContentDirectoryWorkingGroup::opening_by_id(opening_id);
|
|
@@ -339,7 +387,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
let hiring_opening = Hiring::opening_by_id(opening.hiring_opening_id);
|
|
let hiring_opening = Hiring::opening_by_id(opening.hiring_opening_id);
|
|
assert_eq!(
|
|
assert_eq!(
|
|
@@ -360,9 +408,18 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
+ // This uses strum crate for enum iteration
|
|
|
|
+ for group in WorkingGroup::iter() {
|
|
|
|
+ run_create_fill_working_group_leader_opening_proposal_execution_succeeds(group);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_fill_working_group_leader_opening_proposal_execution_succeeds(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
|
|
|
|
let opening_id = add_opening(
|
|
let opening_id = add_opening(
|
|
member_id,
|
|
member_id,
|
|
@@ -370,6 +427,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
None,
|
|
None,
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
@@ -386,7 +444,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
assert!(lead.is_none());
|
|
assert!(lead.is_none());
|
|
@@ -398,6 +456,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
expected_application_id,
|
|
expected_application_id,
|
|
None,
|
|
None,
|
|
3,
|
|
3,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
@@ -405,92 +464,127 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-#[test]
|
|
|
|
-fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
- initial_test_ext().execute_with(|| {
|
|
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 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.clone(),
|
|
|
|
- ActivateOpeningAt::CurrentBlock,
|
|
|
|
- Some(opening_policy_commitment),
|
|
|
|
- 1,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- 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),
|
|
|
|
- None,
|
|
|
|
- Vec::new(),
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- assert_eq!(apply_result, Ok(()));
|
|
|
|
-
|
|
|
|
- let expected_application_id = 0;
|
|
|
|
-
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
-
|
|
|
|
- let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
|
- assert!(lead.is_none());
|
|
|
|
-
|
|
|
|
- fill_opening(
|
|
|
|
- member_id,
|
|
|
|
- account_id,
|
|
|
|
- opening_id,
|
|
|
|
- expected_application_id,
|
|
|
|
- None,
|
|
|
|
- 3,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
-
|
|
|
|
- let stake_id = 1;
|
|
|
|
- let old_balance = Balances::free_balance(&account_id.into());
|
|
|
|
- let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
-
|
|
|
|
- assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
-
|
|
|
|
- let decreasing_stake_amount = 30;
|
|
|
|
- decrease_stake(
|
|
|
|
- member_id,
|
|
|
|
- account_id,
|
|
|
|
- leader_worker_id,
|
|
|
|
- decreasing_stake_amount,
|
|
|
|
- 4,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- let new_balance = Balances::free_balance(&account_id.into());
|
|
|
|
- let new_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
-
|
|
|
|
- assert_eq!(
|
|
|
|
- get_stake_balance(new_stake),
|
|
|
|
- stake_amount - decreasing_stake_amount
|
|
|
|
- );
|
|
|
|
- assert_eq!(new_balance, old_balance + decreasing_stake_amount);
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
|
|
+// #[test]
|
|
|
|
+// fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
+// // This uses strum crate for enum iteration
|
|
|
|
+// for group in WorkingGroup::iter() {
|
|
|
|
+// run_create_decrease_group_leader_stake_proposal_execution_succeeds(group);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// fn run_create_decrease_group_leader_stake_proposal_execution_succeeds(working_group: WorkingGroup) {
|
|
|
|
+// initial_test_ext().execute_with(|| {
|
|
|
|
+// let member_id: MemberId = 1;
|
|
|
|
+// let account_id: AccountId = AccountId::default();
|
|
|
|
+// 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 opening_id = add_opening(
|
|
|
|
+// member_id,
|
|
|
|
+// account_id.clone(),
|
|
|
|
+// 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),
|
|
|
|
+// None,
|
|
|
|
+// Vec::new(),
|
|
|
|
+// );
|
|
|
|
+
|
|
|
|
+// assert_eq!(apply_result, Ok(()));
|
|
|
|
+
|
|
|
|
+// let expected_application_id = 0;
|
|
|
|
+
|
|
|
|
+// begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
+
|
|
|
|
+// let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
|
+// assert!(lead.is_none());
|
|
|
|
+
|
|
|
|
+// fill_opening(
|
|
|
|
+// member_id,
|
|
|
|
+// account_id,
|
|
|
|
+// opening_id,
|
|
|
|
+// expected_application_id,
|
|
|
|
+// None,
|
|
|
|
+// 3,
|
|
|
|
+// working_group,
|
|
|
|
+// );
|
|
|
|
+
|
|
|
|
+// let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
+
|
|
|
|
+// let stake_id = 1;
|
|
|
|
+// let old_balance = Balances::free_balance(&account_id.into());
|
|
|
|
+// let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
+
|
|
|
|
+// assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
+
|
|
|
|
+// let decreasing_stake_amount = 30;
|
|
|
|
+// decrease_stake(
|
|
|
|
+// member_id,
|
|
|
|
+// account_id,
|
|
|
|
+// leader_worker_id,
|
|
|
|
+// decreasing_stake_amount,
|
|
|
|
+// 4,
|
|
|
|
+// working_group,
|
|
|
|
+// );
|
|
|
|
+
|
|
|
|
+// let new_balance = Balances::free_balance(&account_id.into());
|
|
|
|
+// let new_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
+
|
|
|
|
+// assert_eq!(
|
|
|
|
+// get_stake_balance(new_stake),
|
|
|
|
+// stake_amount - decreasing_stake_amount
|
|
|
|
+// );
|
|
|
|
+// assert_eq!(new_balance, old_balance + decreasing_stake_amount);
|
|
|
|
+// });
|
|
|
|
+// }
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
+ // This uses strum crate for enum iteration
|
|
|
|
+ for group in WorkingGroup::iter() {
|
|
|
|
+ match group {
|
|
|
|
+ WorkingGroup::Content => {
|
|
|
|
+ run_create_slash_group_leader_stake_proposal_execution_succeeds::<
|
|
|
|
+ Runtime,
|
|
|
|
+ ContentDirectoryWorkingGroupInstance,
|
|
|
|
+ >(group)
|
|
|
|
+ }
|
|
|
|
+ WorkingGroup::Storage => {
|
|
|
|
+ run_create_slash_group_leader_stake_proposal_execution_succeeds::<
|
|
|
|
+ Runtime,
|
|
|
|
+ StorageWorkingGroupInstance,
|
|
|
|
+ >(group)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_slash_group_leader_stake_proposal_execution_succeeds<
|
|
|
|
+ T: working_group::Trait<I> + system::Trait + stake::Trait,
|
|
|
|
+ I: working_group::Instance,
|
|
|
|
+>(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
let stake_amount = 100;
|
|
let stake_amount = 100;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
@@ -509,14 +603,15 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
Some(opening_policy_commitment),
|
|
Some(opening_policy_commitment),
|
|
1,
|
|
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(T::AccountId::default()).into(),
|
|
|
|
+ member_id.into(),
|
|
|
|
+ opening_id.into(),
|
|
|
|
+ T::AccountId::default(),
|
|
|
|
+ Some(stake_amount.into()),
|
|
None,
|
|
None,
|
|
Vec::new(),
|
|
Vec::new(),
|
|
);
|
|
);
|
|
@@ -525,9 +620,10 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
+
|
|
|
|
+ let lead = WorkingGroupInstance::<T, I>::current_lead();
|
|
|
|
|
|
- let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
|
|
assert!(lead.is_none());
|
|
assert!(lead.is_none());
|
|
|
|
|
|
fill_opening(
|
|
fill_opening(
|
|
@@ -537,23 +633,25 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
expected_application_id,
|
|
expected_application_id,
|
|
None,
|
|
None,
|
|
3,
|
|
3,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
|
|
+ let leader_worker_id = WorkingGroupInstance::<T, I>::current_lead().unwrap();
|
|
|
|
|
|
let stake_id = 1;
|
|
let stake_id = 1;
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
|
|
- assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
|
|
+ assert_eq!(get_stake_balance(old_stake), stake_amount as Balance);
|
|
|
|
|
|
let slashing_stake_amount = 30;
|
|
let slashing_stake_amount = 30;
|
|
slash_stake(
|
|
slash_stake(
|
|
member_id,
|
|
member_id,
|
|
account_id,
|
|
account_id,
|
|
- leader_worker_id,
|
|
|
|
|
|
+ leader_worker_id.into(),
|
|
slashing_stake_amount,
|
|
slashing_stake_amount,
|
|
4,
|
|
4,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let new_balance = Balances::free_balance(&account_id.into());
|
|
let new_balance = Balances::free_balance(&account_id.into());
|
|
@@ -561,7 +659,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
|
|
assert_eq!(
|
|
assert_eq!(
|
|
get_stake_balance(new_stake),
|
|
get_stake_balance(new_stake),
|
|
- stake_amount - slashing_stake_amount
|
|
|
|
|
|
+ stake_amount as u128 - slashing_stake_amount
|
|
);
|
|
);
|
|
assert_eq!(new_balance, old_balance);
|
|
assert_eq!(new_balance, old_balance);
|
|
});
|
|
});
|
|
@@ -569,14 +667,23 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_set_working_group_mint_capacity_proposal_execution_succeeds() {
|
|
fn create_set_working_group_mint_capacity_proposal_execution_succeeds() {
|
|
|
|
+ // This uses strum crate for enum iteration
|
|
|
|
+ for group in WorkingGroup::iter() {
|
|
|
|
+ run_create_set_working_group_mint_capacity_proposal_execution_succeeds(group);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_set_working_group_mint_capacity_proposal_execution_succeeds(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
|
|
|
|
assert_eq!(ContentDirectoryWorkingGroup::mint(), 0);
|
|
assert_eq!(ContentDirectoryWorkingGroup::mint(), 0);
|
|
|
|
|
|
let mint_capacity = 999999;
|
|
let mint_capacity = 999999;
|
|
- set_mint_capacity(member_id, account_id, mint_capacity, 1, true);
|
|
|
|
|
|
+ set_mint_capacity(member_id, account_id, mint_capacity, 1, true, working_group);
|
|
|
|
|
|
let mint_id = ContentDirectoryWorkingGroup::mint();
|
|
let mint_id = ContentDirectoryWorkingGroup::mint();
|
|
let mint = <minting::Module<Runtime>>::mints(mint_id);
|
|
let mint = <minting::Module<Runtime>>::mints(mint_id);
|
|
@@ -587,9 +694,16 @@ fn create_set_working_group_mint_capacity_proposal_execution_succeeds() {
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_set_group_leader_reward_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);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_set_group_leader_reward_proposal_execution_succeeds(working_group: WorkingGroup) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
let stake_amount = 100;
|
|
let stake_amount = 100;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
@@ -608,6 +722,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
Some(opening_policy_commitment),
|
|
Some(opening_policy_commitment),
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
@@ -624,7 +739,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
assert!(lead.is_none());
|
|
assert!(lead.is_none());
|
|
@@ -636,7 +751,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
payout_interval: None,
|
|
payout_interval: None,
|
|
});
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false);
|
|
|
|
|
|
+ set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
fill_opening(
|
|
member_id,
|
|
member_id,
|
|
@@ -645,6 +760,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
expected_application_id,
|
|
expected_application_id,
|
|
reward_policy,
|
|
reward_policy,
|
|
4,
|
|
4,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
@@ -662,6 +778,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
leader_worker_id,
|
|
leader_worker_id,
|
|
new_reward_amount,
|
|
new_reward_amount,
|
|
5,
|
|
5,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let relationship = recurring_rewards::RewardRelationships::<Runtime>::get(relationship_id);
|
|
let relationship = recurring_rewards::RewardRelationships::<Runtime>::get(relationship_id);
|
|
@@ -671,9 +788,16 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_terminate_group_leader_role_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);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_terminate_group_leader_role_proposal_execution_succeeds(working_group: WorkingGroup) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
let stake_amount = 100;
|
|
let stake_amount = 100;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
@@ -692,6 +816,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
Some(opening_policy_commitment),
|
|
Some(opening_policy_commitment),
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
@@ -708,7 +833,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
assert!(lead.is_none());
|
|
assert!(lead.is_none());
|
|
@@ -720,7 +845,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
payout_interval: None,
|
|
payout_interval: None,
|
|
});
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false);
|
|
|
|
|
|
+ set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
fill_opening(
|
|
member_id,
|
|
member_id,
|
|
@@ -729,17 +854,25 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
expected_application_id,
|
|
expected_application_id,
|
|
reward_policy,
|
|
reward_policy,
|
|
4,
|
|
4,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
-
|
|
|
|
let stake_id = 1;
|
|
let stake_id = 1;
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
|
|
- terminate_role(member_id, account_id, leader_worker_id, false, 5);
|
|
|
|
|
|
+ let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
+
|
|
|
|
+ terminate_role(
|
|
|
|
+ member_id,
|
|
|
|
+ account_id,
|
|
|
|
+ leader_worker_id,
|
|
|
|
+ false,
|
|
|
|
+ 5,
|
|
|
|
+ working_group,
|
|
|
|
+ );
|
|
|
|
|
|
assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
|
|
|
|
@@ -753,9 +886,18 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn create_terminate_group_leader_role_proposal_with_slashing_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);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+fn run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
|
|
+ working_group: WorkingGroup,
|
|
|
|
+) {
|
|
initial_test_ext().execute_with(|| {
|
|
initial_test_ext().execute_with(|| {
|
|
- let member_id = 1;
|
|
|
|
- let account_id: [u8; 32] = [member_id; 32];
|
|
|
|
|
|
+ let member_id: MemberId = 1;
|
|
|
|
+ let account_id: [u8; 32] = [0; 32];
|
|
let stake_amount = 100;
|
|
let stake_amount = 100;
|
|
|
|
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
let opening_policy_commitment = OpeningPolicyCommitment {
|
|
@@ -774,11 +916,12 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
ActivateOpeningAt::CurrentBlock,
|
|
ActivateOpeningAt::CurrentBlock,
|
|
Some(opening_policy_commitment),
|
|
Some(opening_policy_commitment),
|
|
1,
|
|
1,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
let apply_result = ContentDirectoryWorkingGroup::apply_on_opening(
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
- member_id as u64,
|
|
|
|
|
|
+ member_id,
|
|
opening_id,
|
|
opening_id,
|
|
account_id.clone().into(),
|
|
account_id.clone().into(),
|
|
Some(stake_amount),
|
|
Some(stake_amount),
|
|
@@ -790,7 +933,7 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
|
|
|
|
let expected_application_id = 0;
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2, working_group);
|
|
|
|
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
let lead = ContentDirectoryWorkingGroup::current_lead();
|
|
assert!(lead.is_none());
|
|
assert!(lead.is_none());
|
|
@@ -802,7 +945,7 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
payout_interval: None,
|
|
payout_interval: None,
|
|
});
|
|
});
|
|
|
|
|
|
- set_mint_capacity(member_id, account_id, 999999, 3, false);
|
|
|
|
|
|
+ set_mint_capacity(member_id, account_id, 999999, 3, false, working_group);
|
|
|
|
|
|
fill_opening(
|
|
fill_opening(
|
|
member_id,
|
|
member_id,
|
|
@@ -811,17 +954,25 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
|
|
expected_application_id,
|
|
expected_application_id,
|
|
reward_policy,
|
|
reward_policy,
|
|
4,
|
|
4,
|
|
|
|
+ working_group,
|
|
);
|
|
);
|
|
|
|
|
|
- let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
-
|
|
|
|
let stake_id = 1;
|
|
let stake_id = 1;
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_balance = Balances::free_balance(&account_id.into());
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
let old_stake = <stake::Module<Runtime>>::stakes(stake_id);
|
|
|
|
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
assert_eq!(get_stake_balance(old_stake), stake_amount);
|
|
|
|
|
|
- terminate_role(member_id, account_id, leader_worker_id, true, 5);
|
|
|
|
|
|
+ let leader_worker_id = ContentDirectoryWorkingGroup::current_lead().unwrap();
|
|
|
|
+
|
|
|
|
+ terminate_role(
|
|
|
|
+ member_id,
|
|
|
|
+ account_id,
|
|
|
|
+ leader_worker_id,
|
|
|
|
+ true,
|
|
|
|
+ 5,
|
|
|
|
+ working_group,
|
|
|
|
+ );
|
|
|
|
|
|
assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
assert!(ContentDirectoryWorkingGroup::current_lead().is_none());
|
|
|
|
|