Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration-tests: Use latest version of fudge-polkadot-v0.9.43 #1590

Merged
merged 18 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
26acfaa
integration-tests: Use latest version of fudge-polkadot-v0.9.43 and a…
cdamian Oct 13, 2023
5f96a9d
integration-tests: Use fudge in development LP tests
cdamian Oct 27, 2023
d22adcc
integration-tests: Drop unnecessary envs and funcs from development t…
cdamian Oct 30, 2023
fce33f8
integration-tests: Add sibling to generic envs, fix LP tests
cdamian Oct 31, 2023
b260429
integration-tests: Adapt LP kusama tests to use the generic framework
cdamian Nov 6, 2023
c1bf32b
integration-tests: Adapt LP polkadot tests to use the generic framework
cdamian Nov 6, 2023
23f44d4
integration-tests: Don't evolve fudge env during creation
cdamian Nov 7, 2023
2b13734
development: Add max holds and max freezes to pallet-balances config.
cdamian Nov 7, 2023
4be8323
integration-tests: Remove unused imports
cdamian Nov 7, 2023
68698bc
integration-tests: Disable liquidity_rewards_runtime_api_works test
cdamian Nov 7, 2023
9612869
investments: Remove commented code
cdamian Nov 7, 2023
bd822d5
development: Remove MaxFreezes const
cdamian Nov 7, 2023
9fc45fb
integration-tests: Handle extrinsics errors, evolve fudge env on init
cdamian Nov 7, 2023
5a1eb05
integration-tests: Add missing LP foreign investment test
cdamian Nov 8, 2023
211bc35
integration-tests: Use correct sibling ID in convert_ausd for centrif…
cdamian Nov 8, 2023
834ef4d
integration-tests: Test LP restricted call on all runtimes
cdamian Nov 8, 2023
34035ab
integration-tests: Update total fee in LP tests
cdamian Nov 8, 2023
db90a0e
clippy: Obey
cdamian Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
integration-tests: Use latest version of fudge-polkadot-v0.9.43 and a…
…dapt testing setup
  • Loading branch information
cdamian committed Nov 7, 2023
commit 26acfaab38f1b1b1c2d032f63de8d68e4d898623
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions runtime/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,10 +10,12 @@ repository = "https://github.com/centrifuge/centrifuge-chain"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
fudge = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v0.9.43" }
fudge-core = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v0.9.43" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need core? Just out of interest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WE should re-export taht ^^

lazy_static = "1.4.0"
serde = { version = "1.0.119" }
tokio = { version = "1.15", features = ["macros"] }
tracing-subscriber = "0.2"
thiserror = "1.0.30"

# Substrate
## Substrate-Frame
Original file line number Diff line number Diff line change
@@ -17,8 +17,12 @@ use cfg_primitives::{parachains, AccountId};
use cfg_types::tokens::CurrencyId;
use cumulus_primitives_core::ParaId;
use frame_support::{traits::GenesisBuild, weights::Weight};
use polkadot_parachain::primitives::Id;
use polkadot_primitives::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_runtime_parachains::configuration::HostConfiguration;
use polkadot_runtime_parachains::{
configuration::HostConfiguration,
paras::{ParaGenesisArgs, ParaKind},
};
use sp_runtime::traits::AccountIdConversion;
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};

@@ -101,6 +105,27 @@ pub fn relay_ext() -> sp_io::TestExternalities {
.assimilate_storage(&mut t)
.unwrap();

<polkadot_runtime_parachains::paras::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(&polkadot_runtime_parachains::paras::GenesisConfig {
paras: vec![
(
Id::from(parachains::polkadot::centrifuge::ID),
ParaGenesisArgs {
genesis_head: Default::default(),
validation_code: vec![1].into(),
para_kind: ParaKind::Parachain,
},
),
(
Id::from(PARA_ID_MOONBEAM),
ParaGenesisArgs {
genesis_head: Default::default(),
validation_code: vec![2].into(),
para_kind: ParaKind::Parachain,
},
),
],
}, &mut t).unwrap();

<pallet_xcm::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_xcm::GenesisConfig {
safe_xcm_version: Some(2),
@@ -110,7 +135,25 @@ pub fn relay_ext() -> sp_io::TestExternalities {
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));

ext.execute_with(|| {
polkadot_runtime_parachains::hrmp::Pallet::<Runtime>::force_open_hrmp_channel(
polkadot_runtime::RuntimeOrigin::root(),
Id::from(parachains::polkadot::centrifuge::ID),
Id::from(PARA_ID_MOONBEAM),
10,
1024,
)
.unwrap();

polkadot_runtime_parachains::hrmp::Pallet::<Runtime>::force_process_hrmp_open(
polkadot_runtime::RuntimeOrigin::root(),
0,
)
.unwrap();

System::set_block_number(1);
});
ext
}

56 changes: 33 additions & 23 deletions runtime/integration-tests/src/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
@@ -25,16 +25,20 @@ use fudge::{
};
use sc_client_api::{HeaderBackend, StorageProof};
use sc_executor::WasmExecutor;
use sc_service::TFullClient;
use sc_service::{TFullBackend, TFullClient};
use sp_api::ProvideRuntimeApi as _;
use sp_consensus_slots::SlotDuration;
use sp_core::{
sr25519,
sr25519::{Pair, Public},
Pair as TraitPair, H256,
};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::{generic::BlockId, traits::IdentifyAccount, BuildStorage, Storage};
use sp_inherents::{CreateInherentDataProviders, InherentData};
use sp_runtime::{
generic::BlockId,
traits::{BlakeTwo256, IdentifyAccount},
BuildStorage, Storage,
};
use tokio::runtime::Handle;

use crate::chain::{
@@ -70,9 +74,13 @@ type ApiRef<'a> = sp_api::ApiRef<'a, <TFullClient<centrifuge::Block, centrifuge:

fn create_builder(
handle: Handle,
genesis: Option<impl BuildStorage>,
genesis: Option<Storage>,
) -> StandaloneBuilder<centrifuge::Block, centrifuge::RuntimeApi, Cidp, Dp> {
let mut state = StateProvider::new(centrifuge::WASM_BINARY.expect("Wasm is build. Qed."));
let mut state =
StateProvider::<TFullBackend<centrifuge::Block>, centrifuge::Block>::empty_default(Some(
centrifuge::WASM_BINARY.expect("Wasm is build. Qed."),
))
.expect("ESSENTIAL: State provider can be created.");
state.insert_storage(
pallet_aura::GenesisConfig::<centrifuge::Runtime> {
authorities: vec![AuraId::from(sr25519::Public([0u8; 32]))],
@@ -108,7 +116,8 @@ fn create_builder(
let instance_id = FudgeInherentTimestamp::create_instance(
std::time::Duration::from_secs(12),
Some(std::time::Duration::from_millis(START_DATE)),
);
)
.expect("ESSENTIAL: Instance ID can be created.");

let cidp = Box::new(move |_parent: H256, ()| {
async move {
@@ -131,29 +140,30 @@ fn create_builder(
Ok((timestamp, slot, relay_para_inherent))
}
});

let dp = |clone_client: Arc<
sc_service::TFullClient<centrifuge::Block, centrifuge::RuntimeApi, TWasmExecutor>,
TFullClient<centrifuge::Block, centrifuge::RuntimeApi, TWasmExecutor>,
>| {
Box::new(move |parent, inherents| {
let client = clone_client.clone();
Box::new(
move |parent: sp_runtime::generic::Header<u32, BlakeTwo256>, inherents| {
let client = clone_client.clone();

async move {
let aura = FudgeAuraDigest::<
centrifuge::Block,
sc_service::TFullClient<
async move {
let aura = FudgeAuraDigest::<
centrifuge::Block,
centrifuge::RuntimeApi,
TWasmExecutor,
>,
>::new(&*client);

let digest = aura.build_digest(&parent, &inherents).await?;
Ok(digest)
}
})
TFullClient<centrifuge::Block, centrifuge::RuntimeApi, TWasmExecutor>,
>::new(&*client)
.expect("ESSENTIAL: Aura digest can be created.");

let digest = aura.build_digest(parent, &inherents).await?;
Ok(digest)
}
},
)
};

StandaloneBuilder::<_, _, Cidp, Dp>::new(init, |client| (cidp, dp(client)))
.expect("ESSENTIAL: Standalone builder can be created.")
}

pub struct ApiEnv {
@@ -167,7 +177,7 @@ impl ApiEnv {
}
}

pub fn new_with_genesis(handle: Handle, genesis: impl BuildStorage) -> Self {
pub fn new_with_genesis(handle: Handle, genesis: Storage) -> Self {
// TODO: Actually make a lot of the utils in pools not specific to pools
// testing. Like init logs, creating builder and so on.
crate::utils::logs::init_logs();
Loading