Skip to content

Commit

Permalink
Companion for #11415 (WeightToFee) (#5525)
Browse files Browse the repository at this point in the history
* Companion for paritytech/substrate#11415

* Rename `WeightToFee::calc()` to `WeightToFee::wight_to_fee()`

* Fix typo

* Fix compile errors

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
  • Loading branch information
nazar-pc authored May 25, 2022
1 parent ee4e2e0 commit 2ff4252
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions relay/kusama/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ mod tests {
fee::WeightToFee,
};
use crate::weights::ExtrinsicBaseWeight;
use frame_support::weights::WeightToFeePolynomial;
use frame_support::weights::WeightToFee as WeightToFeeT;
use runtime_common::MAXIMUM_BLOCK_WEIGHT;

#[test]
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
fn full_block_fee_is_correct() {
// A full block should cost between 1,000 and 10,000 CENTS.
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
assert!(full_block >= 1_000 * CENTS);
assert!(full_block <= 10_000 * CENTS);
}
Expand All @@ -117,7 +117,7 @@ mod tests {
fn extrinsic_base_fee_is_correct() {
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
let y = CENTS / 10;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
Expand Down
4 changes: 2 additions & 2 deletions relay/kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Tests for the Kusama Runtime Configuration

use crate::*;
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
use keyring::Sr25519Keyring::Charlie;
use pallet_transaction_payment::Multiplier;
use parity_scale_codec::Encode;
Expand Down Expand Up @@ -68,7 +68,7 @@ fn payout_weight_portion() {
#[ignore]
fn block_cost() {
let max_block_weight = BlockWeights::get().max_block;
let raw_fee = WeightToFee::calc(&max_block_weight);
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);

println!(
"Full Block weight == {} // WeightToFee(full_block) == {} plank",
Expand Down
6 changes: 3 additions & 3 deletions relay/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ mod tests {
fee::WeightToFee,
};
use crate::weights::ExtrinsicBaseWeight;
use frame_support::weights::WeightToFeePolynomial;
use frame_support::weights::WeightToFee as WeightToFeeT;
use runtime_common::MAXIMUM_BLOCK_WEIGHT;

#[test]
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
fn full_block_fee_is_correct() {
// A full block should cost between 10 and 100 DOLLARS.
let full_block = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
assert!(full_block >= 10 * DOLLARS);
assert!(full_block <= 100 * DOLLARS);
}
Expand All @@ -119,7 +119,7 @@ mod tests {
fn extrinsic_base_fee_is_correct() {
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&ExtrinsicBaseWeight::get());
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
let y = CENTS / 10;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
Expand Down
4 changes: 2 additions & 2 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ sp_api::impl_runtime_apis! {
#[cfg(test)]
mod test_fees {
use super::*;
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT};
use keyring::Sr25519Keyring::Charlie;
use pallet_transaction_payment::Multiplier;
use runtime_common::MinimumMultiplier;
Expand Down Expand Up @@ -2038,7 +2038,7 @@ mod test_fees {
#[ignore]
fn block_cost() {
let max_block_weight = BlockWeights::get().max_block;
let raw_fee = WeightToFee::calc(&max_block_weight);
let raw_fee = WeightToFee::weight_to_fee(&max_block_weight);

println!(
"Full Block weight == {} // WeightToFee(full_block) == {} plank",
Expand Down

0 comments on commit 2ff4252

Please sign in to comment.