Skip to content
Snippets Groups Projects
Commit f7d8319f authored by Benjamin Gallois's avatar Benjamin Gallois Committed by Hugo Trentesaux
Browse files

Deprecate Currency trait (!287)

* deprecate Currency trait
parent 449c1762
No related branches found
No related tags found
1 merge request!287Deprecate Currency trait
Pipeline #38592 passed
......@@ -21,7 +21,7 @@ use super::*;
use codec::Encode;
use frame_benchmarking::v2::*;
use frame_support::traits::{Get, OnFinalize, OnInitialize};
use frame_support::traits::{fungible::Mutate, Get, OnFinalize, OnInitialize};
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use scale_info::prelude::vec;
use sp_runtime::Perbill;
......
......@@ -15,7 +15,7 @@
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use crate::{mock::*, *};
use frame_support::{assert_noop, assert_ok, traits::Currency};
use frame_support::{assert_noop, assert_ok, traits::fungible::Mutate};
// allow request distance evaluation for oneself
#[test]
......@@ -23,7 +23,7 @@ fn test_request_distance_evaluation() {
new_test_ext().execute_with(|| {
run_to_block(1);
// give enough for reserve
Balances::make_free_balance_be(&1, 10_000);
Balances::set_balance(&1, 10_000);
// call request
assert_ok!(Distance::request_distance_evaluation(
......@@ -45,7 +45,7 @@ fn test_request_distance_evaluation_for() {
new_test_ext().execute_with(|| {
run_to_block(1);
// give enough for reserve
Balances::make_free_balance_be(&1, 10_000);
Balances::set_balance(&1, 10_000);
assert_ok!(Identity::create_identity(RuntimeOrigin::signed(1), 5));
assert_ok!(Identity::confirm_identity(
RuntimeOrigin::signed(5),
......@@ -73,7 +73,7 @@ fn test_request_distance_evaluation_non_member() {
new_test_ext().execute_with(|| {
run_to_block(1);
// give enough for reserve
Balances::make_free_balance_be(&5, 10_000);
Balances::set_balance(&5, 10_000);
assert_noop!(
Distance::request_distance_evaluation_for(RuntimeOrigin::signed(5), 1),
......@@ -93,7 +93,7 @@ fn test_request_distance_evaluation_twice() {
new_test_ext().execute_with(|| {
run_to_block(1);
// give enough for reserve
Balances::make_free_balance_be(&1, 10_000);
Balances::set_balance(&1, 10_000);
assert_ok!(Distance::request_distance_evaluation(
RuntimeOrigin::signed(1)
......
......@@ -18,6 +18,7 @@
use super::*;
use frame_benchmarking::{account, v2::*};
use frame_support::traits::fungible::Mutate;
use sp_runtime::traits::One;
fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
......@@ -98,7 +99,7 @@ mod benchmarks {
amount: 10u64.into(),
},
);
let _ = CurrencyOf::<T>::make_free_balance_be(&T::RefundAccount::get(), u32::MAX.into());
let _ = CurrencyOf::<T>::set_balance(&T::RefundAccount::get(), u32::MAX.into());
// The worst-case scenario is when the refund fails
// and can only be triggered if the account is dead,
// in this case by having no balance in the account.
......@@ -119,7 +120,7 @@ mod benchmarks {
#[benchmark]
fn do_refund() {
let account: T::AccountId = account("Alice", 1, 1);
let _ = CurrencyOf::<T>::make_free_balance_be(&T::RefundAccount::get(), u32::MAX.into());
let _ = CurrencyOf::<T>::set_balance(&T::RefundAccount::get(), u32::MAX.into());
// The worst-case scenario is when the refund fails
// and can only be triggered if the account is dead,
// in this case by having no balance in the account.
......@@ -161,7 +162,7 @@ mod benchmarks {
amount: 10u64.into(),
},
);
let _ = CurrencyOf::<T>::make_free_balance_be(&T::RefundAccount::get(), u32::MAX.into());
let _ = CurrencyOf::<T>::set_balance(&T::RefundAccount::get(), u32::MAX.into());
// The worst-case scenario is when the refund fails
// and can only be triggered if the account is dead,
// in this case by having no balance in the account.
......
......@@ -15,7 +15,7 @@
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use crate::{mock::*, Weight};
use frame_support::traits::Currency;
use frame_support::traits::fungible::Mutate;
use sp_core::Get;
// Note: values for reload rate and max quota defined in mock file
......@@ -150,10 +150,10 @@ fn test_process_refund_queue() {
.execute_with(|| {
run_to_block(5);
// give enough currency to accounts and treasury and double check
Balances::make_free_balance_be(&account(1), 1000);
Balances::make_free_balance_be(&account(2), 1000);
Balances::make_free_balance_be(&account(3), 1000);
Balances::make_free_balance_be(
Balances::set_balance(&account(1), 1000);
Balances::set_balance(&account(2), 1000);
Balances::set_balance(&account(3), 1000);
Balances::set_balance(
&<Test as pallet_quota::Config>::RefundAccount::get(),
10_000,
);
......@@ -208,8 +208,8 @@ fn test_not_enough_treasury() {
})
.execute_with(|| {
run_to_block(5);
Balances::make_free_balance_be(&account(1), 1000);
Balances::make_free_balance_be(&<Test as pallet_quota::Config>::RefundAccount::get(), 1200);
Balances::set_balance(&account(1), 1000);
Balances::set_balance(&<Test as pallet_quota::Config>::RefundAccount::get(), 1200);
Quota::queue_refund(pallet_quota::Refund {
account: account(1),
identity: 1,
......@@ -246,10 +246,10 @@ fn test_process_refund_queue_weight_with_quotas() {
.execute_with(|| {
run_to_block(15);
// give enough currency to accounts and treasury and double check
Balances::make_free_balance_be(&account(1), 1000);
Balances::make_free_balance_be(&account(2), 1000);
Balances::make_free_balance_be(&account(3), 1000);
Balances::make_free_balance_be(
Balances::set_balance(&account(1), 1000);
Balances::set_balance(&account(2), 1000);
Balances::set_balance(&account(3), 1000);
Balances::set_balance(
&<Test as pallet_quota::Config>::RefundAccount::get(),
10_000,
);
......@@ -314,10 +314,10 @@ fn test_process_refund_queue_weight_no_quotas() {
.execute_with(|| {
run_to_block(15);
// give enough currency to accounts and treasury and double check
Balances::make_free_balance_be(&account(1), 1000);
Balances::make_free_balance_be(&account(2), 1000);
Balances::make_free_balance_be(&account(3), 1000);
Balances::make_free_balance_be(
Balances::set_balance(&account(1), 1000);
Balances::set_balance(&account(2), 1000);
Balances::set_balance(&account(3), 1000);
Balances::set_balance(
&<Test as pallet_quota::Config>::RefundAccount::get(),
10_000,
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment