Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3302020
Reorganize XCM configuration
sea212 Jun 4, 2022
2bae5e5
Comment XcmConfig and mark necessary changes
sea212 Jun 4, 2022
f172dc4
Implement and configure AssetTransactor
sea212 Jun 5, 2022
a09a350
Configure and comment XCM Barrier
sea212 Jun 16, 2022
8c5f164
Configure XCM IsReserve
sea212 Jun 16, 2022
47179af
Prepare Trader implementation for XcmConfig
sea212 Jun 16, 2022
829491a
Merge branch 'main' into sea212-integrate-aUSD
sea212 Aug 17, 2022
62c05d9
Rename Asset::Ztg -> Asset::ZTG (merge artifact)
sea212 Aug 17, 2022
a204b9a
Merge artifacts, work on XCM impl
sea212 Aug 19, 2022
c735f24
Use MultiAssetTransactor and latest orml pallets
sea212 Sep 25, 2022
15153e8
Add asset registry and AssetProcessor implementation
sea212 Sep 25, 2022
071e50d
Integrate asset-registry, implement fee structure
sea212 Sep 25, 2022
dd80b26
Finalize: XCM Weight/Fee, Trader, Treasury
sea212 Sep 26, 2022
9f2ef67
Fix key conversion & GenesisConfig
sea212 Sep 26, 2022
28517a8
Comment + Cargo fmt
sea212 Sep 26, 2022
45a887a
Merge branch 'main' into sea212-integrate-aUSD
sea212 Sep 26, 2022
49030cb
Include xTokens
sea212 Oct 11, 2022
4f5ab0f
Add integration test environment & XCM test setup
sea212 Oct 31, 2022
c1e2b96
Finalize simulated network preparation
sea212 Nov 1, 2022
49d468e
Add currency conversion tests
sea212 Nov 1, 2022
31933cd
Finalize CurrencyID<>MultiLocation tests
sea212 Nov 2, 2022
208c862
Add helper functions and sibling currency<>location conversion test
sea212 Nov 2, 2022
78b1018
Add relative view trader for ZTG
sea212 Nov 2, 2022
bb30dfa
Extend XCM transfer tests
sea212 Nov 4, 2022
b28542b
Add ZTG -> Sibling -> ZTG test
sea212 Nov 4, 2022
b6a7d92
Read ParaId from ParachainInfo + fix tests
sea212 Nov 5, 2022
5a079b6
Fix KSM <> ZTG XCM tests
sea212 Nov 5, 2022
4e67549
Fix Fee (off by 2000x)
sea212 Nov 5, 2022
a708fb1
Increase ExistentialDeposit & Add Treasury to dust whitelist
sea212 Nov 5, 2022
b7b665b
Fix custom fee calculation
sea212 Nov 5, 2022
d31dcc6
Add custom fee test
sea212 Nov 5, 2022
6cee15d
Finalize XCM integration tests
sea212 Nov 5, 2022
e914d54
Remove unused modules
sea212 Nov 7, 2022
ec00ef2
Add XCM related pallets to common runtime
sea212 Nov 7, 2022
0d460a1
Cleanup code
sea212 Nov 7, 2022
d990634
Add proper XCM configuration to Zeitgeist runtime
sea212 Nov 7, 2022
3e84785
Use ExistentialDeposit directly in integration test
sea212 Nov 8, 2022
857cf74
Add integration tests to Zeitgeist runtime
sea212 Nov 8, 2022
d6030ac
Allow only Kusama as parent on Zeitgeist + Cleanup
sea212 Nov 8, 2022
0ff4e5f
Remove dead code
sea212 Nov 9, 2022
e170adb
Update changelog_for_devs.md
sea212 Nov 9, 2022
a5ed076
Use correct treasury pallet id (as before)
sea212 Nov 17, 2022
7ebe84a
Use unambiguous names for setters
sea212 Nov 17, 2022
fc6ae19
Convert comment to docstring
sea212 Nov 17, 2022
354de95
Fix wrong comment
sea212 Nov 17, 2022
b2c1e1f
Reset emulated testnet in any case
sea212 Nov 22, 2022
0f59db0
Remove unnecessary commas
sea212 Nov 23, 2022
49b54ac
Improve readability of numbers
sea212 Nov 23, 2022
391fc02
Fix docstring
sea212 Nov 23, 2022
b6ef8cc
Remove invalid initial balance (integration test)
sea212 Nov 23, 2022
dab6d11
Improve style
sea212 Nov 24, 2022
884a32d
Use more descriptive function name
sea212 Nov 24, 2022
fdfa04b
Add additional balance guard to xcm tests
sea212 Nov 24, 2022
54d3889
Use ::parachain_id() instead of ::get()
sea212 Nov 24, 2022
37a1536
Reduce nested match depth
sea212 Nov 24, 2022
b503c34
Update changelog
sea212 Nov 24, 2022
b20e13f
Add missing crates to runtime-benchmarks feature
sea212 Nov 24, 2022
21a76e4
Merge branch 'main' into sea212-integrate-aUSD
sea212 Nov 24, 2022
77495ed
Repair build
sea212 Nov 24, 2022
1d31ae0
Satisfy cargo fmt and taplo
sea212 Nov 24, 2022
e153330
Update XCM weight in tests
sea212 Nov 24, 2022
c003dda
Satisfy Clippy
sea212 Nov 24, 2022
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
Prev Previous commit
Next Next commit
Finalize CurrencyID<>MultiLocation tests
  • Loading branch information
sea212 committed Nov 2, 2022
commit 31933cd7c178136e52630f2834e28eb9e44f1989
2 changes: 1 addition & 1 deletion runtime/battery-station/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

#![cfg(test)]

mod xcm;
mod xcm;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

153 changes: 73 additions & 80 deletions runtime/battery-station/src/integration_tests/xcm/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.

use crate::{AccountId, Balance, CurrencyId, Origin, Runtime, System, xcm_config::{asset_registry::CustomMetadata, config::zeitgeist}};
use crate::{
xcm_config::{asset_registry::CustomMetadata, config::zeitgeist},
AccountId, Balance, CurrencyId, Origin, Runtime, System,
};
use frame_support::traits::GenesisBuild;
use orml_traits::asset_registry::AssetMetadata;
use zeitgeist_primitives::types::Asset;
Expand All @@ -30,115 +33,105 @@ pub const BOB: [u8; 32] = [5u8; 32];
pub const PARA_ID_SIBLING: u32 = 3000;

/// IDs that are used to represent tokens from other chains
pub const FOREIGN_ZTG: Asset<u128> = CurrencyId::ForeignAsset(0);
pub const FOREIGN_KSM: Asset<u128> = CurrencyId::ForeignAsset(1);
pub const FOREIGN_SIBLING: Asset<u128> = CurrencyId::ForeignAsset(2);

pub const FOREIGN_ZTG_ID: Asset<u128> = CurrencyId::ForeignAsset(0);
pub const FOREIGN_KSM_ID: Asset<u128> = CurrencyId::ForeignAsset(1);
pub const FOREIGN_SIBLING_ID: Asset<u128> = CurrencyId::ForeignAsset(2);

pub struct ExtBuilder {
balances: Vec<(AccountId, CurrencyId, Balance)>,
parachain_id: u32,
balances: Vec<(AccountId, CurrencyId, Balance)>,
parachain_id: u32,
}

impl Default for ExtBuilder {
fn default() -> Self {
Self {
balances: vec![],
parachain_id: zeitgeist::ID,
}
}
fn default() -> Self {
Self { balances: vec![], parachain_id: zeitgeist::ID }
}
}

impl ExtBuilder {
pub fn balances(mut self, balances: Vec<(AccountId, CurrencyId, Balance)>) -> Self {
self.balances = balances;
self
}

pub fn parachain_id(mut self, parachain_id: u32) -> Self {
self.parachain_id = parachain_id;
self
}

pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
.unwrap();
let native_currency_id = CurrencyId::Ztg;
pallet_balances::GenesisConfig::<Runtime> {
balances: self
.balances
.clone()
.into_iter()
.filter(|(_, currency_id, _)| *currency_id == native_currency_id)
.map(|(account_id, _, initial_balance)| (account_id, initial_balance))
.collect::<Vec<_>>(),
}
.assimilate_storage(&mut t)
.unwrap();

orml_tokens::GenesisConfig::<Runtime> {
balances: self
.balances
.into_iter()
.filter(|(_, currency_id, _)| *currency_id != native_currency_id)
.collect::<Vec<_>>(),
}
.assimilate_storage(&mut t)
.unwrap();

<parachain_info::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&parachain_info::GenesisConfig {
parachain_id: self.parachain_id.into(),
},
&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));
ext
}
pub fn balances(mut self, balances: Vec<(AccountId, CurrencyId, Balance)>) -> Self {
self.balances = balances;
self
}

pub fn parachain_id(mut self, parachain_id: u32) -> Self {
self.parachain_id = parachain_id;
self
}

pub fn build(self) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
let native_currency_id = CurrencyId::Ztg;
pallet_balances::GenesisConfig::<Runtime> {
balances: self
.balances
.clone()
.into_iter()
.filter(|(_, currency_id, _)| *currency_id == native_currency_id)
.map(|(account_id, _, initial_balance)| (account_id, initial_balance))
.collect::<Vec<_>>(),
}
.assimilate_storage(&mut t)
.unwrap();

orml_tokens::GenesisConfig::<Runtime> {
balances: self
.balances
.into_iter()
.filter(|(_, currency_id, _)| *currency_id != native_currency_id)
.collect::<Vec<_>>(),
}
.assimilate_storage(&mut t)
.unwrap();

<parachain_info::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&parachain_info::GenesisConfig { parachain_id: self.parachain_id.into() },
&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));
ext
}
}

pub fn ztg(amount: Balance) -> Balance {
amount * dollar(10)
amount * dollar(10)
}

pub fn sibling(amount: Balance) -> Balance {
foreign(amount, 10)
foreign(amount, 10)
}

pub fn ksm(amount: Balance) -> Balance {
foreign(amount, 12)
foreign(amount, 12)
}

pub fn foreign(amount: Balance, decimals: u32) -> Balance {
amount * dollar(decimals)
amount * dollar(decimals)
}

pub fn dollar(decimals: u32) -> Balance {
10u128.saturating_pow(decimals.into())
10u128.saturating_pow(decimals.into())
}

pub fn sibling_account() -> AccountId {
parachain_account(PARA_ID_SIBLING.into())
parachain_account(PARA_ID_SIBLING.into())
}

pub fn zeitgeist_account() -> AccountId {
parachain_account(zeitgeist::ID)
parachain_account(zeitgeist::ID)
}

fn parachain_account(id: u32) -> AccountId {
use sp_runtime::traits::AccountIdConversion;
use sp_runtime::traits::AccountIdConversion;

polkadot_parachain::primitives::Sibling::from(id).into_account()
}
polkadot_parachain::primitives::Sibling::from(id).into_account()
}
Loading