Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Dec 8, 2023
1 parent 180e521 commit 311432d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pallets/disputes/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ impl crate::traits::DisputeHooks<u32, u32> for Test {
) -> Weight {
<Weight as Default>::default()
}
}
}
3 changes: 1 addition & 2 deletions pallets/fellowship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod benchmarking;
#[frame_support::pallet]
pub mod pallet {
use common_types::CurrencyId;
use frame_support::{pallet_prelude::*, BoundedBTreeMap, weights::Weight};
use frame_support::{pallet_prelude::*, weights::Weight, BoundedBTreeMap};
use frame_system::pallet_prelude::*;
use orml_traits::{MultiCurrency, MultiReservableCurrency};
use sp_runtime::traits::Zero;
Expand Down Expand Up @@ -417,4 +417,3 @@ pub mod pallet {
fn pay_deposit_to_remove_pending_status() -> Weight;
}
}

2 changes: 1 addition & 1 deletion pallets/fellowship/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let _ = Tokens::deposit(CurrencyId::Native, &TREASURY, initial_balance);
});
ext
}
}
1 change: 0 additions & 1 deletion pallets/fellowship/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ pub trait FellowshipPermissions<Role, Permission> {
fn has_permission(role: Role, permission: Permission) -> bool;
fn get_permissions(role: Role) -> Vec<Permission>;
}

64 changes: 48 additions & 16 deletions pallets/proposals/src/tests/foreign_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,28 @@ use test_utils::*;
#[test]
fn set_foreign_asset_signer_check_permission_for_edit() {
build_test_externality().execute_with(|| {
assert_ok!(Proposals::set_foreign_asset_signer(RuntimeOrigin::root(), ALICE));
assert_eq!(ForeignCurrencySigner::<Test>::get().unwrap(), ALICE, "Alice should have been set as signer.");
assert_ok!(Proposals::set_foreign_asset_signer(RuntimeOrigin::root(), BOB));
assert_eq!(ForeignCurrencySigner::<Test>::get().unwrap(), BOB, "Bob should be set as signer.");
assert_noop!(Proposals::set_foreign_asset_signer(RuntimeOrigin::signed(BOB), ALICE), BadOrigin);
assert_ok!(Proposals::set_foreign_asset_signer(
RuntimeOrigin::root(),
ALICE
));
assert_eq!(
ForeignCurrencySigner::<Test>::get().unwrap(),
ALICE,
"Alice should have been set as signer."
);
assert_ok!(Proposals::set_foreign_asset_signer(
RuntimeOrigin::root(),
BOB
));
assert_eq!(
ForeignCurrencySigner::<Test>::get().unwrap(),
BOB,
"Bob should be set as signer."
);
assert_noop!(
Proposals::set_foreign_asset_signer(RuntimeOrigin::signed(BOB), ALICE),
BadOrigin
);
})
}

Expand All @@ -21,15 +38,14 @@ fn foreign_asset_signer_can_mint() {
let amount = 92839572;
let _ = Proposals::set_foreign_asset_signer(RuntimeOrigin::root(), ALICE);
let asset_signer = ForeignCurrencySigner::<Test>::get().unwrap();
assert_eq!(
Tokens::free_balance(currency_id, &BOB),
0
);
assert_ok!(Proposals::mint_offchain_assets(RuntimeOrigin::signed(asset_signer), beneficiary, currency_id, amount));
assert_eq!(
Tokens::free_balance(currency_id, &BOB),
assert_eq!(Tokens::free_balance(currency_id, &BOB), 0);
assert_ok!(Proposals::mint_offchain_assets(
RuntimeOrigin::signed(asset_signer),
beneficiary,
currency_id,
amount
);
));
assert_eq!(Tokens::free_balance(currency_id, &BOB), amount);
})
}

Expand All @@ -42,7 +58,23 @@ fn non_foreign_asset_signer_cannot_mint() {
let _ = Proposals::set_foreign_asset_signer(RuntimeOrigin::root(), ALICE);
let asset_signer = ForeignCurrencySigner::<Test>::get().unwrap();

assert_noop!(Proposals::mint_offchain_assets(RuntimeOrigin::signed(BOB), beneficiary, currency_id, amount), Error::<Test>::RequireForeignAssetSigner);
assert_noop!(Proposals::mint_offchain_assets(RuntimeOrigin::signed(CHARLIE), beneficiary, currency_id, amount), Error::<Test>::RequireForeignAssetSigner);
assert_noop!(
Proposals::mint_offchain_assets(
RuntimeOrigin::signed(BOB),
beneficiary,
currency_id,
amount
),
Error::<Test>::RequireForeignAssetSigner
);
assert_noop!(
Proposals::mint_offchain_assets(
RuntimeOrigin::signed(CHARLIE),
beneficiary,
currency_id,
amount
),
Error::<Test>::RequireForeignAssetSigner
);
})
}
}
2 changes: 1 addition & 1 deletion pallets/proposals/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod disputes;
pub mod foreign_asset;
pub mod immutable_votes;
pub mod pallet;
pub mod refunds;
pub mod foreign_asset;
7 changes: 5 additions & 2 deletions runtime/imbue-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,8 @@ type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
pub struct PointerBasedJurySelector<T: pallet_fellowship::Config>(T);
impl<T: pallet_fellowship::Config> pallet_fellowship::traits::SelectJury<AccountIdOf<T>>
for PointerBasedJurySelector<T>
where T: frame_system::Config<AccountId = sp_runtime::AccountId32>,
where
T: frame_system::Config<AccountId = sp_runtime::AccountId32>,
{
type JurySize = MaxJurySize;
fn select_jury() -> frame_support::BoundedVec<AccountIdOf<T>, Self::JurySize> {
Expand Down Expand Up @@ -1372,7 +1373,9 @@ where T: frame_system::Config<AccountId = sp_runtime::AccountId32>,
sp_runtime::AccountId32::new(hex_literal::hex![
"5a1616831e4508abf2eced2670199ab7a00e9e2bbcfc04655ba7ed138af8787d"
]),
].try_into().unwrap_or_default()
]
.try_into()
.unwrap_or_default()
} else {
out
}
Expand Down

0 comments on commit 311432d

Please sign in to comment.