-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test * forign signer can mint * negative minting test * remove it (#285)
- Loading branch information
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::{mock::*, *}; | ||
use frame_support::{assert_noop, assert_ok, error::BadOrigin}; | ||
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); | ||
}) | ||
} | ||
|
||
#[test] | ||
fn foreign_asset_signer_can_mint() { | ||
build_test_externality().execute_with(|| { | ||
let currency_id = CurrencyId::ForeignAsset(10); | ||
let beneficiary = BOB; | ||
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), | ||
amount | ||
); | ||
}) | ||
} | ||
|
||
#[test] | ||
fn non_foreign_asset_signer_cannot_mint() { | ||
build_test_externality().execute_with(|| { | ||
let currency_id = CurrencyId::ForeignAsset(10); | ||
let beneficiary = BOB; | ||
let amount = 92839572; | ||
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); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod disputes; | |
pub mod immutable_votes; | ||
pub mod pallet; | ||
pub mod refunds; | ||
pub mod foreign_asset; |