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

Fix fee tests #1070

Merged
merged 3 commits into from
Aug 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use orml_traits::MultiCurrency;
use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, NetworkId};
use xcm_emulator::{Limited, TestExt};
use zeitgeist_primitives::{
constants::BalanceFractionalDecimals,
constants::{BalanceFractionalDecimals, BASE},
types::{CustomMetadata, XcmMetadata},
};

Expand Down Expand Up @@ -87,9 +87,6 @@ fn transfer_ztg_to_sibling() {
// Verify that BOB now has (amount transferred - fee)
assert_eq!(current_balance, transfer_amount - ztg_fee());

// Sanity check for the actual amount BOB ends up with
assert_eq!(current_balance, 49_907_304_000);

// Verify that fees (of foreign currency) have been put into treasury
assert_eq!(
Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()),
Expand Down Expand Up @@ -352,7 +349,7 @@ fn transfer_roc_to_relay_chain() {
});

RococoNet::execute_with(|| {
assert_eq!(rococo_runtime::Balances::free_balance(&BOB), 999_988_806_429);
assert_eq!(rococo_runtime::Balances::free_balance(&BOB), 999_988_690_728);
});
}

Expand Down Expand Up @@ -419,10 +416,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() {
let custom_fee = calc_fee(default_per_second(10) * 10);

// Verify that BOB now has (amount transferred - fee)
assert_eq!(current_balance, transfer_amount - custom_fee);

// Sanity check for the actual amount BOB ends up with
assert_eq!(current_balance, 49_073_040_000);
assert_eq!(current_balance, transfer_amount - ztg_fee() * fee_factor / BASE);

// Verify that fees (of foreign currency) have been put into treasury
assert_eq!(
Expand All @@ -434,8 +428,8 @@ fn transfer_ztg_to_sibling_with_custom_fee() {

#[test]
fn test_total_fee() {
assert_eq!(ztg_fee(), 92_696_000);
assert_eq!(roc_fee(), 9_269_600_000);
assert_eq!(ztg_fee(), 80_824_000);
assert_eq!(roc_fee(), 8_082_400_000);
}

#[inline]
Expand Down
13 changes: 5 additions & 8 deletions runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use orml_traits::MultiCurrency;
use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, NetworkId};
use xcm_emulator::{Limited, TestExt};
use zeitgeist_primitives::{
constants::BalanceFractionalDecimals,
constants::{BalanceFractionalDecimals, BASE},
types::{CustomMetadata, XcmMetadata},
};

Expand Down Expand Up @@ -87,9 +87,6 @@ fn transfer_ztg_to_sibling() {
// Verify that BOB now has (amount transferred - fee)
assert_eq!(current_balance, transfer_amount - ztg_fee());

// Sanity check for the actual amount BOB ends up with
assert_eq!(current_balance, 49_907_304_000);

// Verify that fees (of foreign currency) have been put into treasury
assert_eq!(
Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()),
Expand Down Expand Up @@ -470,7 +467,7 @@ fn transfer_dot_to_relay_chain() {
});

PolkadotNet::execute_with(|| {
assert_eq!(polkadot_runtime::Balances::free_balance(&BOB), 19_573_469_824);
assert_eq!(polkadot_runtime::Balances::free_balance(&BOB), 19_578_565_860);
});
}

Expand Down Expand Up @@ -540,7 +537,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() {
assert_eq!(current_balance, transfer_amount - custom_fee);

// Sanity check for the actual amount BOB ends up with
assert_eq!(current_balance, 49_073_040_000);
assert_eq!(current_balance, transfer_amount - ztg_fee() * fee_factor / BASE);

// Verify that fees (of foreign currency) have been put into treasury
assert_eq!(
Expand All @@ -552,8 +549,8 @@ fn transfer_ztg_to_sibling_with_custom_fee() {

#[test]
fn test_total_fee() {
assert_eq!(ztg_fee(), 92_696_000);
assert_eq!(dot_fee(), 92_696_000);
assert_eq!(ztg_fee(), 80_824_000);
assert_eq!(dot_fee(), 80_824_000);
}

#[inline]
Expand Down
Loading