Skip to content

Commit

Permalink
Polkadot v1.1.0 Integration Tests (#1776)
Browse files Browse the repository at this point in the history
* legacy-test migration wip

* main changes

* remove unused dependency

* basic stuff migrated

* uncomment fudge_env

* update fudge

* integration-tests: Fix test envs (#1780)

* main changes

* integration-tests: Fix test envs

* runtime: Implement parachains pallets for runtimes

* runtime: Enable multilocation convert for CurrencyIdConvert

* runtime: Remove extra paras pallets

* integration-tests: Update expected balances

---------

Co-authored-by: lemunozm <[email protected]>

---------

Co-authored-by: Cosmin Damian <[email protected]>
  • Loading branch information
lemunozm and cdamian authored Apr 2, 2024
1 parent 907a6e9 commit fb20056
Show file tree
Hide file tree
Showing 25 changed files with 779 additions and 573 deletions.
590 changes: 416 additions & 174 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ members = [
"runtime/centrifuge",
"runtime/development",
"runtime/common",
#"runtime/integration-tests",
"runtime/integration-tests",
]

[workspace.package]
Expand Down Expand Up @@ -122,6 +122,7 @@ polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk",
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-node-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
Expand Down Expand Up @@ -219,8 +220,8 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v1.1.0" }

# Centrifuge organization
#fudge = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v1.1.0" }
#fudge-core = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v1.1.0" }
fudge = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v1.1.0" }
fudge-core = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v1.1.0" }
chainbridge = { git = "https://github.com/centrifuge/chainbridge-substrate.git", default-features = false, branch = "polkadot-v1.1.0-latest-deps" }

# Foss3
Expand Down
6 changes: 2 additions & 4 deletions runtime/common/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,19 @@ where
}
}

/*
/// Convert an incoming `MultiLocation` into a `CurrencyId` through a
/// reverse-lookup using the AssetRegistry. In the registry, we register CFG
/// using its absolute, non-anchored MultliLocation so we need to unanchor the
/// using its absolute, non-anchored MultiLocation so we need to unanchor the
/// input location for Centrifuge-native assets for that to work.
impl<T> Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert<T>
where
T: orml_asset_registry::Config<AssetId = CurrencyId, CustomMetadata = CustomMetadata>
+ parachain_info::Config,
{
fn convert(location: MultiLocation) -> Option<CurrencyId> {
<Self as MaybeEquivalence<_, _>>::convert(location)
<Self as MaybeEquivalence<_, _>>::convert(&location)
}
}
*/

impl<T> Convert<MultiAsset, Option<CurrencyId>> for CurrencyIdConvert<T>
where
Expand Down
4 changes: 2 additions & 2 deletions runtime/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ thiserror = { workspace = true }
tokio = { workspace = true }
tracing-subscriber = { workspace = true }

node-primitives = { workspace = true, features = ["std"] }
sc-block-builder = { workspace = true }
sc-client-api = { workspace = true }
sc-executor = { workspace = true, features = ["std"] }
Expand Down Expand Up @@ -51,8 +50,9 @@ cumulus-primitives-core = { workspace = true, features = ["std"] }
cumulus-primitives-parachain-inherent = { workspace = true, features = ["std"] }
cumulus-test-relay-sproof-builder = { workspace = true, features = ["std"] }

kusama-runtime = { workspace = true, features = ["std"] }
staging-kusama-runtime = { workspace = true, features = ["std"] }
polkadot-core-primitives = { workspace = true, features = ["std"] }
polkadot-node-primitives = { workspace = true }
polkadot-parachain-primitives = { workspace = true, features = ["std"] }
polkadot-primitives = { workspace = true, features = ["std"] }
polkadot-runtime = { workspace = true, features = ["std"] }
Expand Down
14 changes: 10 additions & 4 deletions runtime/integration-tests/src/evm/precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cfg_types::{
};
use ethabi::{Contract, Function, Param, ParamType, Token};
use ethereum::{LegacyTransaction, TransactionAction, TransactionSignature, TransactionV2};
use frame_support::{assert_err, assert_ok, dispatch::RawOrigin};
use frame_support::{assert_err, assert_ok, dispatch::RawOrigin, BoundedVec};
use fudge::primitives::Chain;
use hex::ToHex;
use orml_traits::{asset_registry::AssetMetadata, MultiCurrency};
Expand All @@ -32,8 +32,8 @@ use parity_scale_codec::Encode;
use runtime_common::{account_conversion::AccountConverter, evm::precompile::LP_AXELAR_GATEWAY};
use sp_core::{Get, H160, H256, U256};
use sp_runtime::traits::{BlakeTwo256, Hash};
use staging_xcm::{v3::MultiLocation, VersionedMultiLocation};
use tokio::runtime::Handle;
use xcm::{v3::MultiLocation, VersionedMultiLocation};

use crate::{
chain::centrifuge::{
Expand Down Expand Up @@ -91,8 +91,14 @@ async fn axelar_precompile_execute() {

let currency_metadata = AssetMetadata {
decimals: 18,
name: "Test".into(),
symbol: "TST".into(),
name: BoundedVec::<u8, <Runtime as pallet_pool_system::Config>::StringLimit>::try_from(
"Test".as_bytes().to_vec(),
)
.expect("Can create BoundedVec for token name"),
symbol: BoundedVec::<u8, <Runtime as pallet_pool_system::Config>::StringLimit>::try_from(
"TST".as_bytes().to_vec(),
)
.expect("Can create BoundedVec for token symbol"),
existential_deposit: ED,
location: Some(VersionedMultiLocation::V3(MultiLocation::here())),
additional: CustomMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
use cfg_primitives::AccountId;
use runtime_common::apis::runtime_decl_for_account_conversion_api::AccountConversionApi;
use sp_api::{BlockT, HeaderT};
use sp_runtime::traits::{Get, Zero};
use xcm::v3::{
use staging_xcm::v3::{
Junction::{AccountId32, AccountKey20, Parachain},
Junctions::{X1, X2},
MultiLocation, NetworkId,
Expand Down Expand Up @@ -187,7 +188,7 @@ fn remote_account_on_relay<T: Runtime>() {
AccountId32 {
id: KEY_32,
network: Some(NetworkId::ByGenesis(
frame_system::BlockHash::<T>::get(T::BlockNumber::zero()).0,
frame_system::BlockHash::<T>::get::<u32>(Zero::zero()).0,
)),
},
),
Expand Down Expand Up @@ -215,7 +216,10 @@ fn remote_account_on_sibling<T: Runtime>() {
AccountId32 {
id: KEY_32,
network: Some(NetworkId::ByGenesis(
frame_system::BlockHash::<T>::get(T::BlockNumber::zero()).0,
frame_system::BlockHash::<T>::get(
<<T::BlockExt as BlockT>::Header as HeaderT>::Number::zero(),
)
.0,
)),
},
),
Expand Down
10 changes: 6 additions & 4 deletions runtime/integration-tests/src/generic/cases/investments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ mod common {

pub fn initialize_state_for_investments<E: Env<T>, T: Runtime>() -> E {
let mut env = E::from_parachain_storage(
Genesis::<T>::default()
.add(genesis::balances(T::ExistentialDeposit::get() + FOR_FEES))
.add(genesis::assets(vec![Box::new(Usd6)]))
.add(genesis::tokens(vec![(Usd6.id(), Usd6.ed())]))
Genesis::default()
.add(genesis::balances::<T>(
T::ExistentialDeposit::get() + FOR_FEES,
))
.add(genesis::assets::<T>(vec![Box::new(Usd6)]))
.add(genesis::tokens::<T>(vec![(Usd6.id(), Usd6.ed())]))
.storage(),
);

Expand Down
Loading

0 comments on commit fb20056

Please sign in to comment.