Skip to content

Commit

Permalink
Spread to other runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Oct 8, 2023
1 parent 9aa9591 commit 39eb1ce
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 19 deletions.
8 changes: 0 additions & 8 deletions runtime/common/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,18 +942,12 @@ macro_rules! impl_governance_tests {
assert_type_eq_all!(<Runtime as pallet_democracy::Config>::VetoOrigin, pallet_collective::EnsureMember<AccountId, TechnicalCollective>);

// Values
assert_eq!(<<Runtime as pallet_democracy::Config>::CooloffPeriod as Get<u32>>::get(), 5 * MINUTES);
assert_eq!(<<Runtime as pallet_democracy::Config>::EnactmentPeriod as Get<u32>>::get(), 10 * MINUTES);
assert_eq!(<<Runtime as pallet_democracy::Config>::FastTrackVotingPeriod as Get<u32>>::get(), MINUTES);
assert_eq!(<<Runtime as pallet_democracy::Config>::InstantAllowed as Get<bool>>::get(), true);
assert_eq!(<<Runtime as pallet_democracy::Config>::LaunchPeriod as Get<u32>>::get(), 10 * MINUTES);
assert_eq!(<<Runtime as pallet_democracy::Config>::MaxBlacklisted as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_democracy::Config>::MaxDeposits as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_democracy::Config>::MaxProposals as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_democracy::Config>::MaxVotes as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_democracy::Config>::MinimumDeposit as Get<u128>>::get(), DARWINIA_PROPOSAL_REQUIREMENT);
assert_eq!(<<Runtime as pallet_democracy::Config>::VoteLockingPeriod as Get<u32>>::get(), 10 * MINUTES);
assert_eq!(<<Runtime as pallet_democracy::Config>::VotingPeriod as Get<u32>>::get(), 10 * MINUTES);
}

#[test]
Expand All @@ -963,7 +957,6 @@ macro_rules! impl_governance_tests {
// Values
assert_eq!(<<Runtime as pallet_collective::Config<CouncilCollective>>::MaxMembers as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_collective::Config<CouncilCollective>>::MaxProposals as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_collective::Config<CouncilCollective>>::MotionDuration as Get<u32>>::get(), 10 * MINUTES);
}

#[test]
Expand All @@ -973,7 +966,6 @@ macro_rules! impl_governance_tests {
// Values
assert_eq!(<<Runtime as pallet_collective::Config<TechnicalCollective>>::MaxMembers as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_collective::Config<TechnicalCollective>>::MaxProposals as Get<u32>>::get(), 100);
assert_eq!(<<Runtime as pallet_collective::Config<TechnicalCollective>>::MotionDuration as Get<u32>>::get(), 10 * MINUTES);
}
}

Expand Down
66 changes: 66 additions & 0 deletions runtime/crab/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,69 @@ darwinia_common_runtime::impl_fee_tests! {}
darwinia_common_runtime::impl_ethereum_tests! {}
darwinia_common_runtime::impl_account_migration_tests! {}
darwinia_common_runtime::impl_messages_bridge_tests! {}
darwinia_common_runtime::impl_governance_tests! {}
darwinia_common_runtime::impl_balances_tests! {}
darwinia_common_runtime::impl_assets_tests! {}
darwinia_common_runtime::impl_message_transact_tests! {}

mod specific_setting {
// darwinia
use crate::mock::*;
// substrate
use frame_support::traits::Get;

#[test]
fn precompile_address() {
assert_eq!(
CrabPrecompiles::<Runtime>::used_addresses()
.iter()
.map(|a| a.to_low_u64_be())
.collect::<Vec<u64>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1536, 1537, 2048]
);
}

#[test]
fn democracy_mod() {
assert_eq!(
<<Runtime as pallet_democracy::Config>::CooloffPeriod as Get<u32>>::get(),
7 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::EnactmentPeriod as Get<u32>>::get(),
8 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::FastTrackVotingPeriod as Get<u32>>::get(),
3 * HOURS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::LaunchPeriod as Get<u32>>::get(),
7 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VoteLockingPeriod as Get<u32>>::get(),
8 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VotingPeriod as Get<u32>>::get(),
7 * DAYS
);
}

#[test]
fn collective_mod() {
assert_eq!(
<<Runtime as pallet_collective::Config<CouncilCollective>>::MotionDuration as Get<
u32,
>>::get(),
3 * DAYS
);
assert_eq!(
<<Runtime as pallet_collective::Config<TechnicalCollective>>::MotionDuration as Get<
u32,
>>::get(),
3 * DAYS
);
}
}
4 changes: 2 additions & 2 deletions runtime/darwinia/src/pallets/democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl pallet_democracy::Config for Runtime {
type FastTrackVotingPeriod = ConstU32<{ 3 * HOURS }>;
type InstantAllowed = ConstBool<true>;
type InstantOrigin = RootOrAll<TechnicalCollective>;
type LaunchPeriod = ConstU32<{ 28 * DAYS }>;
type LaunchPeriod = ConstU32<{ ENACTMENT_PERIOD }>;
type MaxBlacklisted = ConstU32<100>;
type MaxDeposits = ConstU32<100>;
type MaxProposals = ConstU32<100>;
Expand All @@ -60,6 +60,6 @@ impl pallet_democracy::Config for Runtime {
// only do it once and it lasts only for the cool-off period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type VoteLockingPeriod = ConstU32<ENACTMENT_PERIOD>;
type VotingPeriod = ConstU32<{ 28 * DAYS }>;
type VotingPeriod = ConstU32<{ ENACTMENT_PERIOD }>;
type WeightInfo = weights::pallet_democracy::WeightInfo<Self>;
}
66 changes: 66 additions & 0 deletions runtime/darwinia/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,69 @@ darwinia_common_runtime::impl_fee_tests! {}
darwinia_common_runtime::impl_ethereum_tests! {}
darwinia_common_runtime::impl_account_migration_tests! {}
darwinia_common_runtime::impl_messages_bridge_tests! {}
darwinia_common_runtime::impl_governance_tests! {}
darwinia_common_runtime::impl_balances_tests! {}
darwinia_common_runtime::impl_assets_tests! {}
darwinia_common_runtime::impl_message_transact_tests! {}

mod specific_setting {
// darwinia
use crate::mock::*;
// substrate
use frame_support::traits::Get;

#[test]
fn precompile_address() {
assert_eq!(
DarwiniaPrecompiles::<Runtime>::used_addresses()
.iter()
.map(|a| a.to_low_u64_be())
.collect::<Vec<u64>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1536, 1537, 2048]
);
}

#[test]
fn democracy_mod() {
assert_eq!(
<<Runtime as pallet_democracy::Config>::CooloffPeriod as Get<u32>>::get(),
7 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::EnactmentPeriod as Get<u32>>::get(),
28 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::FastTrackVotingPeriod as Get<u32>>::get(),
3 * HOURS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::LaunchPeriod as Get<u32>>::get(),
28 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VoteLockingPeriod as Get<u32>>::get(),
28 * DAYS
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VotingPeriod as Get<u32>>::get(),
28 * DAYS
);
}

#[test]
fn collective_mod() {
assert_eq!(
<<Runtime as pallet_collective::Config<CouncilCollective>>::MotionDuration as Get<
u32,
>>::get(),
7 * DAYS
);
assert_eq!(
<<Runtime as pallet_collective::Config<TechnicalCollective>>::MotionDuration as Get<
u32,
>>::get(),
7 * DAYS
);
}
}
67 changes: 58 additions & 9 deletions runtime/pangolin/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,64 @@ darwinia_common_runtime::impl_balances_tests! {}
darwinia_common_runtime::impl_assets_tests! {}
darwinia_common_runtime::impl_message_transact_tests! {}

#[test]
fn precompile_address() {
mod specific_setting {
// darwinia
use crate::mock::*;
// substrate
use frame_support::traits::Get;

assert_eq!(
PangolinPrecompiles::<Runtime>::used_addresses()
.iter()
.map(|a| a.to_low_u64_be())
.collect::<Vec<u64>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1027, 1536, 1537, 2048]
);
#[test]
fn precompile_address() {
assert_eq!(
PangolinPrecompiles::<Runtime>::used_addresses()
.iter()
.map(|a| a.to_low_u64_be())
.collect::<Vec<u64>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1027, 1536, 1537, 2048]
);
}

#[test]
fn democracy_mod() {
assert_eq!(
<<Runtime as pallet_democracy::Config>::CooloffPeriod as Get<u32>>::get(),
5 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::EnactmentPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::FastTrackVotingPeriod as Get<u32>>::get(),
MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::LaunchPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VoteLockingPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VotingPeriod as Get<u32>>::get(),
10 * MINUTES
);
}

#[test]
fn collective_mod() {
assert_eq!(
<<Runtime as pallet_collective::Config<CouncilCollective>>::MotionDuration as Get<
u32,
>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_collective::Config<TechnicalCollective>>::MotionDuration as Get<
u32,
>>::get(),
10 * MINUTES
);
}
}
66 changes: 66 additions & 0 deletions runtime/pangoro/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,69 @@ darwinia_common_runtime::impl_fee_tests! {}
darwinia_common_runtime::impl_ethereum_tests! {}
darwinia_common_runtime::impl_account_migration_tests! {}
darwinia_common_runtime::impl_messages_bridge_tests! {}
darwinia_common_runtime::impl_governance_tests! {}
darwinia_common_runtime::impl_balances_tests! {}
darwinia_common_runtime::impl_assets_tests! {}
darwinia_common_runtime::impl_message_transact_tests! {}

mod specific_setting {
// darwinia
use crate::mock::*;
// substrate
use frame_support::traits::Get;

#[test]
fn precompile_address() {
assert_eq!(
PangoroPrecompiles::<Runtime>::used_addresses()
.iter()
.map(|a| a.to_low_u64_be())
.collect::<Vec<u64>>(),
vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1536, 1537, 2048]
);
}

#[test]
fn democracy_mod() {
assert_eq!(
<<Runtime as pallet_democracy::Config>::CooloffPeriod as Get<u32>>::get(),
5 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::EnactmentPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::FastTrackVotingPeriod as Get<u32>>::get(),
MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::LaunchPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VoteLockingPeriod as Get<u32>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_democracy::Config>::VotingPeriod as Get<u32>>::get(),
10 * MINUTES
);
}

#[test]
fn collective_mod() {
assert_eq!(
<<Runtime as pallet_collective::Config<CouncilCollective>>::MotionDuration as Get<
u32,
>>::get(),
10 * MINUTES
);
assert_eq!(
<<Runtime as pallet_collective::Config<TechnicalCollective>>::MotionDuration as Get<
u32,
>>::get(),
10 * MINUTES
);
}
}

0 comments on commit 39eb1ce

Please sign in to comment.