Skip to content

Commit

Permalink
Fix fee tests (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea212 committed Aug 7, 2023
1 parent caea6d7 commit 5f2b4ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
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

0 comments on commit 5f2b4ad

Please sign in to comment.