From d3052a51890f49b8620c31f182f657449d603029 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 17 Jun 2024 14:47:41 +0200 Subject: [PATCH] Remove politest from integration-tests --- Cargo.lock | 1 - integration-tests/Cargo.toml | 9 +- integration-tests/src/constants.rs | 187 +----------------- integration-tests/src/lib.rs | 52 +---- integration-tests/src/tests/credentials.rs | 78 ++++---- integration-tests/src/tests/ct_migration.rs | 40 ++-- integration-tests/src/tests/defaults.rs | 23 ++- integration-tests/src/tests/e2e.rs | 97 +++++---- integration-tests/src/tests/governance.rs | 2 +- integration-tests/src/tests/oracle.rs | 34 ++-- .../src/tests/reserve_backed_transfers.rs | 8 +- integration-tests/src/tests/vest.rs | 2 +- runtimes/polimec/Cargo.toml | 4 +- runtimes/polimec/src/lib.rs | 51 ++--- runtimes/politest/src/lib.rs | 4 - runtimes/shared-configuration/Cargo.toml | 1 + runtimes/shared-configuration/src/identity.rs | 16 ++ 17 files changed, 193 insertions(+), 416 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 934c0df7c..bee89ea81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4557,7 +4557,6 @@ dependencies = [ "polimec-common-test-utils", "polimec-receiver", "polimec-runtime", - "politest-runtime", "polkadot-core-primitives", "polkadot-parachain-primitives", "polkadot-primitives", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index f3d5aee0a..dafad096f 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -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", @@ -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", @@ -140,4 +138,7 @@ std = [ "xcm-executor/std", "xcm/std", ] +development-settings = [ + "polimec-runtime/development-settings", +] diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 3a3ca9439..2e956451c 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -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; @@ -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}; @@ -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 { +fn polimec_inflation_config() -> polimec_runtime::pallet_parachain_staking::InflationInfo { fn to_round_inflation(annual: Range) -> Range { perbill_annual_to_perbill_round( annual, @@ -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 @@ -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), ::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::::feed_values( - PolitestOrigin::signed(alice.clone().into()), - values.clone() - )); - - frame_support::assert_ok!(orml_oracle::Pallet::::feed_values( - PolitestOrigin::signed(bob.clone().into()), - values.clone() - )); - - frame_support::assert_ok!(orml_oracle::Pallet::::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![ - ( - >::sovereign_account_id_of( - (Parent, xcm::prelude::Parachain(penpal::PARA_ID)).into(), - ), - INITIAL_DEPOSIT, - ), - ( - >::sovereign_account_id_of( - (Parent, xcm::prelude::Parachain(asset_hub::PARA_ID)).into(), - ), - INITIAL_DEPOSIT, - ), - (::ContributionTreasury::get(), INITIAL_DEPOSIT), - (::PalletId::get().into_account_truncating(), INITIAL_DEPOSIT), - ]; - let alice_account = >::account_id_of(accounts::ALICE); - let bob_account: AccountId = >::account_id_of(accounts::BOB); - let charlie_account: AccountId = >::account_id_of(accounts::CHARLIE); - let dave_account: AccountId = >::account_id_of(accounts::DAVE); - let eve_account: AccountId = >::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::("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::("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::*; @@ -543,7 +366,7 @@ pub mod penpal { } } -// Polimec Runtime +// Polimec pub mod polimec { use super::*; use crate::{PolimecNet, PolimecOrigin, PolimecRuntime}; diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index f7a5b436b..e4ae37892 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -19,7 +19,7 @@ pub mod constants; #[cfg(test)] mod tests; -pub use constants::{accounts::*, asset_hub, penpal, polimec, politest, polkadot}; +pub use constants::{accounts::*, asset_hub, penpal, polimec, polkadot}; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::Weight, parameter_types, traits::Hooks}; pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; pub use sp_core::{sr25519, storage::Storage, Encode, Get}; @@ -66,27 +66,6 @@ decl_test_parachains! { ParachainInfo: penpal_runtime::ParachainInfo, } }, - pub struct Politest { - genesis = politest::genesis(), - on_init = politest_runtime::AuraExt::on_initialize(1), - runtime = politest_runtime, - core = { - XcmpMessageHandler: politest_runtime::XcmpQueue, - LocationToAccountId: politest_runtime::xcm_config::LocationToAccountId, - ParachainInfo: politest_runtime::ParachainInfo, - MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, - }, - pallets = { - Balances: politest_runtime::Balances, - ParachainSystem: politest_runtime::ParachainSystem, - PolkadotXcm: politest_runtime::PolkadotXcm, - LocalAssets: politest_runtime::ContributionTokensInstance, - ForeignAssets: politest_runtime::ForeignAssets, - FundingPallet: politest_runtime::Funding, - Dispenser: politest_runtime::Dispenser, - Vesting: politest_runtime::Vesting, - } - }, pub struct AssetHub { genesis = asset_hub::genesis(), on_init = asset_hub_polkadot_runtime::AuraExt::on_initialize(1), @@ -120,6 +99,9 @@ decl_test_parachains! { ParachainSystem: polimec_runtime::ParachainSystem, PolkadotXcm: polimec_runtime::PolkadotXcm, ForeignAssets: polimec_runtime::ForeignAssets, + Funding: polimec_runtime::Funding, + Dispenser: polimec_runtime::Dispenser, + Vesting: polimec_runtime::Vesting, } } } @@ -128,7 +110,6 @@ decl_test_networks! { pub struct PolkadotNet { relay_chain = PolkadotRelay, parachains = vec![ - Politest, Penpal, AssetHub, Polimec, @@ -140,74 +121,61 @@ decl_test_networks! { /// Shortcuts to reduce boilerplate on runtime types pub mod shortcuts { use super::{ - AssetHub, AssetHubParaPallet, Chain, Penpal, PenpalParaPallet, Polimec, PolimecParaPallet, Politest, - PolitestParaPallet, PolkadotNet, PolkadotRelay as Polkadot, PolkadotRelayRelayPallet, + AssetHub, AssetHubParaPallet, Chain, Penpal, PenpalParaPallet, Polimec, PolimecParaPallet, PolkadotNet, + PolkadotRelay as Polkadot, PolkadotRelayRelayPallet, }; pub type PolkaNet = Polkadot; pub type PolimecNet = Polimec; pub type PenNet = Penpal; pub type AssetNet = AssetHub; - pub type PolitestNet = Politest; - - pub type PolitestFundingPallet = as PolitestParaPallet>::FundingPallet; pub type PolkadotRuntime = ::Runtime; - pub type PolitestRuntime = ::Runtime; pub type PenpalRuntime = ::Runtime; pub type AssetHubRuntime = ::Runtime; pub type PolimecRuntime = ::Runtime; + pub type PolimecFunding = ::Funding; + pub type PolimecDispenser = ::Dispenser; + pub type PolimecVesting = ::Vesting; + pub type PolkadotXcmPallet = ::XcmPallet; - pub type PolitestXcmPallet = ::PolkadotXcm; pub type PenpalXcmPallet = ::PolkadotXcm; pub type AssetHubXcmPallet = ::PolkadotXcm; pub type PolimecXcmPallet = ::PolkadotXcm; pub type PolkadotBalances = ::Balances; - pub type PolitestBalances = ::Balances; pub type PenpalBalances = ::Balances; pub type AssetHubBalances = ::Balances; pub type PolimecBalances = ::Balances; - pub type PolitestLocalAssets = ::LocalAssets; - pub type PolitestForeignAssets = ::ForeignAssets; pub type PenpalAssets = ::Assets; pub type AssetHubAssets = ::LocalAssets; pub type PolimecForeignAssets = ::ForeignAssets; pub type PolkadotOrigin = ::RuntimeOrigin; - pub type PolitestOrigin = ::RuntimeOrigin; pub type PenpalOrigin = ::RuntimeOrigin; pub type AssetHubOrigin = ::RuntimeOrigin; pub type PolimecOrigin = ::RuntimeOrigin; pub type PolkadotCall = ::RuntimeCall; - pub type PolitestCall = ::RuntimeCall; pub type PenpalCall = ::RuntimeCall; pub type AssetHubCall = ::RuntimeCall; pub type PolimecCall = ::RuntimeCall; pub type PolkadotAccountId = ::AccountId; - pub type PolitestAccountId = ::AccountId; pub type PenpalAccountId = ::AccountId; pub type AssetHubAccountId = ::AccountId; pub type PolimecAccountId = ::AccountId; pub type PolkadotEvent = ::RuntimeEvent; - pub type PolitestEvent = ::RuntimeEvent; pub type PenpalEvent = ::RuntimeEvent; pub type AssetHubEvent = ::RuntimeEvent; pub type PolimecEvent = ::RuntimeEvent; pub type PolkadotSystem = ::System; - pub type PolitestSystem = ::System; pub type PenpalSystem = ::System; pub type AssetHubSystem = ::System; pub type PolimecSystem = ::System; - - // Politest specific pallets - pub type PolitestDispenser = ::Dispenser; - pub type PolitestVesting = ::Vesting; } pub use shortcuts::*; diff --git a/integration-tests/src/tests/credentials.rs b/integration-tests/src/tests/credentials.rs index cbc4087bd..d4c1c174c 100644 --- a/integration-tests/src/tests/credentials.rs +++ b/integration-tests/src/tests/credentials.rs @@ -31,33 +31,29 @@ use tests::defaults::*; #[test] fn test_jwt_for_create() { let project = default_project_metadata(ISSUER.into()); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let issuer = AccountId32::from(ISSUER); - assert_ok!(PolitestBalances::force_set_balance(PolitestOrigin::root(), issuer.into(), 10_000 * PLMC)); - let retail_jwt = get_test_jwt(PolitestAccountId::from(ISSUER), InvestorType::Retail); + assert_ok!(PolimecBalances::force_set_balance(PolimecOrigin::root(), issuer.into(), 10_000 * PLMC)); + let retail_jwt = get_test_jwt(PolimecAccountId::from(ISSUER), InvestorType::Retail); assert_noop!( - PolitestFundingPallet::create_project(PolitestOrigin::signed(ISSUER.into()), retail_jwt, project.clone()), - pallet_funding::Error::::WrongInvestorType + PolimecFunding::create_project(PolimecOrigin::signed(ISSUER.into()), retail_jwt, project.clone()), + pallet_funding::Error::::WrongInvestorType ); - let inst_jwt = get_test_jwt(PolitestAccountId::from(ISSUER), InvestorType::Institutional); - assert_ok!(PolitestFundingPallet::create_project( - PolitestOrigin::signed(ISSUER.into()), - inst_jwt, - project.clone() - )); + let inst_jwt = get_test_jwt(PolimecAccountId::from(ISSUER), InvestorType::Institutional); + assert_ok!(PolimecFunding::create_project(PolimecOrigin::signed(ISSUER.into()), inst_jwt, project.clone())); }); } #[test] fn test_jwt_verification() { let project = default_project_metadata(ISSUER.into()); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let issuer = AccountId32::from(ISSUER); - assert_ok!(PolitestBalances::force_set_balance(PolitestOrigin::root(), issuer.into(), 1000 * PLMC)); + assert_ok!(PolimecBalances::force_set_balance(PolimecOrigin::root(), issuer.into(), 1000 * PLMC)); // This JWT tokens is signed with a private key that is not the one set in the Pallet Funding configuration in the real runtime. - let inst_jwt = get_fake_jwt(PolitestAccountId::from(ISSUER), InvestorType::Institutional); + let inst_jwt = get_fake_jwt(PolimecAccountId::from(ISSUER), InvestorType::Institutional); assert_noop!( - PolitestFundingPallet::create_project(PolitestOrigin::signed(ISSUER.into()), inst_jwt, project.clone()), + PolimecFunding::create_project(PolimecOrigin::signed(ISSUER.into()), inst_jwt, project.clone()), DispatchError::BadOrigin ); }); @@ -67,22 +63,22 @@ generate_accounts!(EMPTY_ACCOUNT); #[test] fn dispenser_signed_extensions_pass_for_new_account() { - PolitestNet::execute_with(|| { - let who = PolitestAccountId::from(EMPTY_ACCOUNT); + PolimecNet::execute_with(|| { + let who = PolimecAccountId::from(EMPTY_ACCOUNT); assert_eq!(PolimecBalances::free_balance(who.clone()), 0); let jwt = get_test_jwt(who.clone(), InvestorType::Retail); - let free_call = PolitestCall::Dispenser(pallet_dispenser::Call::dispense { jwt: jwt.clone() }); - let paid_call = PolitestCall::System(frame_system::Call::remark { remark: vec![69, 69] }); - let extra: politest_runtime::SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(Era::mortal(0u64, 0u64)), - pallet_dispenser::extensions::CheckNonce::::from(0u32), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0u64.into()).into(), + let free_call = PolimecCall::Dispenser(pallet_dispenser::Call::dispense { jwt: jwt.clone() }); + let paid_call = PolimecCall::System(frame_system::Call::remark { remark: vec![69, 69] }); + let extra: polimec_runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(Era::mortal(0u64, 0u64)), + pallet_dispenser::extensions::CheckNonce::::from(0u32), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0u64.into()).into(), ); assert_err!( extra.validate(&who, &paid_call, &paid_call.get_dispatch_info(), 0), @@ -100,8 +96,8 @@ fn dispenser_signed_extensions_pass_for_new_account() { #[test] fn dispenser_works_with_runtime_values() { - PolitestNet::execute_with(|| { - let who = PolitestAccountId::from(EMPTY_ACCOUNT); + PolimecNet::execute_with(|| { + let who = PolimecAccountId::from(EMPTY_ACCOUNT); let did = "kilt:did:tz:tz1K7fCz9QJtXv3J8Ud3Zvz7eQ6"; let bytes_did = did.as_bytes().to_vec(); let bounded_did: Did = bytes_did.try_into().unwrap(); @@ -109,25 +105,25 @@ fn dispenser_works_with_runtime_values() { who.clone(), InvestorType::Retail, bounded_did, - politest_runtime::DispenserWhitelistedPolicy::get(), + polimec_runtime::DispenserWhitelistedPolicy::get(), ); - PolitestBalances::force_set_balance( - PolitestOrigin::root(), - PolitestDispenser::dispense_account().into(), + PolimecBalances::force_set_balance( + PolimecOrigin::root(), + PolimecDispenser::dispense_account().into(), 1000 * PLMC, ) .unwrap(); - assert_ok!(PolitestDispenser::dispense(PolitestOrigin::signed(who.clone()), jwt)); - assert_eq!(PolitestBalances::free_balance(&who), 700 * PLMC); + assert_ok!(PolimecDispenser::dispense(PolimecOrigin::signed(who.clone()), jwt)); + assert_eq!(PolimecBalances::free_balance(&who), 700 * PLMC); assert_eq!( - PolitestBalances::usable_balance(who.clone()), - ::FreeDispenseAmount::get() + PolimecBalances::usable_balance(who.clone()), + ::FreeDispenseAmount::get() ); assert_eq!( - PolitestVesting::vesting_balance(&who), + PolimecVesting::vesting_balance(&who), Some( - ::InitialDispenseAmount::get() - - ::FreeDispenseAmount::get() + ::InitialDispenseAmount::get() - + ::FreeDispenseAmount::get() ) ); }) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 8dce49cb4..9a97323b5 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -18,22 +18,22 @@ use crate::*; use frame_support::traits::{fungible::Mutate, fungibles::Inspect}; use pallet_funding::{assert_close_enough, ProjectId}; use polimec_common::migration_types::{MigrationStatus, Migrations}; -use politest_runtime::Funding; +use polimec_runtime::Funding; use sp_runtime::Perquintill; use std::collections::HashMap; use tests::defaults::*; fn mock_hrmp_establishment(project_id: u32) { - let ct_issued = PolitestNet::execute_with(|| { - ::ContributionTokenCurrency::total_issuance(project_id) + let ct_issued = PolimecNet::execute_with(|| { + ::ContributionTokenCurrency::total_issuance(project_id) }); PenNet::execute_with(|| { let polimec_sovereign_account = >::sovereign_account_id_of((Parent, xcm::prelude::Parachain(polimec::PARA_ID)).into()); - PenpalBalances::set_balance(&polimec_sovereign_account, ct_issued + politest_runtime::EXISTENTIAL_DEPOSIT); + PenpalBalances::set_balance(&polimec_sovereign_account, ct_issued + polimec_runtime::EXISTENTIAL_DEPOSIT); }); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { assert_ok!(Funding::do_set_para_id_for_project(&ISSUER.into(), project_id, ParaId::from(6969u32))); let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { @@ -52,8 +52,8 @@ fn mock_hrmp_establishment(project_id: u32) { } fn assert_migration_is_ready(project_id: u32) { - PolitestNet::execute_with(|| { - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + PolimecNet::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); } @@ -63,10 +63,10 @@ fn get_migrations_for_participants( participants: Vec, ) -> HashMap { let mut user_migrations = HashMap::new(); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { for participant in participants { let (status, migrations) = - pallet_funding::UserMigrations::::get(project_id, participant.clone()).unwrap(); + pallet_funding::UserMigrations::::get(project_id, participant.clone()).unwrap(); user_migrations.insert(participant, (status, Migrations::from(migrations.into()))); } }); @@ -75,12 +75,8 @@ fn get_migrations_for_participants( fn send_migrations(project_id: ProjectId, accounts: Vec) { for user in accounts.into_iter() { - PolitestNet::execute_with(|| { - assert_ok!(Funding::migrate_one_participant( - PolitestOrigin::signed(user.clone()), - project_id, - user.clone() - )); + PolimecNet::execute_with(|| { + assert_ok!(Funding::migrate_one_participant(PolimecOrigin::signed(user.clone()), project_id, user.clone())); }); } } @@ -113,7 +109,7 @@ fn migrations_are_executed(project_id: ProjectId, accounts: Vec) { fn migrations_are_confirmed(project_id: u32, accounts: Vec) { let user_migrations = get_migrations_for_participants(project_id, accounts.clone()); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { for user in accounts.iter() { let (current_status, _) = user_migrations.get(user).unwrap(); assert_eq!(current_status, &MigrationStatus::Confirmed); @@ -150,7 +146,7 @@ fn migrations_are_vested(project_id: u32, accounts: Vec) { fn create_settled_project() -> (ProjectId, Vec) { let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let project_id = inst.create_finished_project( default_project_metadata(ISSUER.into()), ISSUER.into(), @@ -159,13 +155,13 @@ fn create_settled_project() -> (ProjectId, Vec) { default_community_contributions(), default_remainder_contributions(), ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); let mut participants: Vec = - pallet_funding::Evaluations::::iter_prefix_values((project_id,)) + pallet_funding::Evaluations::::iter_prefix_values((project_id,)) .map(|eval| eval.evaluator) - .chain(pallet_funding::Bids::::iter_prefix_values((project_id,)).map(|bid| bid.bidder)) + .chain(pallet_funding::Bids::::iter_prefix_values((project_id,)).map(|bid| bid.bidder)) .chain( - pallet_funding::Contributions::::iter_prefix_values((project_id,)) + pallet_funding::Contributions::::iter_prefix_values((project_id,)) .map(|contribution| contribution.contributor), ) .collect(); @@ -179,7 +175,7 @@ fn create_settled_project() -> (ProjectId, Vec) { #[test] fn full_migration_test() { - politest::set_prices(); + polimec::set_prices(); let (project_id, participants) = create_settled_project(); mock_hrmp_establishment(project_id); diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index b5bd2fd58..03b4c32b1 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::PolitestRuntime; +use crate::PolimecRuntime; use frame_support::BoundedVec; pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToUSDBalance}; use pallet_funding::{ @@ -25,8 +25,7 @@ use sp_arithmetic::{FixedPointNumber, Percent}; use macros::generate_accounts; use pallet_funding::traits::ProvideAssetPrice; use polimec_common::{USD_DECIMALS, USD_UNIT}; -use polimec_runtime::PLMC; -use politest_runtime::AccountId; +use polimec_runtime::{AccountId, PLMC}; use sp_runtime::{traits::ConstU32, Perquintill}; pub const IPFS_CID: &str = "QmeuJ24ffwLAZppQcgcggJs3n689bewednYkuc8Bx5Gngz"; @@ -34,9 +33,9 @@ pub const CT_DECIMALS: u8 = 18; pub const CT_UNIT: u128 = 10_u128.pow(CT_DECIMALS as u32); pub type IntegrationInstantiator = pallet_funding::instantiator::Instantiator< - PolitestRuntime, - ::AllPalletsWithoutSystem, - ::RuntimeEvent, + PolimecRuntime, + ::AllPalletsWithoutSystem, + ::RuntimeEvent, >; generate_accounts!( @@ -63,13 +62,13 @@ pub fn default_contributor_multipliers() -> Vec { vec![1u8, 1u8, 1u8, 1u8, 1u8] } -pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf { +pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf { ProjectMetadata { token_information: CurrencyMetadata { name: bounded_name(), symbol: bounded_symbol(), decimals: CT_DECIMALS }, mainnet_token_max_supply: 8_000_000 * CT_UNIT, total_allocation_size: 1_000_000 * CT_UNIT, auction_round_allocation_percentage: Percent::from_percent(50u8), - minimum_price: PriceProviderOf::::calculate_decimals_aware_price( + minimum_price: PriceProviderOf::::calculate_decimals_aware_price( sp_runtime::FixedU128::from_float(10.0), USD_DECIMALS, CT_DECIMALS, @@ -91,7 +90,7 @@ pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf Vec> { +pub fn default_evaluations() -> Vec> { vec![ UserToUSDBalance::new(EVAL_1.into(), 500_000 * PLMC), UserToUSDBalance::new(EVAL_2.into(), 250_000 * PLMC), @@ -102,7 +101,7 @@ pub fn default_bidders() -> Vec { vec![BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()] } -pub fn default_bids() -> Vec> { +pub fn default_bids() -> Vec> { let inst = IntegrationInstantiator::new(None); let default_metadata = default_project_metadata(ISSUER.into()); let auction_allocation = @@ -119,7 +118,7 @@ pub fn default_bids() -> Vec> { ) } -pub fn default_community_contributions() -> Vec> { +pub fn default_community_contributions() -> Vec> { let inst = IntegrationInstantiator::new(None); let default_metadata = default_project_metadata(ISSUER.into()); @@ -140,7 +139,7 @@ pub fn default_community_contributions() -> Vec Vec> { +pub fn default_remainder_contributions() -> Vec> { let inst = IntegrationInstantiator::new(None); let default_metadata = default_project_metadata(ISSUER.into()); diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index aa75e9691..744cb30a5 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -42,7 +42,7 @@ generate_accounts!( JOEL, POLKA, MALIK, ALEXANDER, SOLOMUN, JOHNNY, GRINGO, JONAS, BUNDI, FELIX, ); -pub fn excel_project() -> ProjectMetadataOf { +pub fn excel_project() -> ProjectMetadataOf { let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); let bounded_symbol = BoundedVec::try_from("PLMC".as_bytes().to_vec()).unwrap(); let metadata_hash = ipfs_hash(); @@ -54,8 +54,8 @@ pub fn excel_project() -> ProjectMetadataOf { auction_round_allocation_percentage: Percent::from_percent(50u8), // Minimum Price per Contribution Token (in USDT) - minimum_price: PriceProviderOf::::calculate_decimals_aware_price( - PriceOf::::from_float(10.0f64), + minimum_price: PriceProviderOf::::calculate_decimals_aware_price( + PriceOf::::from_float(10.0f64), USD_DECIMALS, CT_DECIMALS, ) @@ -77,7 +77,7 @@ pub fn excel_project() -> ProjectMetadataOf { } } -fn excel_evaluators() -> Vec> { +fn excel_evaluators() -> Vec> { vec![ (LINA.into(), 93754 * USD_UNIT).into(), (MIA.into(), 162 * USD_UNIT).into(), @@ -98,7 +98,7 @@ fn excel_evaluators() -> Vec> { ] } -fn excel_bidders() -> Vec> { +fn excel_bidders() -> Vec> { vec![ (ADAMS.into(), 700 * CT_UNIT).into(), (POLK.into(), 4000 * CT_UNIT).into(), @@ -125,7 +125,7 @@ fn excel_bidders() -> Vec> { ] } -fn excel_contributions() -> Vec> { +fn excel_contributions() -> Vec> { vec![ (XI.into(), 692 * CT_UNIT).into(), (PARI.into(), 236 * CT_UNIT).into(), @@ -172,7 +172,7 @@ fn excel_contributions() -> Vec> { (LUIS.into(), 422 * CT_UNIT).into(), ] } -fn excel_remainders() -> Vec> { +fn excel_remainders() -> Vec> { vec![ (JOEL.into(), 692 * CT_UNIT).into(), (POLK.into(), 236 * CT_UNIT).into(), @@ -271,7 +271,7 @@ fn excel_ct_amounts() -> UserToCTBalance { #[test] fn evaluation_round_completed() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); @@ -279,14 +279,14 @@ fn evaluation_round_completed() { let project = excel_project(); let evaluations = excel_evaluators(); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { inst.create_auctioning_project(project, issuer, evaluations); }); } #[test] fn auction_round_completed() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); @@ -295,13 +295,13 @@ fn auction_round_completed() { let evaluations = excel_evaluators(); let bids = excel_bidders(); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let project_id = inst.create_community_contributing_project(project, issuer, evaluations, bids); let excel_wap_fixed = FixedU128::from_float(10.202357561f64); let excel_wap_usd = excel_wap_fixed.saturating_mul_int(USD_UNIT); let stored_wap_fixed = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let stored_wap_fixed_decimal_unaware = PriceProviderOf::::convert_back_to_normal_price( + let stored_wap_fixed_decimal_unaware = PriceProviderOf::::convert_back_to_normal_price( stored_wap_fixed, USD_DECIMALS, CT_DECIMALS, @@ -314,7 +314,7 @@ fn auction_round_completed() { let names = names(); inst.execute(|| { let bids = - Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder.clone()).collect_vec(); + Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder.clone()).collect_vec(); for bid in bids.clone() { let key: [u8; 32] = bid.bidder.clone().into(); @@ -326,11 +326,11 @@ fn auction_round_completed() { #[test] fn community_round_completed() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let _ = inst.create_remainder_contributing_project( excel_project(), ISSUER.into(), @@ -340,7 +340,7 @@ fn community_round_completed() { ); inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0,)) + let contributions = Contributions::::iter_prefix_values((0,)) .sorted_by_key(|bid| bid.contributor.clone()) .collect_vec(); let _total_contribution = @@ -352,11 +352,11 @@ fn community_round_completed() { #[test] fn remainder_round_completed() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { inst.create_finished_project( excel_project(), ISSUER.into(), @@ -366,13 +366,13 @@ fn remainder_round_completed() { excel_remainders(), ); - let contributions = Contributions::::iter_prefix_values((0,)) + let contributions = Contributions::::iter_prefix_values((0,)) .sorted_by_key(|contribution| contribution.contributor.clone()) .collect_vec(); let total_stored = contributions.into_iter().fold(0, |acc, contribution| acc + contribution.funding_asset_amount); - let usdt_decimals = ::FundingCurrency::decimals( + let usdt_decimals = ::FundingCurrency::decimals( AcceptedFundingAsset::USDT.to_assethub_id(), ); let usdt_total_from_excel_f64 = 503_945.4_517_000_000f64; @@ -385,11 +385,11 @@ fn remainder_round_completed() { #[test] fn funds_raised() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let project_id = inst.create_finished_project( excel_project(), ISSUER.into(), @@ -400,12 +400,12 @@ fn funds_raised() { ); inst.execute(|| { - let project_specific_account: AccountId = PolitestFundingPallet::fund_account_id(project_id); + let project_specific_account: AccountId = PolimecFunding::fund_account_id(project_id); let stored_usdt_funded = - PolitestForeignAssets::balance(AcceptedFundingAsset::USDT.to_assethub_id(), project_specific_account); + PolimecForeignAssets::balance(AcceptedFundingAsset::USDT.to_assethub_id(), project_specific_account); let excel_usdt_funded_f64 = 1_004_256.0_140_000_000f64; let excet_usdt_funding_fixed = FixedU128::from_float(excel_usdt_funded_f64); - let usdt_decimals = ::FundingCurrency::decimals( + let usdt_decimals = ::FundingCurrency::decimals( AcceptedFundingAsset::USDT.to_assethub_id(), ); let excel_usdt_funded = excet_usdt_funding_fixed.saturating_mul_int(10u128.pow(usdt_decimals as u32)); @@ -416,11 +416,11 @@ fn funds_raised() { #[test] fn ct_minted() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { let project_id = inst.create_finished_project( excel_project(), ISSUER.into(), @@ -429,13 +429,13 @@ fn ct_minted() { excel_contributions(), excel_remainders(), ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); inst.settle_project(project_id).unwrap(); for (contributor, expected_amount_fixed, project_id) in excel_ct_amounts() { let minted = inst - .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); let expected_amount = expected_amount_fixed.saturating_mul_int(CT_UNIT); assert_close_enough!(minted, expected_amount, Perquintill::from_float(0.99)); } @@ -444,11 +444,11 @@ fn ct_minted() { #[test] fn ct_migrated() { - politest::set_prices(); + polimec::set_prices(); let mut inst = IntegrationInstantiator::new(None); - let project_id = PolitestNet::execute_with(|| { + let project_id = PolimecNet::execute_with(|| { let project_id = inst.create_finished_project( excel_project(), ISSUER.into(), @@ -457,13 +457,13 @@ fn ct_migrated() { excel_contributions(), excel_remainders(), ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); inst.settle_project(project_id).unwrap(); for (contributor, expected_amount_fixed, project_id) in excel_ct_amounts() { let minted = inst - .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); let expected_amount = expected_amount_fixed.saturating_mul_int(CT_UNIT); assert_close_enough!(minted, expected_amount, Perquintill::from_float(0.99)); } @@ -471,11 +471,10 @@ fn ct_migrated() { project_id }); - let project_details = PolitestNet::execute_with(|| inst.get_project_details(project_id)); + let project_details = PolimecNet::execute_with(|| inst.get_project_details(project_id)); assert!(matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Rewarded(_))); - let ct_issued = PolitestNet::execute_with(|| { - ::ContributionTokenCurrency::total_issuance(project_id) - }); + let ct_issued = + PolimecNet::execute_with(|| ::ContributionTokenCurrency::total_issuance(project_id)); PenNet::execute_with(|| { let polimec_sovereign_account = @@ -484,22 +483,18 @@ fn ct_migrated() { }); // Mock HRMP establishment - PolitestNet::execute_with(|| { - let _account_id: PolitestAccountId = ISSUER.into(); - assert_ok!(PolitestFundingPallet::do_set_para_id_for_project( - &ISSUER.into(), - project_id, - ParaId::from(6969u32), - )); + PolimecNet::execute_with(|| { + let _account_id: PolimecAccountId = ISSUER.into(); + assert_ok!(PolimecFunding::do_set_para_id_for_project(&ISSUER.into(), project_id, ParaId::from(6969u32),)); let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { sender: 6969, max_message_size: 102_300, max_capacity: 1000, }; - assert_ok!(PolitestFundingPallet::do_handle_channel_open_request(open_channel_message)); + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; - assert_ok!(PolitestFundingPallet::do_handle_channel_accepted(channel_accepted_message)); + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); }); PenNet::execute_with(|| { @@ -508,8 +503,8 @@ fn ct_migrated() { }); // Migration is ready - PolitestNet::execute_with(|| { - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + PolimecNet::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); @@ -529,9 +524,9 @@ fn ct_migrated() { let names = names(); for account in accounts { - PolitestNet::execute_with(|| { - assert_ok!(PolitestFundingPallet::migrate_one_participant( - PolitestOrigin::signed(account.clone()), + PolimecNet::execute_with(|| { + assert_ok!(PolimecFunding::migrate_one_participant( + PolimecOrigin::signed(account.clone()), project_id, account.clone() )); diff --git a/integration-tests/src/tests/governance.rs b/integration-tests/src/tests/governance.rs index 971cc9515..3275c2c30 100644 --- a/integration-tests/src/tests/governance.rs +++ b/integration-tests/src/tests/governance.rs @@ -116,7 +116,7 @@ fn council_and_technical_committee_members_set_correctly() { let dave = PolimecNet::account_id_of(DAVE); let eve = PolimecNet::account_id_of(EVE); let accounts = vec![alice, bob, charlie, dave, eve]; - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { assert_same_members(Council::members(), &accounts); assert_same_members(TechnicalCommittee::members(), &accounts); }); diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 779ee6f6a..8d46b38f1 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -19,13 +19,13 @@ use crate::*; /// Alice, Bob, Charlie are members of the OracleProvidersMembers. /// Only members should be able to feed data into the oracle. use parity_scale_codec::alloc::collections::HashMap; -use politest_runtime::{Oracle, RuntimeOrigin}; +use polimec_runtime::{Oracle, RuntimeOrigin}; use sp_runtime::{bounded_vec, BoundedVec, FixedU128}; use tests::defaults::*; fn values( values: [f64; 4], -) -> BoundedVec<(u32, FixedU128), >::MaxFeedValues> { +) -> BoundedVec<(u32, FixedU128), >::MaxFeedValues> { let [dot, usdc, usdt, plmc] = values; bounded_vec![ (10u32, FixedU128::from_float(dot)), @@ -39,16 +39,16 @@ fn values( fn members_can_feed_data() { let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. inst.advance_time(1u32).unwrap(); - let alice = PolitestNet::account_id_of(ALICE); + let alice = PolimecNet::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); - let bob = PolitestNet::account_id_of(BOB); + let bob = PolimecNet::account_id_of(BOB); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 0.4]))); - let charlie = PolitestNet::account_id_of(CHARLIE); + let charlie = PolimecNet::account_id_of(CHARLIE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); let expected_values = HashMap::from([ @@ -67,11 +67,11 @@ fn members_can_feed_data() { #[test] fn non_members_cannot_feed_data() { - PolitestNet::execute_with(|| { - let dave = PolitestNet::account_id_of(DAVE); + PolimecNet::execute_with(|| { + let dave = PolimecNet::account_id_of(DAVE); assert_noop!( Oracle::feed_values(RuntimeOrigin::signed(dave.clone()), values([4.84, 1.0, 1.0, 0.4])), - orml_oracle::Error::::NoPermission + orml_oracle::Error::::NoPermission ); }); } @@ -79,17 +79,17 @@ fn non_members_cannot_feed_data() { #[test] fn data_is_correctly_combined() { let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. inst.advance_time(1u32).unwrap(); - let alice = PolitestNet::account_id_of(ALICE); + let alice = PolimecNet::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 0.11111]))); - let bob = PolitestNet::account_id_of(BOB); + let bob = PolimecNet::account_id_of(BOB); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([2.0, 1.0, 1.2, 0.22222]))); - let charlie = PolitestNet::account_id_of(CHARLIE); + let charlie = PolimecNet::account_id_of(CHARLIE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([3.0, 0.8, 1.1, 0.33333]))); // Default CombineData implementation is the median value @@ -111,17 +111,17 @@ fn data_is_correctly_combined() { fn pallet_funding_works() { let mut inst = IntegrationInstantiator::new(None); - PolitestNet::execute_with(|| { + PolimecNet::execute_with(|| { // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. inst.advance_time(1u32).unwrap(); - let alice = PolitestNet::account_id_of(ALICE); + let alice = PolimecNet::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); - let bob = PolitestNet::account_id_of(BOB); + let bob = PolimecNet::account_id_of(BOB); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 0.4]))); - let charlie = PolitestNet::account_id_of(CHARLIE); + let charlie = PolimecNet::account_id_of(CHARLIE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); let _project_id = inst.create_finished_project( diff --git a/integration-tests/src/tests/reserve_backed_transfers.rs b/integration-tests/src/tests/reserve_backed_transfers.rs index d67252362..b43c9492c 100644 --- a/integration-tests/src/tests/reserve_backed_transfers.rs +++ b/integration-tests/src/tests/reserve_backed_transfers.rs @@ -63,9 +63,9 @@ fn mint_asset_on_asset_hub_to(asset_id: u32, recipient: &AssetHubAccountId, amou fn get_polimec_balances(asset_id: u32, user_account: AccountId) -> (u128, u128, u128, u128) { PolimecNet::execute_with(|| { ( - PolitestForeignAssets::balance(asset_id, user_account.clone()), + PolimecForeignAssets::balance(asset_id, user_account.clone()), PolimecBalances::balance(&user_account.clone()), - PolitestForeignAssets::total_issuance(asset_id), + PolimecForeignAssets::total_issuance(asset_id), PolimecBalances::total_issuance(), ) }) @@ -169,14 +169,14 @@ fn test_reserve_to_polimec(asset_id: u32) { let asset_hub_delta_asset_issuance = asset_hub_post_asset_issuance.abs_diff(asset_hub_prev_asset_issuance); assert!( - polimec_delta_alice_asset_balance >= RESERVE_TRANSFER_AMOUNT - politest_runtime::WeightToFee::weight_to_fee(&max_weight) && + polimec_delta_alice_asset_balance >= RESERVE_TRANSFER_AMOUNT - polimec_runtime::WeightToFee::weight_to_fee(&max_weight) && polimec_delta_alice_asset_balance <= RESERVE_TRANSFER_AMOUNT, "Polimec alice_account.clone() Asset balance should have increased by at least the transfer amount minus the XCM execution fee" ); assert!( polimec_delta_asset_issuance >= - RESERVE_TRANSFER_AMOUNT - politest_runtime::WeightToFee::weight_to_fee(&max_weight) && + RESERVE_TRANSFER_AMOUNT - polimec_runtime::WeightToFee::weight_to_fee(&max_weight) && polimec_delta_asset_issuance <= RESERVE_TRANSFER_AMOUNT, "Polimec Asset issuance should have increased by at least the transfer amount minus the XCM execution fee" ); diff --git a/integration-tests/src/tests/vest.rs b/integration-tests/src/tests/vest.rs index b547ec0a2..aa428057a 100644 --- a/integration-tests/src/tests/vest.rs +++ b/integration-tests/src/tests/vest.rs @@ -42,7 +42,7 @@ fn base_vested_can_stake() { // Stake 60 PLMC from "new_account" to "COLL_1", it should fail since the account has no PLMC assert_noop!( ParachainStaking::delegate(RuntimeOrigin::signed(new_account.clone()), coll_1.clone(), 60 * PLMC, 0, 0), - pallet_parachain_staking::Error::::InsufficientBalance + pallet_parachain_staking::Error::::InsufficientBalance ); // Create a vesting schedule for 60 PLMC + ED over 60 blocks (~1 PLMC per block) to NEW_ACCOUNT diff --git a/runtimes/polimec/Cargo.toml b/runtimes/polimec/Cargo.toml index d17dc79f8..3da246c72 100644 --- a/runtimes/polimec/Cargo.toml +++ b/runtimes/polimec/Cargo.toml @@ -278,4 +278,6 @@ try-runtime = [ # to make it smaller, like logging for example. on-chain-release-build = [ "sp-api/disable-logging" ] -development-settings = [] +development-settings = [ + "shared-configuration/development-settings" +] diff --git a/runtimes/polimec/src/lib.rs b/runtimes/polimec/src/lib.rs index c00a614bf..94087c891 100644 --- a/runtimes/polimec/src/lib.rs +++ b/runtimes/polimec/src/lib.rs @@ -227,21 +227,24 @@ pub struct BaseCallFilter; impl Contains for BaseCallFilter { fn contains(c: &RuntimeCall) -> bool { match c { - RuntimeCall::Funding(call) => { - matches!( - call, - pallet_funding::Call::create_project { .. } | - pallet_funding::Call::remove_project { .. } | - pallet_funding::Call::edit_project { .. } | - pallet_funding::Call::start_evaluation { .. } | - pallet_funding::Call::root_do_evaluation_end { .. } | - pallet_funding::Call::evaluate { .. } | - pallet_funding::Call::start_auction { .. } | - pallet_funding::Call::root_do_auction_opening { .. } | - pallet_funding::Call::root_do_start_auction_closing { .. } | - pallet_funding::Call::bid { .. } - ) - }, + RuntimeCall::Funding(call) => + if cfg!(feature = "development-settings") { + true + } else { + matches!( + call, + pallet_funding::Call::create_project { .. } | + pallet_funding::Call::remove_project { .. } | + pallet_funding::Call::edit_project { .. } | + pallet_funding::Call::start_evaluation { .. } | + pallet_funding::Call::root_do_evaluation_end { .. } | + pallet_funding::Call::evaluate { .. } | + pallet_funding::Call::start_auction { .. } | + pallet_funding::Call::root_do_auction_opening { .. } | + pallet_funding::Call::root_do_start_auction_closing { .. } | + pallet_funding::Call::bid { .. } + ) + }, _ => true, } } @@ -995,24 +998,6 @@ parameter_types! { } -// Development public key -#[cfg(any(feature = "development-settings", test))] -parameter_types! { - pub VerifierPublicKey: [u8; 32] = [ - 32, 118, 30, 171, 58, 212, 197, 27, 146, 122, 255, 243, 34, 245, 90, 244, 221, 37, 253, - 195, 18, 202, 111, 55, 39, 48, 123, 17, 101, 78, 215, 94, - ]; -} - -// Production public key -#[cfg(not(any(feature = "development-settings", test)))] -parameter_types! { - pub VerifierPublicKey: [u8; 32] = [ - 83, 49, 95, 191, 98, 138, 14, 43, 234, 192, 105, 248, 11, 96, 127, 234, 192, 62, 80, - 35, 204, 0, 38, 210, 177, 72, 167, 116, 133, 127, 140, 249 - ]; -} - pub struct ConvertSelf; impl Convert for ConvertSelf { fn convert(account_id: AccountId) -> [u8; 32] { diff --git a/runtimes/politest/src/lib.rs b/runtimes/politest/src/lib.rs index 374d0a947..3a1b6e20b 100644 --- a/runtimes/politest/src/lib.rs +++ b/runtimes/politest/src/lib.rs @@ -997,10 +997,6 @@ parameter_types! { pub MaxCapacityThresholds: (u32, u32) = (8, 1000); pub RequiredMaxCapacity: u32 = 1000; pub RequiredMaxMessageSize: u32 = 102_400; - pub VerifierPublicKey: [u8; 32] = [ - 32, 118, 30, 171, 58, 212, 197, 27, 146, 122, 255, 243, 34, 245, 90, 244, 221, 37, 253, - 195, 18, 202, 111, 55, 39, 48, 123, 17, 101, 78, 215, 94, - ]; pub MinUsdPerEvaluation: Balance = 100 * USD_UNIT; } diff --git a/runtimes/shared-configuration/Cargo.toml b/runtimes/shared-configuration/Cargo.toml index 24ddb3892..0e72af673 100644 --- a/runtimes/shared-configuration/Cargo.toml +++ b/runtimes/shared-configuration/Cargo.toml @@ -86,3 +86,4 @@ try-runtime = [ "polimec-common/try-runtime", "sp-runtime/try-runtime", ] +development-settings = [] diff --git a/runtimes/shared-configuration/src/identity.rs b/runtimes/shared-configuration/src/identity.rs index e453bbd3b..28c4a5a64 100644 --- a/runtimes/shared-configuration/src/identity.rs +++ b/runtimes/shared-configuration/src/identity.rs @@ -58,3 +58,19 @@ pub type UsernameAuthorityOrigin = frame_system::EnsureNever; #[cfg(feature = "runtime-benchmarks")] pub type UsernameAuthorityOrigin = frame_system::EnsureRoot; + +parameter_types! { + pub TestingVerifierPublicKey: [u8; 32] = [ + 32, 118, 30, 171, 58, 212, 197, 27, 146, 122, 255, 243, 34, 245, 90, 244, 221, 37, 253, + 195, 18, 202, 111, 55, 39, 48, 123, 17, 101, 78, 215, 94, + ]; + pub ProductionVerifierPublicKey: [u8; 32] = [ + 83, 49, 95, 191, 98, 138, 14, 43, 234, 192, 105, 248, 11, 96, 127, 234, 192, 62, 80, + 35, 204, 0, 38, 210, 177, 72, 167, 116, 133, 127, 140, 249 + ]; +} + +#[cfg(any(feature = "runtime-benchmarks", test, feature = "development-settings"))] +pub type VerifierPublicKey = TestingVerifierPublicKey; +#[cfg(not(any(feature = "runtime-benchmarks", test, feature = "development-settings")))] +pub type VerifierPublicKey = ProductionVerifierPublicKey;