Skip to content

Commit

Permalink
Merge pull request #748 from galacticcouncil/fix_integration_tests
Browse files Browse the repository at this point in the history
fix: integration tests
  • Loading branch information
Roznovjak authored Jan 19, 2024
2 parents 7f690d5 + b86cf84 commit 98bd2f1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.16.10"
version = "1.16.11"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/dca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,7 @@ mod with_onchain_route {
let fee = Currencies::free_balance(DOT, &Treasury::account_id());
assert!(fee > 0, "The treasury did not receive the fee");

assert_balance!(ALICE.into(), HDX, alice_init_hdx_balance + 278060378846663);
assert_balance!(ALICE.into(), HDX, alice_init_hdx_balance + 277_875_160_724_971);
assert_reserved_balance!(&ALICE.into(), DOT, dca_budget - amount_to_sell - fee);
});
}
Expand Down
58 changes: 30 additions & 28 deletions integration-tests/src/referrals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn trading_in_omnipool_should_transfer_portion_of_fee_to_reward_pot() {
0
));
let pot_balance = Currencies::free_balance(DAI, &Referrals::pot_account_id());
assert_eq!(pot_balance, 28_540_796_051_302_768);
assert_eq!(pot_balance, 29_307_364_722_907_532);
});
}

Expand All @@ -67,7 +67,7 @@ fn buying_in_omnipool_should_transfer_portion_of_asset_out_fee_to_reward_pot() {
u128::MAX,
));
let pot_balance = Currencies::free_balance(DAI, &Referrals::pot_account_id());
assert_eq!(pot_balance, 29_794_264_670_024_389);
assert_eq!(pot_balance, 30_594_591_369_789_397);
});
}

Expand Down Expand Up @@ -113,7 +113,7 @@ fn trading_in_omnipool_should_increase_referrer_shares() {
0
));
let referrer_shares = Referrals::referrer_shares::<AccountId>(ALICE.into());
assert_eq!(referrer_shares, 128_499_283);
assert_eq!(referrer_shares, 131_950_592);
});
}
#[test]
Expand All @@ -135,7 +135,7 @@ fn trading_in_omnipool_should_increase_trader_shares() {
0
));
let trader_shares = Referrals::trader_shares::<AccountId>(BOB.into());
assert_eq!(trader_shares, 256_998_567);
assert_eq!(trader_shares, 263_901_185);
});
}
#[test]
Expand All @@ -156,8 +156,9 @@ fn trading_in_omnipool_should_increase_external_shares() {
1_000_000_000_000,
0
));
let external_shares = Referrals::trader_shares::<AccountId>(Staking::pot_account_id().into());
assert_eq!(external_shares, 1_067_610_243_609);

let external_shares = Referrals::trader_shares::<AccountId>(Staking::pot_account_id());
assert_eq!(external_shares, 1_096_284_866_630);
});
}

Expand All @@ -180,7 +181,7 @@ fn trading_in_omnipool_should_increase_total_shares_correctly() {
0
));
let total_shares = Referrals::total_shares();
assert_eq!(total_shares, 1_067_995_741_459);
assert_eq!(total_shares, 1_096_680_718_407);
});
}

Expand Down Expand Up @@ -246,7 +247,7 @@ fn trading_in_omnipool_should_transfer_some_portion_of_fee_when_no_code_linked()
0
));
let pot_balance = Currencies::free_balance(DAI, &Referrals::pot_account_id());
assert_eq!(pot_balance, 28_540_796_051_302_769);
assert_eq!(pot_balance, 29_307_364_722_907_532);
let external_shares = Referrals::trader_shares::<AccountId>(Staking::pot_account_id());
let total_shares = Referrals::total_shares();
assert_eq!(total_shares, external_shares);
Expand All @@ -272,11 +273,11 @@ fn trading_in_omnipool_should_use_global_rewards_when_not_set() {
0
));
let referrer_shares = Referrals::referrer_shares::<AccountId>(ALICE.into());
assert_eq!(referrer_shares, 128_499_283);
assert_eq!(referrer_shares, 131_950_592);
let trader_shares = Referrals::trader_shares::<AccountId>(BOB.into());
assert_eq!(trader_shares, 256_998_567);
assert_eq!(trader_shares, 263_901_185);
let external_shares = Referrals::trader_shares::<AccountId>(Staking::pot_account_id());
assert_eq!(external_shares, 1_067_610_243_609);
assert_eq!(external_shares, 1_096_284_866_630);
let total_shares = Referrals::total_shares();
assert_eq!(total_shares, referrer_shares + trader_shares + external_shares);
});
Expand Down Expand Up @@ -311,11 +312,11 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() {
0
));
let referrer_shares = Referrals::referrer_shares::<AccountId>(ALICE.into());
assert_eq!(referrer_shares, 51_399_713);
assert_eq!(referrer_shares, 52_780_237);
let trader_shares = Referrals::trader_shares::<AccountId>(BOB.into());
assert_eq!(trader_shares, 25_699_856);
assert_eq!(trader_shares, 26_390_118);
let external_shares = Referrals::trader_shares::<AccountId>(Staking::pot_account_id());
assert_eq!(external_shares, 1_066_967_747_190);
assert_eq!(external_shares, 1_095_625_113_667);
let total_shares = Referrals::total_shares();
assert_eq!(total_shares, referrer_shares + trader_shares + external_shares);
});
Expand All @@ -342,19 +343,19 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() {
who: BOB.into(),
asset_in: DAI,
asset_out: HDX,
amount_in: 26_831_707_982_513_510,
amount_in: 26_835_579_541_620_354,
amount_out: 1_000_000_000_000,
hub_amount_in: 1_209_571_666,
hub_amount_out: 1_208_966_881,
asset_fee_amount: 2_650_003_961,
protocol_fee_amount: 604785,
hub_amount_in: 1_209_746_177,
hub_amount_out: 1_209_141_304,
asset_fee_amount: 2_794_789_078,
protocol_fee_amount: 604_873,
}
.into()]);

let ref_dai_balance = Currencies::free_balance(DAI, &ref_account);
let staking_balance = Currencies::free_balance(HDX, &staking_acc);
assert_eq!(ref_dai_balance.abs_diff(orig_balance), 0);
assert_eq!(staking_balance.abs_diff(stak_orig_balance), 2_650_003_960);
assert_eq!(staking_balance.abs_diff(stak_orig_balance), 2_794_789_077);
});
}

Expand All @@ -379,18 +380,18 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() {
who: BOB.into(),
asset_in: HDX,
asset_out: DAI,
amount_in: 37_504_158_320_270,
amount_in: 37_506_757_329_085,
amount_out: 1_000_000_000_000_000_000,
hub_amount_in: 45219585307,
hub_amount_out: 45196975515,
asset_fee_amount: 2_575_616_759_455_040,
protocol_fee_amount: 22609792,
hub_amount_in: 45_222_713_080,
hub_amount_out: 45_200_101_724,
asset_fee_amount: 2_644_977_450_514_458,
protocol_fee_amount: 22_611_356,
}
.into()]);

let ref_dai_balance = Currencies::free_balance(DAI, &ref_account);
let staking_balance = Currencies::free_balance(HDX, &staking_acc);
assert_eq!(ref_dai_balance.abs_diff(orig_balance), 2_575_616_759_455_040 / 2 - 1);
assert_eq!(ref_dai_balance.abs_diff(orig_balance), 2_644_977_450_514_458 / 2 - 1);
assert_eq!(staking_balance.abs_diff(stak_orig_balance), 0);
});
}
Expand All @@ -407,8 +408,9 @@ fn trading_in_omnipool_should_increase_staking_shares_when_no_code_linked() {
0
));
let staking_acc = Staking::pot_account_id();
let staking_shares = Referrals::trader_shares::<AccountId>(staking_acc.into());
assert_eq!(staking_shares, 1_067_995_741_461);

let staking_shares = Referrals::trader_shares::<AccountId>(staking_acc);
assert_eq!(staking_shares, 1_096_680_718_408);
let total_shares = Referrals::total_shares();
assert_eq!(total_shares, staking_shares);
});
Expand Down

0 comments on commit 98bd2f1

Please sign in to comment.