From 70da7d415dc9261017cbe0463382c7d5693c1d10 Mon Sep 17 00:00:00 2001 From: Amiya Behera Date: Sun, 21 Jan 2024 13:43:57 +0530 Subject: [PATCH] create phase will all data --- pallets/profile-validation/src/extras.rs | 2 +- pallets/profile-validation/src/tests.rs | 46 ++++++++++++++++++++++++ rust-toolchain.toml.bak | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/pallets/profile-validation/src/extras.rs b/pallets/profile-validation/src/extras.rs index 6fd6319..09b6fa0 100644 --- a/pallets/profile-validation/src/extras.rs +++ b/pallets/profile-validation/src/extras.rs @@ -53,7 +53,7 @@ impl ChallengeEvidencePost { impl Pallet { pub(super) fn get_phase_data() -> PhaseData { - T::SchellingGameSharedSource::create_phase_with_all_data(10, 100, 100, 100, 100, 100, 100, 5, 3, 100, (100, 100)) + T::SchellingGameSharedSource::create_phase_with_all_data(10, 100, 100, 100, 100, 100, 100, 5, 5, 100, (100, 100)) // T::SchellingGameSharedSource::create_phase_data(100, 5, 3, 100, (100, 100)) } diff --git a/pallets/profile-validation/src/tests.rs b/pallets/profile-validation/src/tests.rs index d8690ef..532ac22 100644 --- a/pallets/profile-validation/src/tests.rs +++ b/pallets/profile-validation/src/tests.rs @@ -425,3 +425,49 @@ fn schelling_game_test() { assert_eq!(300025, balance); }) } + +#[test] +fn test_draw_juror() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let content: Content = Content::IPFS( + "bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhvqy" + .as_bytes() + .to_vec(), + ); + assert_ok!(ProfileValidation::add_citizen(RuntimeOrigin::signed(1), content.clone())); + + assert_ok!(ProfileValidation::add_profile_stake(RuntimeOrigin::signed(3), 1, 1000)); + let challenge_content: Content = Content::IPFS( + "bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhabc" + .as_bytes() + .to_vec(), + ); + let phase_data = ProfileValidation::get_phase_data(); + System::set_block_number(phase_data.evidence_length + 1); + assert_ok!(ProfileValidation::challenge_profile( + RuntimeOrigin::signed(4), + 1, + challenge_content.clone() + )); + + + assert_ok!(ProfileValidation::apply_jurors(RuntimeOrigin::signed(5), 1, 100)); + assert_ok!(ProfileValidation::apply_jurors(RuntimeOrigin::signed(6), 1, 500)); + assert_ok!(ProfileValidation::apply_jurors(RuntimeOrigin::signed(7), 1, 1000)); + assert_ok!(ProfileValidation::apply_jurors(RuntimeOrigin::signed(8), 1, 1500)); + assert_ok!(ProfileValidation::apply_jurors(RuntimeOrigin::signed(9), 1, 2000)); + + System::set_block_number(phase_data.evidence_length + 1 + phase_data.staking_length); + + assert_ok!(ProfileValidation::pass_period(RuntimeOrigin::signed(5), 1)); + + assert_ok!(ProfileValidation::draw_jurors(RuntimeOrigin::signed(5), 1, 6)); + + // assert_ok!(ProfileValidation::draw_jurors(RuntimeOrigin::signed(5), 1, 5)); + + + + + }) +} diff --git a/rust-toolchain.toml.bak b/rust-toolchain.toml.bak index fdef78e..13d6bbe 100644 --- a/rust-toolchain.toml.bak +++ b/rust-toolchain.toml.bak @@ -1,3 +1,3 @@ [toolchain] -channel = "stable-2023-04-20" # stable|beta|nightly +channel = "stable-2023-12-21" # stable|beta|nightly targets = [ "wasm32-unknown-unknown"] \ No newline at end of file