|
@@ -20,7 +20,11 @@ fn add_opening(
|
|
|
account_id: [u8; 32],
|
|
|
activate_at: hiring::ActivateOpeningAt<BlockNumber>,
|
|
|
opening_policy_commitment: Option<OpeningPolicyCommitment<BlockNumber, u128>>,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
) -> u64 {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
let opening_id = StorageWorkingGroup::next_opening_id();
|
|
|
|
|
|
assert!(!<working_group::OpeningById<
|
|
@@ -44,14 +48,24 @@ fn add_opening(
|
|
|
working_group: WorkingGroup::Storage,
|
|
|
},
|
|
|
)
|
|
|
- });
|
|
|
+ })
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
|
|
|
opening_id
|
|
|
}
|
|
|
|
|
|
-fn begin_review_applications(member_id: u8, account_id: [u8; 32], opening_id: u64) {
|
|
|
+fn begin_review_applications(
|
|
|
+ member_id: u8,
|
|
|
+ account_id: [u8; 32],
|
|
|
+ opening_id: u64,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
+) {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
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(),
|
|
@@ -64,8 +78,8 @@ fn begin_review_applications(member_id: u8, account_id: [u8; 32], opening_id: u6
|
|
|
)
|
|
|
})
|
|
|
.disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(2)
|
|
|
- .with_run_to_block(3);
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
@@ -76,15 +90,10 @@ fn fill_opening(
|
|
|
opening_id: u64,
|
|
|
successful_application_id: u64,
|
|
|
reward_policy: Option<RewardPolicy<Balance, BlockNumber>>,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
) {
|
|
|
- let mut expected_proposal_id = 3;
|
|
|
- let mut run_to_block = 4;
|
|
|
- if reward_policy.is_some() {
|
|
|
- set_mint_capacity(member_id, account_id, 999999);
|
|
|
-
|
|
|
- expected_proposal_id = 4;
|
|
|
- run_to_block = 5;
|
|
|
- }
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_fill_working_group_leader_opening_proposal(
|
|
@@ -121,7 +130,11 @@ fn decrease_stake(
|
|
|
account_id: [u8; 32],
|
|
|
leader_worker_id: u64,
|
|
|
stake_amount: Balance,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
) {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_decrease_working_group_leader_stake_proposal(
|
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
@@ -135,13 +148,22 @@ fn decrease_stake(
|
|
|
)
|
|
|
})
|
|
|
.disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(4)
|
|
|
- .with_run_to_block(5);
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
|
|
|
|
-fn slash_stake(member_id: u8, account_id: [u8; 32], leader_worker_id: u64, stake_amount: Balance) {
|
|
|
+fn slash_stake(
|
|
|
+ member_id: u8,
|
|
|
+ account_id: [u8; 32],
|
|
|
+ leader_worker_id: u64,
|
|
|
+ stake_amount: Balance,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
+) {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_slash_working_group_leader_stake_proposal(
|
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
@@ -155,13 +177,22 @@ fn slash_stake(member_id: u8, account_id: [u8; 32], leader_worker_id: u64, stake
|
|
|
)
|
|
|
})
|
|
|
.disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(4)
|
|
|
- .with_run_to_block(5);
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
|
|
|
|
-fn set_reward(member_id: u8, account_id: [u8; 32], leader_worker_id: u64, reward_amount: Balance) {
|
|
|
+fn set_reward(
|
|
|
+ member_id: u8,
|
|
|
+ account_id: [u8; 32],
|
|
|
+ leader_worker_id: u64,
|
|
|
+ reward_amount: Balance,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
+) {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
let codex_extrinsic_test_fixture = CodexProposalTestFixture::default_for_call(|| {
|
|
|
ProposalCodex::create_set_working_group_leader_reward_proposal(
|
|
|
RawOrigin::Signed(account_id.clone().into()).into(),
|
|
@@ -175,13 +206,21 @@ fn set_reward(member_id: u8, account_id: [u8; 32], leader_worker_id: u64, reward
|
|
|
)
|
|
|
})
|
|
|
.disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(5)
|
|
|
- .with_run_to_block(6);
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
|
|
|
|
-fn set_mint_capacity(member_id: u8, account_id: [u8; 32], mint_capacity: Balance) {
|
|
|
+fn set_mint_capacity(
|
|
|
+ member_id: u8,
|
|
|
+ account_id: [u8; 32],
|
|
|
+ mint_capacity: Balance,
|
|
|
+ sequence_number: u32, // action sequence number to align with other actions
|
|
|
+) {
|
|
|
+ let expected_proposal_id = sequence_number;
|
|
|
+ let run_to_block = sequence_number + 1;
|
|
|
+
|
|
|
let mint_id_result = <minting::Module<Runtime>>::add_mint(0, None);
|
|
|
|
|
|
if let Ok(mint_id) = mint_id_result {
|
|
@@ -200,8 +239,8 @@ fn set_mint_capacity(member_id: u8, account_id: [u8; 32], mint_capacity: Balance
|
|
|
)
|
|
|
})
|
|
|
.disable_setup_enviroment()
|
|
|
- .with_expected_proposal_id(3)
|
|
|
- .with_run_to_block(4);
|
|
|
+ .with_expected_proposal_id(expected_proposal_id)
|
|
|
+ .with_run_to_block(run_to_block);
|
|
|
|
|
|
codex_extrinsic_test_fixture.call_extrinsic_and_assert();
|
|
|
}
|
|
@@ -219,7 +258,13 @@ fn create_add_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
StorageWorkingGroupInstance,
|
|
|
>>::exists(next_opening_id));
|
|
|
|
|
|
- let opening_id = add_opening(member_id, account_id, ActivateOpeningAt::CurrentBlock, None);
|
|
|
+ let opening_id = add_opening(
|
|
|
+ member_id,
|
|
|
+ account_id,
|
|
|
+ ActivateOpeningAt::CurrentBlock,
|
|
|
+ None,
|
|
|
+ 1,
|
|
|
+ );
|
|
|
|
|
|
// Check for expected opening id.
|
|
|
assert_eq!(opening_id, next_opening_id);
|
|
@@ -243,6 +288,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ
|
|
|
account_id.clone(),
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
None,
|
|
|
+ 1,
|
|
|
);
|
|
|
|
|
|
let opening = StorageWorkingGroup::opening_by_id(opening_id);
|
|
@@ -261,7 +307,7 @@ fn create_begin_review_working_group_leader_applications_proposal_execution_succ
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id);
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
let hiring_opening = Hiring::opening_by_id(opening.hiring_opening_id);
|
|
|
assert_eq!(
|
|
@@ -291,6 +337,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
account_id.clone(),
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
None,
|
|
|
+ 1,
|
|
|
);
|
|
|
|
|
|
let apply_result = StorageWorkingGroup::apply_on_opening(
|
|
@@ -307,7 +354,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id);
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
let lead = StorageWorkingGroup::current_lead();
|
|
|
assert!(lead.is_none());
|
|
@@ -318,6 +365,7 @@ fn create_fill_working_group_leader_opening_proposal_execution_succeeds() {
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
None,
|
|
|
+ 3,
|
|
|
);
|
|
|
|
|
|
let lead = StorageWorkingGroup::current_lead();
|
|
@@ -347,6 +395,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
account_id.clone(),
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
+ 1,
|
|
|
);
|
|
|
|
|
|
let apply_result = StorageWorkingGroup::apply_on_opening(
|
|
@@ -363,7 +412,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id);
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
let lead = StorageWorkingGroup::current_lead();
|
|
|
assert!(lead.is_none());
|
|
@@ -374,6 +423,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
None,
|
|
|
+ 3,
|
|
|
);
|
|
|
|
|
|
let leader_worker_id = StorageWorkingGroup::current_lead().unwrap();
|
|
@@ -390,6 +440,7 @@ fn create_decrease_group_leader_stake_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
leader_worker_id,
|
|
|
decreasing_stake_amount,
|
|
|
+ 4,
|
|
|
);
|
|
|
|
|
|
let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into());
|
|
@@ -425,6 +476,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
account_id.clone(),
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
+ 1,
|
|
|
);
|
|
|
|
|
|
let apply_result = StorageWorkingGroup::apply_on_opening(
|
|
@@ -441,7 +493,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id);
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
let lead = StorageWorkingGroup::current_lead();
|
|
|
assert!(lead.is_none());
|
|
@@ -452,6 +504,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
None,
|
|
|
+ 3,
|
|
|
);
|
|
|
|
|
|
let leader_worker_id = StorageWorkingGroup::current_lead().unwrap();
|
|
@@ -468,6 +521,7 @@ fn create_slash_group_leader_stake_proposal_execution_succeeds() {
|
|
|
account_id,
|
|
|
leader_worker_id,
|
|
|
slashing_stake_amount,
|
|
|
+ 4,
|
|
|
);
|
|
|
|
|
|
let new_balance = Balances::free_balance::<&AccountId32>(&account_id.into());
|
|
@@ -503,6 +557,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
account_id.clone(),
|
|
|
ActivateOpeningAt::CurrentBlock,
|
|
|
Some(opening_policy_commitment),
|
|
|
+ 1,
|
|
|
);
|
|
|
|
|
|
let apply_result = StorageWorkingGroup::apply_on_opening(
|
|
@@ -519,7 +574,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
|
|
|
let expected_application_id = 0;
|
|
|
|
|
|
- begin_review_applications(member_id, account_id, opening_id);
|
|
|
+ begin_review_applications(member_id, account_id, opening_id, 2);
|
|
|
|
|
|
let lead = StorageWorkingGroup::current_lead();
|
|
|
assert!(lead.is_none());
|
|
@@ -531,12 +586,15 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
payout_interval: None,
|
|
|
});
|
|
|
|
|
|
+ set_mint_capacity(member_id, account_id, 999999, 3);
|
|
|
+
|
|
|
fill_opening(
|
|
|
member_id,
|
|
|
account_id,
|
|
|
opening_id,
|
|
|
expected_application_id,
|
|
|
reward_policy,
|
|
|
+ 4,
|
|
|
);
|
|
|
|
|
|
let leader_worker_id = StorageWorkingGroup::current_lead().unwrap();
|
|
@@ -548,7 +606,13 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
|
|
|
assert_eq!(relationship.amount_per_payout, old_reward_amount);
|
|
|
|
|
|
let new_reward_amount = 999;
|
|
|
- set_reward(member_id, account_id, leader_worker_id, new_reward_amount);
|
|
|
+ set_reward(
|
|
|
+ member_id,
|
|
|
+ account_id,
|
|
|
+ leader_worker_id,
|
|
|
+ new_reward_amount,
|
|
|
+ 5,
|
|
|
+ );
|
|
|
|
|
|
let relationship = recurringrewards::RewardRelationships::<Runtime>::get(relationship_id);
|
|
|
assert_eq!(relationship.amount_per_payout, new_reward_amount);
|