Skip to content

Commit

Permalink
Remove politest from integration-tests (#325)
Browse files Browse the repository at this point in the history
## What?
- Remove politest from integration tests, and replace all references with polimec

## Why?
- First step in deleting politest

## Testing?
`cargo test --package integration-tests`
  • Loading branch information
JuaniRios authored Jun 18, 2024
1 parent 28089fe commit 8e88a7e
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 416 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ pallet-treasury.workspace = true
polkadot-runtime.workspace = true
asset-hub-polkadot-runtime.workspace = true
polimec-runtime.workspace = true
politest-runtime.workspace = true
penpal-runtime = { path = "./penpal", default-features = false }

[features]
default = [ "instant-mode", "std" ]
default = [ "instant-mode", "std", "development-settings"]
instant-mode = [
"polimec-runtime/instant-mode",
"politest-runtime/instant-mode",
]
std = [
"asset-hub-polkadot-runtime/std",
Expand Down Expand Up @@ -118,7 +116,7 @@ std = [
"polimec-common-test-utils/std",
"polimec-common/std",
"polimec-receiver/std",
"politest-runtime/std",
"polimec-runtime/std",
"polkadot-core-primitives/std",
"polkadot-parachain-primitives/std",
"polkadot-primitives/std",
Expand All @@ -140,4 +138,7 @@ std = [
"xcm-executor/std",
"xcm/std",
]
development-settings = [
"polimec-runtime/development-settings",
]

187 changes: 5 additions & 182 deletions integration-tests/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@

use frame_support::BoundedVec;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_parachain_staking::inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR};
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
use politest_runtime::{
pallet_parachain_staking::{
inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR},
Range,
},
PLMC,
};
use polimec_runtime::{pallet_parachain_staking::Range, PLMC};
use polkadot_primitives::{AssignmentId, ValidatorId};
pub use polkadot_runtime_parachains::configuration::HostConfiguration;
use sc_consensus_grandpa::AuthorityId as GrandpaId;
Expand All @@ -33,8 +28,6 @@ use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_core::{sr25519, storage::Storage, Pair, Public};
use sp_runtime::{bounded_vec, BuildStorage, Perbill};

use pallet_funding::AcceptedFundingAsset;
pub use xcm;
use xcm_emulator::{helpers::get_account_id_from_seed, Chain, Parachain};

Expand All @@ -45,7 +38,7 @@ pub const PROOF_SIZE_THRESHOLD: u64 = 33;
pub const INITIAL_DEPOSIT: u128 = 420_0_000_000_000;
const BLOCKS_PER_ROUND: u32 = 6 * 100;

fn polimec_inflation_config() -> politest_runtime::pallet_parachain_staking::InflationInfo<Balance> {
fn polimec_inflation_config() -> polimec_runtime::pallet_parachain_staking::InflationInfo<Balance> {
fn to_round_inflation(annual: Range<Perbill>) -> Range<Perbill> {
perbill_annual_to_perbill_round(
annual,
Expand All @@ -57,7 +50,7 @@ fn polimec_inflation_config() -> politest_runtime::pallet_parachain_staking::Inf
let annual =
Range { min: Perbill::from_percent(2), ideal: Perbill::from_percent(3), max: Perbill::from_percent(3) };

politest_runtime::pallet_parachain_staking::InflationInfo {
polimec_runtime::pallet_parachain_staking::InflationInfo {
// staking expectations
expect: Range { min: 100_000 * PLMC, ideal: 200_000 * PLMC, max: 500_000 * PLMC },
// annual inflation
Expand Down Expand Up @@ -317,176 +310,6 @@ pub mod asset_hub {
}
}

// Polimec
pub mod politest {
use super::*;
use crate::{Polimec, PolitestNet, PolitestOrigin, PolitestRuntime, PolkadotNet};
use sp_runtime::traits::AccountIdConversion;
use xcm::v3::Parent;
use xcm_emulator::TestExt;

pub const PARA_ID: u32 = 3344;
pub const ED: Balance = politest_runtime::EXISTENTIAL_DEPOSIT;

const GENESIS_BLOCKS_PER_ROUND: BlockNumber = 1800;
const GENESIS_COLLATOR_COMMISSION: Perbill = Perbill::from_percent(10);
const GENESIS_PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(0);
const GENESIS_NUM_SELECTED_CANDIDATES: u32 = 5;

pub fn set_prices() {
PolitestNet::execute_with(|| {
let dot = (AcceptedFundingAsset::DOT.to_assethub_id(), FixedU128::from_rational(69, 1));
let usdc = (AcceptedFundingAsset::USDC.to_assethub_id(), FixedU128::from_rational(1, 1));
let usdt = (AcceptedFundingAsset::USDT.to_assethub_id(), FixedU128::from_rational(1, 1));
let plmc = (pallet_funding::PLMC_FOREIGN_ID, FixedU128::from_rational(840, 100));

let values: BoundedVec<(u32, FixedU128), <PolitestRuntime as orml_oracle::Config>::MaxFeedValues> =
vec![dot, usdc, usdt, plmc].try_into().expect("benchmarks can panic");
let alice: [u8; 32] = [
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205,
227, 154, 86, 132, 231, 165, 109, 162, 125,
];
let bob: [u8; 32] = [
142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144,
156, 178, 38, 170, 71, 148, 242, 106, 72,
];
let charlie: [u8; 32] = [
144, 181, 171, 32, 92, 105, 116, 201, 234, 132, 27, 230, 136, 134, 70, 51, 220, 156, 168, 163, 87, 132,
62, 234, 207, 35, 20, 100, 153, 101, 254, 34,
];

frame_support::assert_ok!(orml_oracle::Pallet::<PolitestRuntime>::feed_values(
PolitestOrigin::signed(alice.clone().into()),
values.clone()
));

frame_support::assert_ok!(orml_oracle::Pallet::<PolitestRuntime>::feed_values(
PolitestOrigin::signed(bob.clone().into()),
values.clone()
));

frame_support::assert_ok!(orml_oracle::Pallet::<PolitestRuntime>::feed_values(
PolitestOrigin::signed(charlie.clone().into()),
values.clone()
));
});
}

pub fn genesis() -> Storage {
let dot_asset_id = AcceptedFundingAsset::DOT.to_assethub_id();
let usdt_asset_id = AcceptedFundingAsset::USDT.to_assethub_id();
let mut funded_accounts = vec![
(
<Polimec<PolkadotNet>>::sovereign_account_id_of(
(Parent, xcm::prelude::Parachain(penpal::PARA_ID)).into(),
),
INITIAL_DEPOSIT,
),
(
<Polimec<PolkadotNet>>::sovereign_account_id_of(
(Parent, xcm::prelude::Parachain(asset_hub::PARA_ID)).into(),
),
INITIAL_DEPOSIT,
),
(<PolitestRuntime as pallet_funding::Config>::ContributionTreasury::get(), INITIAL_DEPOSIT),
(<PolitestRuntime as pallet_funding::Config>::PalletId::get().into_account_truncating(), INITIAL_DEPOSIT),
];
let alice_account = <Polimec<PolkadotNet>>::account_id_of(accounts::ALICE);
let bob_account: AccountId = <Polimec<PolkadotNet>>::account_id_of(accounts::BOB);
let charlie_account: AccountId = <Polimec<PolkadotNet>>::account_id_of(accounts::CHARLIE);
let dave_account: AccountId = <Polimec<PolkadotNet>>::account_id_of(accounts::DAVE);
let eve_account: AccountId = <Polimec<PolkadotNet>>::account_id_of(accounts::EVE);

funded_accounts.extend(accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)));
funded_accounts.extend(collators::initial_authorities().iter().cloned().map(|(acc, _)| (acc, 20_005 * PLMC)));
funded_accounts.push((get_account_id_from_seed::<sr25519::Public>("TREASURY_STASH"), 20_005 * PLMC));

let genesis_config = politest_runtime::RuntimeGenesisConfig {
system: Default::default(),
balances: politest_runtime::BalancesConfig { balances: funded_accounts },
parachain_info: politest_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
session: politest_runtime::SessionConfig {
keys: collators::invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
politest_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: politest_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: politest_runtime::SudoConfig { key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")) },
council: Default::default(),
democracy: Default::default(),
treasury: Default::default(),
technical_committee: politest_runtime::TechnicalCommitteeConfig {
members: vec![
alice_account.clone(),
bob_account.clone(),
charlie_account.clone(),
dave_account.clone(),
eve_account.clone(),
],
..Default::default()
},
elections: politest_runtime::ElectionsConfig {
members: vec![
(alice_account.clone(), 0),
(bob_account.clone(), 0),
(charlie_account.clone(), 0),
(dave_account.clone(), 0),
(eve_account.clone(), 0),
],
..Default::default()
},
oracle_providers_membership: politest_runtime::OracleProvidersMembershipConfig {
members: bounded_vec![alice_account.clone(), bob_account, charlie_account],
..Default::default()
},
parachain_staking: politest_runtime::ParachainStakingConfig {
candidates: collators::initial_authorities()
.iter()
.map(|(acc, _)| (acc.clone(), 20_000 * PLMC))
.collect(),
delegations: vec![],
inflation_config: polimec_inflation_config(),
collator_commission: GENESIS_COLLATOR_COMMISSION,
parachain_bond_reserve_percent: GENESIS_PARACHAIN_BOND_RESERVE_PERCENT,
blocks_per_round: GENESIS_BLOCKS_PER_ROUND,
num_selected_candidates: GENESIS_NUM_SELECTED_CANDIDATES,
},
foreign_assets: politest_runtime::ForeignAssetsConfig {
assets: vec![
(dot_asset_id, alice_account.clone(), true, 0_0_010_000_000u128),
(usdt_asset_id, alice_account.clone(), true, 0_0_010_000_000u128),
],
metadata: vec![
(dot_asset_id, "Local DOT".as_bytes().to_vec(), "DOT".as_bytes().to_vec(), 10),
(usdt_asset_id, "Local USDT".as_bytes().to_vec(), "USDT".as_bytes().to_vec(), 6),
],
accounts: vec![],
},
vesting: Default::default(),
transaction_payment: Default::default(),
contribution_tokens: Default::default(),
};

genesis_config.build_storage().unwrap()
}
}

// Penpal
pub mod penpal {
use super::*;
Expand Down Expand Up @@ -543,7 +366,7 @@ pub mod penpal {
}
}

// Polimec Runtime
// Polimec
pub mod polimec {
use super::*;
use crate::{PolimecNet, PolimecOrigin, PolimecRuntime};
Expand Down
Loading

0 comments on commit 8e88a7e

Please sign in to comment.