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

Replace Currency->fungible trait migration for time-release pallet #1818

Merged
merged 14 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
35 changes: 18 additions & 17 deletions 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 e2e/package-lock.json

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

3 changes: 2 additions & 1 deletion pallets/time-release/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
sp-core = { workspace = true }
log = { workspace = true, default-features = false }

[dev-dependencies]
chrono = { workspace = true }
pallet-balances = { workspace = true }
sp-core = { workspace = true }
common-primitives = { default-features = false, path = "../../common/primitives" }

[features]
Expand Down
10 changes: 4 additions & 6 deletions pallets/time-release/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use super::*;
use crate::Pallet as TimeReleasePallet;

use frame_benchmarking::{account, benchmarks, whitelist_account, whitelisted_caller};
use frame_support::traits::{Currency, Imbalance};
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use sp_runtime::{traits::TrailingZeroInput, SaturatedConversion};
use sp_std::prelude::*;
Expand All @@ -17,9 +16,8 @@ pub type Schedule<T> = ReleaseSchedule<BlockNumberFor<T>, BalanceOf<T>>;
const SEED: u32 = 0;

fn set_balance<T: Config>(who: &T::AccountId, balance: BalanceOf<T>) {
let deposit_result = T::Currency::deposit_creating(who, balance.saturated_into());
let actual_deposit = deposit_result.peek();
assert_eq!(balance, actual_deposit);
let actual_deposit = T::Currency::mint_into(&who, balance.saturated_into());
assert_eq!(balance, actual_deposit.unwrap());
}

fn lookup_of_account<T: Config>(
Expand Down Expand Up @@ -76,7 +74,7 @@ benchmarks! {
}: _(RawOrigin::Signed(to.clone()))
verify {
assert_eq!(
T::Currency::free_balance(&to),
T::Currency::balance(&to),
schedule.total_amount().unwrap() * BalanceOf::<T>::from(i) ,
);
}
Expand All @@ -103,7 +101,7 @@ benchmarks! {
}: _(RawOrigin::Root, to_lookup, schedules)
verify {
assert_eq!(
T::Currency::free_balance(&to),
T::Currency::balance(&to),
schedule.total_amount().unwrap() * BalanceOf::<T>::from(i)
);
}
Expand Down
Loading
Loading