Skip to content

Commit

Permalink
Hotfix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperzuk-neti committed Nov 17, 2023
1 parent 760a27d commit 1230c3c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 86 deletions.
3 changes: 1 addition & 2 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,12 +908,11 @@ mod multiplier_tests {
assert!(!LandMetadataValidator::<TestCoords>::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() {
Expand Down
85 changes: 4 additions & 81 deletions frame/democracy/src/tests/external_proposing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,100 +185,23 @@ 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,
delay: 2,
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,
Expand Down
4 changes: 1 addition & 3 deletions frame/democracy/src/tests/public_proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,15 @@ 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));
assert_ok!(propose_set_balance(3, 4, 4));
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)));
});
}
2 changes: 2 additions & 0 deletions frame/liberland-legislation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ impl pallet_democracy::Config for Test {
type LLInitializer = LiberlandInitializer;
type DelegateeFilter = Everything;
type SubmitOrigin = EnsureSigned<Self::AccountId>;
type ProposalFeeAmount = ConstU64<0>;
type ProposalFee = ();
}

impl pallet_balances::Config for Test {
Expand Down

0 comments on commit 1230c3c

Please sign in to comment.