From 1230c3ccbc3fdb7668a55b6b54c9ef8ad841fab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20=C5=BBuk?= Date: Fri, 17 Nov 2023 16:24:11 +0100 Subject: [PATCH] Hotfix tests --- bin/node/runtime/src/impls.rs | 3 +- .../democracy/src/tests/external_proposing.rs | 85 +------------------ frame/democracy/src/tests/public_proposals.rs | 4 +- frame/liberland-legislation/src/mock.rs | 2 + 4 files changed, 8 insertions(+), 86 deletions(-) diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index d7bf2270f..e0fcae277 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -908,12 +908,11 @@ mod multiplier_tests { assert!(!LandMetadataValidator::::validate_metadata(1, 1, &self_intersecting)); } - use frame_support::traits::EitherOfDiverse; use frame_system::{EnsureRoot, RawOrigin}; use node_primitives::AccountId; use core::cmp::Ordering; use sp_runtime::testing::sr25519; - use crate::{EnsureSenateMajority, EnsureCmp, OriginCaller, sp_api_hidden_includes_construct_runtime::hidden_include::traits::PrivilegeCmp}; + use crate::{EnsureCmp, OriginCaller, sp_api_hidden_includes_construct_runtime::hidden_include::traits::PrivilegeCmp}; #[test] fn ensure_cmp_works_for_root() { diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 90debfe01..efab8d435 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -185,28 +185,11 @@ fn external_and_public_interleaving_works() { fast_forward_to(2); - // both waiting: external goes first. + // both waiting: both start. assert_eq!( Democracy::referendum_status(0), Ok(ReferendumStatus { end: 4, - proposal: set_balance_proposal(1), - dispatch_origin: DispatchOrigin::Root, - threshold: VoteThreshold::SuperMajorityApprove, - delay: 2, - tally: Tally { ayes: 0, nays: 0, aye_voters: 00000, nay_voters: 00000, turnout: 0 }, - }) - ); - // replenish external - assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(3),)); - - fast_forward_to(4); - - // both waiting: public goes next. - assert_eq!( - Democracy::referendum_status(1), - Ok(ReferendumStatus { - end: 6, proposal: set_balance_proposal(2), dispatch_origin: DispatchOrigin::Root, threshold: VoteThreshold::SuperMajorityApprove, @@ -214,71 +197,11 @@ fn external_and_public_interleaving_works() { tally: Tally { ayes: 0, nays: 0, aye_voters: 00000, nay_voters: 00000, turnout: 0 }, }) ); - // don't replenish public - - fast_forward_to(6); - - // it's external "turn" again, though since public is empty that doesn't really matter - assert_eq!( - Democracy::referendum_status(2), - Ok(ReferendumStatus { - end: 8, - proposal: set_balance_proposal(3), - dispatch_origin: DispatchOrigin::Root, - threshold: VoteThreshold::SuperMajorityApprove, - delay: 2, - tally: Tally { ayes: 0, nays: 0, aye_voters: 00000, nay_voters: 00000, turnout: 0 }, - }) - ); - // replenish external - assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(5),)); - - fast_forward_to(8); - - // external goes again because there's no public waiting. assert_eq!( - Democracy::referendum_status(3), - Ok(ReferendumStatus { - end: 10, - proposal: set_balance_proposal(5), - dispatch_origin: DispatchOrigin::Root, - threshold: VoteThreshold::SuperMajorityApprove, - delay: 2, - tally: Tally { ayes: 0, nays: 0, aye_voters: 00000, nay_voters: 00000, turnout: 0 }, - }) - ); - // replenish both - assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(7),)); - assert_ok!(propose_set_balance(6, 4, 2)); - - fast_forward_to(10); - - // public goes now since external went last time. - assert_eq!( - Democracy::referendum_status(4), - Ok(ReferendumStatus { - end: 12, - proposal: set_balance_proposal(4), - dispatch_origin: DispatchOrigin::Root, - threshold: VoteThreshold::SuperMajorityApprove, - delay: 2, - tally: Tally { ayes: 0, nays: 0, aye_voters: 00000, nay_voters: 00000, turnout: 0 }, - }) - ); - // replenish public again - assert_ok!(propose_set_balance(6, 6, 2)); - // cancel external - let h = set_balance_proposal(7).hash(); - assert_ok!(Democracy::veto_external(RuntimeOrigin::signed(3), h)); - - fast_forward_to(12); - - // public goes again now since there's no external waiting. - assert_eq!( - Democracy::referendum_status(5), + Democracy::referendum_status(1), Ok(ReferendumStatus { - end: 14, - proposal: set_balance_proposal(6), + end: 4, + proposal: set_balance_proposal(1), dispatch_origin: DispatchOrigin::Root, threshold: VoteThreshold::SuperMajorityApprove, delay: 2, diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index e3ae7f901..eeb463085 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -177,7 +177,7 @@ fn blacklisting_should_work() { } #[test] -fn runners_up_should_come_after() { +fn all_referenda_should_start_at_the_same_time() { new_test_ext().execute_with(|| { System::set_block_number(0); assert_ok!(propose_set_balance(3, 2, 2)); @@ -185,9 +185,7 @@ fn runners_up_should_come_after() { assert_ok!(propose_set_balance(3, 3, 3)); fast_forward_to(2); assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 0, aye(1))); - fast_forward_to(4); assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 1, aye(1))); - fast_forward_to(6); assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 2, aye(1))); }); } diff --git a/frame/liberland-legislation/src/mock.rs b/frame/liberland-legislation/src/mock.rs index 2221b7758..15e3cc5f4 100644 --- a/frame/liberland-legislation/src/mock.rs +++ b/frame/liberland-legislation/src/mock.rs @@ -126,6 +126,8 @@ impl pallet_democracy::Config for Test { type LLInitializer = LiberlandInitializer; type DelegateeFilter = Everything; type SubmitOrigin = EnsureSigned; + type ProposalFeeAmount = ConstU64<0>; + type ProposalFee = (); } impl pallet_balances::Config for Test {