Skip to content

Commit

Permalink
some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Aug 8, 2023
1 parent 387c630 commit d26f3b6
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 65 deletions.
15 changes: 0 additions & 15 deletions modules/currencies/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,25 +331,10 @@ fn force_set_lock_and_force_remove_lock_should_work() {

// do nothing
assert_ok!(Currencies::force_set_lock(RuntimeOrigin::root(), alice(), DOT, 0, ID_1,));
assert_ok!(Currencies::force_set_lock(
RuntimeOrigin::root(),
alice(),
NATIVE_CURRENCY_ID,
0,
ID_1,
));
assert_eq!(
Tokens::locks(&alice(), DOT)[0],
tokens::BalanceLock { id: ID_1, amount: 10 }
);
assert_eq!(
PalletBalances::locks(&alice())[0],
pallet_balances::BalanceLock {
id: ID_1,
amount: 100,
reasons: WithdrawReasons::all().into(),
}
);

// remove lock
assert_noop!(
Expand Down
4 changes: 2 additions & 2 deletions modules/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ fn strict_call_works() {
),
Err(DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(Weight::from_parts(1468769052, 7186)),
actual_weight: Some(Weight::from_parts(1465812680, 7186)),
pays_fee: Pays::Yes
},
error: Error::<Runtime>::NoPermission.into(),
Expand Down Expand Up @@ -2610,7 +2610,7 @@ fn strict_call_works() {
),
Err(DispatchErrorWithPostInfo {
post_info: PostDispatchInfo {
actual_weight: Some(Weight::from_parts(1467812754, 7186)),
actual_weight: Some(Weight::from_parts(1464856382, 7186)),
pays_fee: Pays::Yes
},
error: Error::<Runtime>::StrictCallFailed.into(),
Expand Down
2 changes: 1 addition & 1 deletion runtime/acala/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mod tests {
let q = Balance::from(ExtrinsicBaseWeight::get().ref_time());

assert_eq!(p, 1_000_000_000);
assert_eq!(q, 113_638_000);
assert_eq!(q, 124_414_000);
assert_eq!(p / q, 8)
}
}
6 changes: 3 additions & 3 deletions runtime/integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,12 @@ fn transaction_payment_module_works_with_evm_contract() {
pays_fee: Pays::Yes,
};
let fee = module_transaction_payment::Pallet::<Runtime>::compute_fee(len, &info, 0);
assert_eq!(fee, 2_500_000_880);
assert_eq!(fee, 2500000804);

let surplus_perc = Percent::from_percent(50); // CustomFeeSurplus
let fee_surplus = surplus_perc.mul_ceil(fee);
let fee = fee + fee_surplus;
assert_eq!(fee, 3_750_001_320);
assert_eq!(fee, 3750001206);

// empty_account use payment non wrapped call to charge fee by erc20 fee pool.
assert_eq!(Currencies::free_balance(erc20_token, &sub_account), 0);
Expand Down Expand Up @@ -1146,7 +1146,7 @@ fn create_contract_use_none_native_token_to_charge_storage() {
#[test]
fn evm_limits() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(runtime_common::EvmLimits::<Runtime>::max_gas_limit(), 33_320_706);
assert_eq!(runtime_common::EvmLimits::<Runtime>::max_gas_limit(), 33319509);
assert_eq!(runtime_common::EvmLimits::<Runtime>::max_storage_limit(), 3_670_016);
});
}
Expand Down
48 changes: 24 additions & 24 deletions runtime/integration-tests/src/relaychain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ mod fee_test {
#[cfg(feature = "with-karura-runtime")]
let relay_per_second = karura_runtime::ksm_per_second();
#[cfg(feature = "with-karura-runtime")]
assert_eq!(175_980_000_000, relay_per_second);
assert_eq!(relay_per_second, 175_980_000_000);

#[cfg(feature = "with-acala-runtime")]
let relay_per_second = acala_runtime::dot_per_second();
#[cfg(feature = "with-acala-runtime")]
assert_eq!(1_759_800_000, relay_per_second);
assert_eq!(relay_per_second, 1_759_800_000);

#[cfg(feature = "with-mandala-runtime")]
let relay_per_second = mandala_runtime::dot_per_second();
#[cfg(feature = "with-mandala-runtime")]
assert_eq!(87_990_000_000, relay_per_second);
assert_eq!(relay_per_second, 80370000000);

native_unit_cost(instruction_count, relay_per_second)
}
Expand All @@ -108,15 +108,15 @@ mod fee_test {
#[cfg(feature = "with-karura-runtime")]
let native_per_second = karura_runtime::kar_per_second();
#[cfg(feature = "with-karura-runtime")]
assert_eq!(8_799_000_000_000, native_per_second);
assert_eq!(native_per_second, 8037000000000);
#[cfg(feature = "with-acala-runtime")]
let native_per_second = acala_runtime::aca_per_second();
#[cfg(feature = "with-acala-runtime")]
assert_eq!(8_799_000_000_000, native_per_second);
assert_eq!(native_per_second, 8037000000000);
#[cfg(feature = "with-mandala-runtime")]
let native_per_second = mandala_runtime::aca_per_second();
#[cfg(feature = "with-mandala-runtime")]
assert_eq!(8_799_000_000_000, native_per_second);
assert_eq!(native_per_second, 8037000000000);

native_unit_cost(instruction_count, native_per_second)
}
Expand Down Expand Up @@ -147,43 +147,43 @@ mod fee_test {
#[cfg(feature = "with-karura-runtime")]
#[test]
fn karura_per_second_works() {
assert_eq!(140_784_000, relay_per_second_as_fee(4));
assert_eq!(105_588_000, relay_per_second_as_fee(3));
assert_eq!(7_039_200_000, native_per_second_as_fee(4));
assert_eq!(11_262_720_000, bnc_per_second_as_fee(4));
assert_eq!(relay_per_second_as_fee(4), 140_784_000);
assert_eq!(relay_per_second_as_fee(3), 105_588_000);
assert_eq!(native_per_second_as_fee(4), 7_039_200_000);
assert_eq!(bnc_per_second_as_fee(4), 11_262_720_000);

assert_eq!(7_039_200_000, foreign_per_second_as_fee(4, Balances::minimum_balance()));
assert_eq!(foreign_per_second_as_fee(4, Balances::minimum_balance()), 7_039_200_000);
assert_eq!(
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10),
703_920_000,
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10)
);
}

#[cfg(feature = "with-acala-runtime")]
#[test]
fn acala_per_second_works() {
assert_eq!(1_407_840, relay_per_second_as_fee(4));
assert_eq!(1_055_880, relay_per_second_as_fee(3));
assert_eq!(7_039_200_000, native_per_second_as_fee(4));
assert_eq!(relay_per_second_as_fee(4), 1_407_840);
assert_eq!(relay_per_second_as_fee(3), 1_055_880);
assert_eq!(native_per_second_as_fee(4), 7_039_200_000);

assert_eq!(7_039_200_000, foreign_per_second_as_fee(4, Balances::minimum_balance()));
assert_eq!(foreign_per_second_as_fee(4, Balances::minimum_balance()), 7_039_200_000);
assert_eq!(
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10),
703_920_000,
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10)
);
}

#[cfg(feature = "with-mandala-runtime")]
#[test]
fn mandala_per_second_works() {
assert_eq!(351_960, relay_per_second_as_fee(4));
assert_eq!(263_970, relay_per_second_as_fee(3));
assert_eq!(35_196_000, native_per_second_as_fee(4));
assert_eq!(relay_per_second_as_fee(4), 321480);
assert_eq!(relay_per_second_as_fee(3), 263_970);
assert_eq!(native_per_second_as_fee(4), 35_196_000);

assert_eq!(35_196_000, foreign_per_second_as_fee(4, Balances::minimum_balance()));
assert_eq!(foreign_per_second_as_fee(4, Balances::minimum_balance()), 35_196_000);
assert_eq!(
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10),
3_519_600,
foreign_per_second_as_fee(4, Balances::minimum_balance() / 10)
);
}
}
Expand All @@ -203,12 +203,12 @@ fn weight_to_fee_works() {

let weight: Weight = base_weight.saturating_mul(4);
let fee = WeightToFee::weight_to_fee(&weight);
assert_eq!(1_202_056_716, fee);
assert_eq!(fee, 1_202_056_716);

// transfer_to_relay_chain weight in KusamaNet
let weight: Weight = Weight::from_parts(299_506_000, 0);
let fee = WeightToFee::weight_to_fee(&weight);
assert_eq!(90_005_800, fee);
assert_eq!(fee, 90_005_800);
}

// Polkadot
Expand Down
6 changes: 3 additions & 3 deletions runtime/integration-tests/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ mod mandala_only_tests {

assert_eq!(base_fee, 1_000_000_000);
assert_eq!(len_fee, 50_000_000);
assert_eq!(adjusted_weight_fee, 22_193_280);
assert_eq!(adjusted_weight_fee, 17031845);

let total_fee = base_fee.saturating_add(len_fee).saturating_add(adjusted_weight_fee);
assert_eq!(total_fee, 1_072_193_280);
assert_eq!(total_fee, 1067031845);
});
}

Expand Down Expand Up @@ -416,7 +416,7 @@ mod mandala_only_tests {
bytes.len()
),
Ok(ValidTransaction {
priority: 198_255,
priority: 235960,
requires: vec![],
provides: vec![],
longevity: 18_446_744_073_709_551_615,
Expand Down
27 changes: 13 additions & 14 deletions runtime/integration-tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

pub use codec::{Decode, Encode};
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use frame_support::traits::{GenesisBuild, OnFinalize, OnIdle, OnInitialize};
use frame_support::traits::{OnFinalize, OnIdle, OnInitialize};
pub use frame_support::{assert_noop, assert_ok, traits::Currency};
pub use frame_system::RawOrigin;
use runtime_common::evm_genesis;
Expand All @@ -42,7 +42,8 @@ pub use sp_core::H160;
use sp_io::hashing::keccak_256;
pub use sp_runtime::{
traits::{AccountIdConversion, BadOrigin, BlakeTwo256, Convert, Hash, Zero},
Digest, DigestItem, DispatchError, DispatchResult, FixedPointNumber, FixedU128, MultiAddress, Perbill, Permill,
BuildStorage, Digest, DigestItem, DispatchError, DispatchResult, FixedPointNumber, FixedU128, MultiAddress,
Perbill, Permill,
};

pub use xcm::v3::prelude::*;
Expand Down Expand Up @@ -379,20 +380,18 @@ impl ExtBuilder {
.assimilate_storage(&mut t)
.unwrap();

<parachain_info::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&parachain_info::GenesisConfig {
parachain_id: self.parachain_id.into(),
},
&mut t,
)
parachain_info::GenesisConfig::<Runtime> {
_config: Default::default(),
parachain_id: self.parachain_id.into(),
}
.assimilate_storage(&mut t)
.unwrap();

<pallet_xcm::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_xcm::GenesisConfig {
safe_xcm_version: Some(2),
},
&mut t,
)
pallet_xcm::GenesisConfig::<Runtime> {
_config: Default::default(),
safe_xcm_version: Some(2),
}
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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")] // Mandala uses DOT, which has 10 d.p. accuracy.
let actual_amount = 9_999_999_736_030;
let actual_amount = 9999999758890;
#[cfg(feature = "with-karura-runtime")] // Karura uses KSM, which has 12 d.p. accuracy.
let actual_amount = 999_999_894_412_000;
#[cfg(feature = "with-acala-runtime")] // Acala uses DOT, which has 10 d.p. accuracy.
Expand Down
2 changes: 1 addition & 1 deletion runtime/karura/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ mod tests {
let q = Balance::from(ExtrinsicBaseWeight::get().ref_time());

assert_eq!(p, 1_000_000_000);
assert_eq!(q, 113_638_000);
assert_eq!(q, 124_414_000);
}
}
2 changes: 1 addition & 1 deletion runtime/mandala/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ mod tests {
let q = Balance::from(ExtrinsicBaseWeight::get().ref_time());

assert_eq!(p, 1_000_000_000);
assert_eq!(q, 113_638_000);
assert_eq!(q, 124_414_000);
}
}

0 comments on commit d26f3b6

Please sign in to comment.