Skip to content
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
16 changes: 16 additions & 0 deletions runtime/integration-tests/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ fn test_authority_module() {
#[cfg(feature = "with-karura-runtime")]
const AUTHORITY_ORIGIN_ID: u8 = 60u8;

#[cfg(feature = "with-acala-runtime")]
const AUTHORITY_ORIGIN_ID: u8 = 60u8;

ExtBuilder::default()
.balances(vec![
(AccountId::from(ALICE), USD_CURRENCY, 1_000 * dollar(USD_CURRENCY)),
Expand Down Expand Up @@ -133,6 +136,12 @@ fn test_authority_module() {
Some([AUTHORITY_ORIGIN_ID, 32, 28, 0, 0, 0, 0, 1, 0, 0, 0].to_vec()),
Err(DispatchError::BadOrigin),
)));
#[cfg(feature = "with-acala-runtime")]
System::assert_last_event(Event::Scheduler(pallet_scheduler::Event::<Runtime>::Dispatched(
(OneDay::get() + 1, 1),
Some([AUTHORITY_ORIGIN_ID, 32, 28, 0, 0, 0, 0, 1, 0, 0, 0].to_vec()),
Err(DispatchError::BadOrigin),
)));

let seven_days_later = one_day_later + SevenDays::get() + 1;

Expand Down Expand Up @@ -161,6 +170,13 @@ fn test_authority_module() {
Ok(()),
)));

#[cfg(feature = "with-acala-runtime")]
System::assert_last_event(Event::Scheduler(pallet_scheduler::Event::<Runtime>::Dispatched(
(seven_days_later, 0),
Some([AUTHORITY_ORIGIN_ID, 225, 196, 0, 0, 0, 0, 2, 0, 0, 0].to_vec()),
Ok(()),
)));

// with_delayed_origin = false
assert_ok!(Authority::schedule_dispatch(
Origin::root(),
Expand Down
12 changes: 8 additions & 4 deletions runtime/integration-tests/src/homa_lite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ fn homa_lite_mint_works() {
let liquid_amount_1 = 49_974_999_500_250;
#[cfg(feature = "with-karura-runtime")]
let liquid_amount_1 = 4_997_499_000_500_000;
#[cfg(feature = "with-acala-runtime")]
let liquid_amount_1 = 49_974_990_005_000;

assert_ok!(HomaLite::mint(Origin::signed(alice()), amount));
assert_eq!(Currencies::free_balance(LIQUID_CURRENCY, &alice()), liquid_amount_1);
Expand All @@ -72,12 +74,16 @@ fn homa_lite_mint_works() {
assert_eq!(new_liquid_issuance, 10_049_974_999_500_250);
#[cfg(feature = "with-karura-runtime")]
assert_eq!(new_liquid_issuance, 1_004_997_499_000_500_000);
#[cfg(feature = "with-acala-runtime")]
assert_eq!(new_liquid_issuance, 10_049_974_990_005_000);

// liquid = (amount - MintFee) * (new_liquid_issuance / new_staking_total) * (1 - MaxRewardPerEra)
#[cfg(feature = "with-mandala-runtime")] // Mandala uses DOT, which has 10 d.p. accuracy.
let liquid_amount_2 = 49_974_875_181_840;
#[cfg(feature = "with-karura-runtime")] // Karura uses KSM, which has 12 d.p. accuracy.
let liquid_amount_2 = 4_997_486_563_940_292;
#[cfg(feature = "with-acala-runtime")] // Acala uses DOT, which has 10 d.p. accuracy.
let liquid_amount_2 = 49_974_865_639_397;

assert_ok!(HomaLite::mint(Origin::signed(alice()), amount));
System::assert_last_event(Event::HomaLite(module_homa_lite::Event::Minted(
Expand All @@ -93,6 +99,8 @@ fn homa_lite_mint_works() {
Currencies::free_balance(LIQUID_CURRENCY, &alice()),
9_994_985_564_440_292
);
#[cfg(feature = "with-acala-runtime")]
assert_eq!(Currencies::free_balance(LIQUID_CURRENCY, &alice()), 99_949_855_644_397);
});
}

Expand Down Expand Up @@ -321,10 +329,6 @@ mod karura_only_tests {
let homa_lite_sub_account: AccountId =
hex_literal::hex!["d7b8926b326dd349355a9a7cca6606c1e0eb6fd2b506066b518c7155ff0d8297"].into();
KusamaNet::execute_with(|| {
assert_ok!(kusama_runtime::XcmPallet::force_default_xcm_version(
kusama_runtime::Origin::root(),
Some(0)
));
// Transfer some KSM into the parachain.
assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets(
kusama_runtime::Origin::signed(ALICE.into()),
Expand Down
79 changes: 65 additions & 14 deletions runtime/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,98 @@

#![cfg(test)]

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod setup;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
// TODO: blocked by BaseCallFilter on acala-runtime
#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime"))]
mod authority;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod dex;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod evm;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod homa_lite;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod honzon;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod nft;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod prices;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
// TODO: blocked by BaseCallFilter on acala-runtime
#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime"))]
mod proxy;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod runtime;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod session_manager;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod treasury;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod vesting;

#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime",))]
#[cfg(any(
feature = "with-mandala-runtime",
feature = "with-karura-runtime",
feature = "with-acala-runtime"
))]
mod weights;

// TODO: polkadot_runtime not support XCM
#[cfg(feature = "with-karura-runtime")]
mod relaychain;
41 changes: 35 additions & 6 deletions runtime/integration-tests/src/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::setup::*;
use module_prices::RealTimePriceProvider;
use module_support::PriceProvider;

#[cfg(any(feature = "with-karura-runtime"))]
#[test]
fn test_default_liquid_currency_price() {
ExtBuilder::default()
Expand All @@ -38,12 +37,37 @@ fn test_default_liquid_currency_price() {

set_oracle_price(vec![(RELAY_CHAIN_CURRENCY, relaychain_price)]);

assert_eq!(
RealTimePriceProvider::<Runtime>::get_relative_price(RELAY_CHAIN_CURRENCY, USD_CURRENCY),
Some(relaychain_price)
);
#[cfg(any(feature = "with-mandala-runtime", feature = "with-acala-runtime"))]
{
assert_eq!(
RealTimePriceProvider::<Runtime>::get_price(RELAY_CHAIN_CURRENCY),
Some(Price::saturating_from_integer(1_000_000_000u128))
);
assert_eq!(
RealTimePriceProvider::<Runtime>::get_price(LIQUID_CURRENCY),
Some(Price::saturating_from_integer(100_000_000u128))
);
}
#[cfg(feature = "with-karura-runtime")]
{
assert_eq!(
RealTimePriceProvider::<Runtime>::get_price(RELAY_CHAIN_CURRENCY),
Some(Price::saturating_from_integer(10_000_000u128))
);
assert_eq!(
RealTimePriceProvider::<Runtime>::get_price(LIQUID_CURRENCY),
Some(Price::saturating_from_integer(1_000_000u128))
);
}

let default_ratio = DefaultExchangeRate::get();

#[cfg(any(feature = "with-mandala-runtime", feature = "with-acala-runtime"))]
assert_eq!(
RealTimePriceProvider::<Runtime>::get_relative_price(LIQUID_CURRENCY, USD_CURRENCY),
Some(relaychain_price * default_ratio * 100.into())
);
#[cfg(feature = "with-karura-runtime")]
assert_eq!(
RealTimePriceProvider::<Runtime>::get_relative_price(LIQUID_CURRENCY, USD_CURRENCY),
Some(relaychain_price * default_ratio)
Expand All @@ -56,7 +80,6 @@ fn test_default_liquid_currency_price() {
});
}

#[cfg(any(feature = "with-karura-runtime"))]
#[test]
fn test_update_liquid_currency_price() {
ExtBuilder::default()
Expand All @@ -82,6 +105,12 @@ fn test_update_liquid_currency_price() {
110 * dollar(RELAY_CHAIN_CURRENCY)
));

#[cfg(feature = "with-mandala-runtime")]
assert_eq!(
RealTimePriceProvider::<Runtime>::get_relative_price(LIQUID_CURRENCY, RELAY_CHAIN_CURRENCY),
Some(Ratio::saturating_from_rational(100, 1000))
);
#[cfg(any(feature = "with-karura-runtime", feature = "with-acala-runtime"))]
assert_eq!(
RealTimePriceProvider::<Runtime>::get_relative_price(LIQUID_CURRENCY, RELAY_CHAIN_CURRENCY),
Some(Ratio::saturating_from_rational(110, 1000))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ use xcm_emulator::TestExt;
#[test]
fn transfer_from_relay_chain() {
KusamaNet::execute_with(|| {
assert_ok!(kusama_runtime::XcmPallet::force_default_xcm_version(
kusama_runtime::Origin::root(),
Some(0)
));
assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets(
kusama_runtime::Origin::signed(ALICE.into()),
Box::new(Parachain(2000).into().into()),
Expand Down
15 changes: 7 additions & 8 deletions runtime/integration-tests/src/relaychain/kusama_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ pub fn kusama_ext() -> sp_io::TestExternalities {
.assimilate_storage(&mut t)
.unwrap();

// TODO: https://github.com/paritytech/polkadot/pull/4116
// remove force_default_xcm_version
//pallet_xcm::GenesisConfig::<Runtime> {
// safe_xcm_version: Some(2),
// ..Default::default()
//}
//.assimilate_storage(&mut t)
//.unwrap();
<pallet_xcm::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_xcm::GenesisConfig {
safe_xcm_version: Some(2),
},
&mut t,
)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
Expand Down
29 changes: 0 additions & 29 deletions runtime/integration-tests/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,35 +202,6 @@ fn currency_id_convert() {
CurrencyIdConvert::convert(MultiLocation::sibling_parachain_general_key(id, LKSM.encode())),
None
);
assert_eq!(
CurrencyIdConvert::convert(MultiLocation::sibling_parachain_general_key(
parachains::bifrost::ID,
parachains::bifrost::BNC_KEY.to_vec()
)),
None
);
assert_eq!(
CurrencyIdConvert::convert(MultiLocation::sibling_parachain_general_key(
parachains::bifrost::ID,
parachains::bifrost::VSKSM_KEY.to_vec()
)),
None
);

assert_eq!(
CurrencyIdConvert::convert(BNC),
Some(MultiLocation::sibling_parachain_general_key(
parachains::bifrost::ID,
parachains::bifrost::BNC_KEY.to_vec()
))
);
assert_eq!(
CurrencyIdConvert::convert(VSKSM),
Some(MultiLocation::sibling_parachain_general_key(
parachains::bifrost::ID,
parachains::bifrost::VSKSM_KEY.to_vec()
))
);

let native_currency: MultiAsset = (
MultiLocation::sibling_parachain_general_key(id, NATIVE_CURRENCY.encode()),
Expand Down
18 changes: 9 additions & 9 deletions runtime/integration-tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ pub use acala_imports::*;
#[cfg(feature = "with-acala-runtime")]
mod acala_imports {
pub use acala_runtime::{
constants::parachains, create_x2_parachain_multilocation, get_all_module_accounts, AcalaFoundationAccounts,
AcalaOracle, AccountId, AuctionManager, Authority, AuthoritysOriginId, Balance, Balances, BlockNumber, Call,
CdpEngine, CdpTreasury, CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, CurrencyIdConvert,
DataDepositPerByte, DefaultExchangeRate, Dex, EmergencyShutdown, Event, EvmAccounts, ExistentialDeposits, Get,
GetNativeCurrencyId, HomaLite, Honzon, Loans, MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit,
NetworkId, NftPalletId, OneDay, Origin, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem,
Perbill, Permill, Proxy, ProxyType, RelayChainBlockNumberProvider, RelayChainSovereignSubAccount, Runtime,
Scheduler, Session, SessionManager, SevenDays, System, Timestamp, TokenSymbol, Tokens, TreasuryPalletId,
Utility, Vesting, XTokens, XcmConfig, XcmExecutor, XcmUnbondFee, NFT,
create_x2_parachain_multilocation, get_all_module_accounts, AcalaFoundationAccounts, AcalaOracle, AccountId,
AuctionManager, Authority, AuthoritysOriginId, Balance, Balances, BlockNumber, Call, CdpEngine, CdpTreasury,
CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, CurrencyIdConvert, DataDepositPerByte,
DefaultExchangeRate, Dex, EmergencyShutdown, Event, EvmAccounts, ExistentialDeposits, Get, GetNativeCurrencyId,
HomaLite, Honzon, Loans, MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit, NetworkId,
NftPalletId, OneDay, Origin, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, Proxy, ProxyType,
RelayChainBlockNumberProvider, RelayChainSovereignSubAccount, Runtime, Scheduler, Session, SessionManager,
SevenDays, System, Timestamp, TokenSymbol, Tokens, TreasuryPalletId, Utility, Vesting, XTokens, XcmConfig,
XcmExecutor, XcmUnbondFee, NFT,
};
pub use frame_support::parameter_types;
pub use primitives::TradingPair;
Expand Down
8 changes: 4 additions & 4 deletions runtime/integration-tests/src/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use crate::setup::*;
fn treasury_should_take_xcm_execution_revenue() {
ExtBuilder::default().build().execute_with(|| {
let dot_amount = 1000 * dollar(RELAY_CHAIN_CURRENCY);
#[cfg(feature = "with-mandala-runtime")]
#[cfg(feature = "with-mandala-runtime")] // Mandala uses DOT, which has 10 d.p. accuracy.
let actual_amount = 9_999_999_760_000;
#[cfg(feature = "with-karura-runtime")]
let actual_amount = 999_999_952_000_000;
#[cfg(feature = "with-acala-runtime")]
#[cfg(feature = "with-karura-runtime")] // Karura uses KSM, which has 12 d.p. accuracy.
let actual_amount = 999_999_952_000_000;
#[cfg(feature = "with-acala-runtime")] // Acala uses DOT, which has 10 d.p. accuracy.
let actual_amount = 9_999_952_000_000;

#[cfg(feature = "with-mandala-runtime")]
let shallow_weight = 3_000_000;
Expand Down