diff --git a/runtime/gdev/tests/balance_tests.rs b/runtime/gdev/tests/balance_tests.rs index 8db1efb151afae84c9d9f31c475b00f9ae71e831..de2ac25c859473ec5cdba1842c30ae23b700e934 100644 --- a/runtime/gdev/tests/balance_tests.rs +++ b/runtime/gdev/tests/balance_tests.rs @@ -25,6 +25,7 @@ use sp_keyring::AccountKeyring; /// test currency transfer /// (does not take fees into account because it's only calls, not extrinsics) +/// test final balance of Alice and Eve accounts #[test] fn test_transfer() { ExtBuilder::new(1, 3, 4) @@ -52,23 +53,7 @@ fn test_transfer() { }) } -/// test balance transfer -#[test] -fn test_transfer() { - ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 600)]) - .build() - .execute_with(|| { - run_to_block(1); - assert_ok!(Balances::transfer_allow_death( - frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), - AccountKeyring::Dave.to_account_id().into(), - 500 - )); - }) -} - -/// test balance transfer without enough balance (would prefer TokenError::BelowMinimum or NotExpendable) +/// test balance transfer without enough balance #[test] fn test_transfer_not_enough() { ExtBuilder::new(1, 3, 4) @@ -82,24 +67,26 @@ fn test_transfer_not_enough() { AccountKeyring::Dave.to_account_id().into(), 500 ), - sp_runtime::TokenError::Frozen + sp_runtime::TokenError::Frozen // frozen because trying to transfer more than liquid ); }) } -/// test balance transfer without enough balance (would prefer TokenError::FundsUnavailable) +/// test balance transfer without enough balance +/// in this case, it is the total issuance which cause problem, hence the arithmetic underflow #[test] fn test_transfer_underflow() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 499)]) + .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 400)]) .build() .execute_with(|| { run_to_block(1); + assert_eq!(Balances::total_issuance(), 400); assert_noop!( Balances::transfer_allow_death( frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), AccountKeyring::Dave.to_account_id().into(), - 500 + 500 // larger than total issuance ), sp_runtime::ArithmeticError::Underflow ); @@ -107,6 +94,7 @@ fn test_transfer_underflow() { } /// test balance transfer without enough balance +/// can not transfer 500 when only 499 available #[test] fn test_transfer_funds_unavailable() { ExtBuilder::new(1, 3, 4)