Skip to content

Commit 0367801

Browse files
committed
fix
1 parent 0efc5e1 commit 0367801

File tree

4 files changed

+57
-12
lines changed

4 files changed

+57
-12
lines changed

currencies/src/tests.rs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ fn native_currency_should_work() {
217217
assert_eq!(NativeCurrency::free_balance(&ALICE), 50);
218218
assert_eq!(NativeCurrency::free_balance(&BOB), 150);
219219

220-
assert_ok!(NativeCurrency::transfer(&ALICE, &BOB, 10));
220+
assert_ok!(NativeCurrency::transfer(
221+
&ALICE,
222+
&BOB,
223+
10,
224+
ExistenceRequirement::AllowDeath
225+
));
221226
assert_eq!(NativeCurrency::free_balance(&ALICE), 40);
222227
assert_eq!(NativeCurrency::free_balance(&BOB), 160);
223228

@@ -251,12 +256,22 @@ fn basic_currency_adapting_pallet_balances_transfer() {
251256
.one_hundred_for_alice_n_bob()
252257
.build()
253258
.execute_with(|| {
254-
assert_ok!(AdaptedBasicCurrency::transfer(&ALICE, &BOB, 50));
259+
assert_ok!(AdaptedBasicCurrency::transfer(
260+
&ALICE,
261+
&BOB,
262+
50,
263+
ExistenceRequirement::AllowDeath
264+
));
255265
assert_eq!(PalletBalances::total_balance(&ALICE), 50);
256266
assert_eq!(PalletBalances::total_balance(&BOB), 150);
257267

258268
// creation fee
259-
assert_ok!(AdaptedBasicCurrency::transfer(&ALICE, &EVA, 10));
269+
assert_ok!(AdaptedBasicCurrency::transfer(
270+
&ALICE,
271+
&EVA,
272+
10,
273+
ExistenceRequirement::AllowDeath
274+
));
260275
assert_eq!(PalletBalances::total_balance(&ALICE), 40);
261276
assert_eq!(PalletBalances::total_balance(&EVA), 10);
262277
});
@@ -297,7 +312,11 @@ fn basic_currency_adapting_pallet_balances_withdraw() {
297312
.one_hundred_for_alice_n_bob()
298313
.build()
299314
.execute_with(|| {
300-
assert_ok!(AdaptedBasicCurrency::withdraw(&ALICE, 100));
315+
assert_ok!(AdaptedBasicCurrency::withdraw(
316+
&ALICE,
317+
100,
318+
ExistenceRequirement::AllowDeath
319+
));
301320
assert_eq!(PalletBalances::total_balance(&ALICE), 0);
302321
assert_eq!(PalletBalances::total_issuance(), 100);
303322
});
@@ -375,7 +394,11 @@ fn call_event_should_work() {
375394
}));
376395

377396
assert_ok!(<Currencies as MultiCurrency<AccountId>>::transfer(
378-
X_TOKEN_ID, &ALICE, &BOB, 10
397+
X_TOKEN_ID,
398+
&ALICE,
399+
&BOB,
400+
10,
401+
ExistenceRequirement::AllowDeath
379402
));
380403
assert_eq!(Currencies::free_balance(X_TOKEN_ID, &ALICE), 40);
381404
assert_eq!(Currencies::free_balance(X_TOKEN_ID, &BOB), 160);
@@ -397,7 +420,10 @@ fn call_event_should_work() {
397420
}));
398421

399422
assert_ok!(<Currencies as MultiCurrency<AccountId>>::withdraw(
400-
X_TOKEN_ID, &ALICE, 20
423+
X_TOKEN_ID,
424+
&ALICE,
425+
20,
426+
ExistenceRequirement::AllowDeath
401427
));
402428
assert_eq!(Currencies::free_balance(X_TOKEN_ID, &ALICE), 120);
403429
System::assert_last_event(RuntimeEvent::Tokens(orml_tokens::Event::Withdrawn {

tokens/src/tests_events.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ fn pallet_multicurrency_deposit_events() {
2020
.balances(vec![(ALICE, DOT, 100), (BOB, DOT, 100)])
2121
.build()
2222
.execute_with(|| {
23-
assert_ok!(<Tokens as MultiCurrency<AccountId>>::transfer(DOT, &ALICE, &BOB, 10));
23+
assert_ok!(<Tokens as MultiCurrency<AccountId>>::transfer(
24+
DOT,
25+
&ALICE,
26+
&BOB,
27+
10,
28+
ExistenceRequirement::AllowDeath
29+
));
2430
System::assert_last_event(RuntimeEvent::Tokens(crate::Event::Transfer {
2531
currency_id: DOT,
2632
from: ALICE,
@@ -35,7 +41,12 @@ fn pallet_multicurrency_deposit_events() {
3541
amount: 10,
3642
}));
3743

38-
assert_ok!(<Tokens as MultiCurrency<AccountId>>::withdraw(DOT, &ALICE, 10));
44+
assert_ok!(<Tokens as MultiCurrency<AccountId>>::withdraw(
45+
DOT,
46+
&ALICE,
47+
10,
48+
ExistenceRequirement::AllowDeath
49+
));
3950
System::assert_last_event(RuntimeEvent::Tokens(crate::Event::Withdrawn {
4051
currency_id: DOT,
4152
who: ALICE,

tokens/src/tests_multicurrency.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn multicurrency_withdraw_work() {
2828
assert!(Accounts::<Runtime>::contains_key(ALICE, DOT));
2929
assert_eq!(Tokens::free_balance(DOT, &ALICE), 100);
3030
assert_eq!(Tokens::total_issuance(DOT), 100);
31-
assert_ok!(Tokens::withdraw(DOT, &ALICE, 99));
31+
assert_ok!(Tokens::withdraw(DOT, &ALICE, 99, ExistenceRequirement::AllowDeath));
3232
assert!(!Accounts::<Runtime>::contains_key(ALICE, DOT));
3333
assert_eq!(Tokens::free_balance(DOT, &ALICE), 0);
3434
assert_eq!(Tokens::total_issuance(DOT), 1);
@@ -44,7 +44,13 @@ fn multicurrency_transfer_work() {
4444
assert!(Accounts::<Runtime>::contains_key(ALICE, DOT));
4545
assert_eq!(Tokens::free_balance(DOT, &ALICE), 100);
4646
assert_eq!(Tokens::free_balance(DOT, &BOB), 100);
47-
assert_ok!(<Tokens as MultiCurrency<_>>::transfer(DOT, &ALICE, &BOB, 99));
47+
assert_ok!(<Tokens as MultiCurrency<_>>::transfer(
48+
DOT,
49+
&ALICE,
50+
&BOB,
51+
99,
52+
ExistenceRequirement::AllowDeath
53+
));
4854
assert!(!Accounts::<Runtime>::contains_key(ALICE, DOT));
4955
assert_eq!(Tokens::free_balance(DOT, &ALICE), 0);
5056
assert_eq!(Tokens::free_balance(DOT, &BOB), 199);
@@ -379,7 +385,7 @@ fn no_op_if_amount_is_zero() {
379385
assert_ok!(Tokens::transfer(Some(ALICE).into(), BOB, DOT, 0));
380386
assert_ok!(Tokens::transfer(Some(ALICE).into(), ALICE, DOT, 0));
381387
assert_ok!(Tokens::deposit(DOT, &ALICE, 0));
382-
assert_ok!(Tokens::withdraw(DOT, &ALICE, 0));
388+
assert_ok!(Tokens::withdraw(DOT, &ALICE, 0, ExistenceRequirement::AllowDeath));
383389
assert_eq!(Tokens::slash(DOT, &ALICE, 0), 0);
384390
assert_eq!(Tokens::slash(DOT, &ALICE, 1), 1);
385391
assert_ok!(Tokens::update_balance(DOT, &ALICE, 0));

xtokens/src/mock/teleport_currency_adapter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use frame_support::traits::ExistenceRequirement;
12
use parity_scale_codec::FullCodec;
23
use sp_runtime::traits::{Convert, MaybeSerializeDeserialize, SaturatedConversion};
34
use sp_std::{
@@ -121,7 +122,8 @@ impl<
121122
let amount: MultiCurrency::Balance = Match::matches_fungible(asset)
122123
.ok_or_else(|| XcmError::from(Error::FailedToMatchFungible))?
123124
.saturated_into();
124-
MultiCurrency::withdraw(currency_id, &who, amount).map_err(|e| XcmError::FailedToTransactAsset(e.into()))
125+
MultiCurrency::withdraw(currency_id, &who, amount, ExistenceRequirement::AllowDeath)
126+
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
125127
})?;
126128

127129
Ok(asset.clone().into())

0 commit comments

Comments
 (0)