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

Optimising integration tests #1079

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
295 changes: 10 additions & 285 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cargo-features = ["resolver"]
members = [
"integration-tests/bifrost-kusama",
"integration-tests/bifrost-polkadot",
"integration-tests/common",
"node/cli",
"node/rpc",
"node/service",
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/bifrost-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ edition = "2021"

[dependencies]
env_logger = "0.10.0"
log = { version = "0.4.17" }
hex-literal = "0.3.1"
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }

# Substrate
Expand All @@ -18,6 +20,7 @@ pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", branch = "
pallet-asset-conversion = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false}
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false}
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false}
pallet-staking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false}

# Polkadot
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false}
Expand All @@ -40,3 +43,6 @@ bifrost-vtoken-voting = { path = "../../pallets/vtoken-voting" }
bifrost-primitives = { path = "../../primitives" }
bifrost-asset-registry = { path = "../../pallets/asset-registry" }
bifrost-kusama-runtime = { path = "../../runtime/bifrost-kusama" }
bifrost-runtime-common = { path = "../../runtime/common" }
orml-traits = "0.4.1-dev"
orml-tokens = "0.4.1-dev"
12 changes: 8 additions & 4 deletions integration-tests/bifrost-kusama/src/account_id.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use crate::kusama_integration_tests::*;
use frame_support::PalletId;
use polkadot_parachain::primitives::{Id as ParaId, Sibling};
use integration_tests_common::{
impls::{AccountId, ParaId},
BifrostKusama,
};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::{app_crypto::Ss58Codec, traits::AccountIdConversion};
use xcm_emulator::TestExt;

pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"bf/trsry");
pub const BIFROST_CROWDLOAN_ID: PalletId = PalletId(*b"bf/salp#");
Expand All @@ -24,7 +28,7 @@ pub const SYSTEM_MAKER_PALLET_ID: PalletId = PalletId(*b"bf/sysmk");

#[test]
fn parachain_account_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(
<ParaId as AccountIdConversion<AccountId>>::into_account_truncating(&ParaId::from(
2001
Expand All @@ -48,7 +52,7 @@ fn parachain_account_should_work() {

#[test]
fn pallet_id_account_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(
<PalletId as AccountIdConversion<AccountId>>::into_account_truncating(
&TREASURY_PALLET_ID
Expand Down
14 changes: 8 additions & 6 deletions integration-tests/bifrost-kusama/src/dollor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
use bifrost_kusama_runtime::Runtime;
use bifrost_primitives::{CurrencyId, TokenSymbol::*};
use bifrost_runtime_common::{cent, dollar, micro, microcent, milli, millicent};
use integration_tests_common::BifrostKusama;
use xcm_emulator::TestExt;

const DECIMAL_18: u128 = 1_000_000_000_000_000_000;
const DECIMAL_12: u128 = 1_000_000_000_000;
const DOT_DECIMALS: u128 = 10_000_000_000;

#[test]
fn dollar_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(dollar::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12);
assert_eq!(dollar::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12);
assert_eq!(dollar::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12);
Expand All @@ -43,7 +45,7 @@ fn dollar_should_work() {

#[test]
fn milli_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(milli::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12 / 1000);
assert_eq!(milli::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12 / 1000);
assert_eq!(milli::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12 / 1000);
Expand All @@ -60,7 +62,7 @@ fn milli_should_work() {

#[test]
fn micro_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(micro::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12 / 1_000_000);
assert_eq!(micro::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12 / 1_000_000);
assert_eq!(micro::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12 / 1_000_000);
Expand All @@ -77,7 +79,7 @@ fn micro_should_work() {

#[test]
fn cent_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(cent::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12 / 100);
assert_eq!(cent::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12 / 100);
assert_eq!(cent::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12 / 100);
Expand All @@ -94,7 +96,7 @@ fn cent_should_work() {

#[test]
fn millicent_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(millicent::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12 / 100_000);
assert_eq!(millicent::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12 / 100_000);
assert_eq!(millicent::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12 / 100_000);
Expand All @@ -111,7 +113,7 @@ fn millicent_should_work() {

#[test]
fn microcent_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
assert_eq!(microcent::<Runtime>(CurrencyId::Token(ASG)), DECIMAL_12 / 100_000_000);
assert_eq!(microcent::<Runtime>(CurrencyId::Token(BNC)), DECIMAL_12 / 100_000_000);
assert_eq!(microcent::<Runtime>(CurrencyId::Token(KUSD)), DECIMAL_12 / 100_000_000);
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/bifrost-kusama/src/general_key.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use bifrost_primitives::{CurrencyId, TokenSymbol};
use codec::Encode;
use integration_tests_common::BifrostKusama;
use sp_runtime::BoundedVec;
use xcm::prelude::*;
use xcm_emulator::TestExt;

#[test]
fn dollar_should_work() {
sp_io::TestExternalities::default().execute_with(|| {
BifrostKusama::execute_with(|| {
let id = CurrencyId::Token(TokenSymbol::KSM);
assert_eq!(
Junction::from(BoundedVec::try_from(id.encode()).unwrap()),
Expand Down
134 changes: 0 additions & 134 deletions integration-tests/bifrost-kusama/src/kusama_cross_chain_transact.rs

This file was deleted.

Loading