Skip to content
Snippets Groups Projects

add balance transfer tests

Merged Hugo Trentesaux requested to merge hugo-dev into master
@@ -184,6 +184,60 @@ fn test_total_issuance_vs_monetary_mass() {
@@ -184,6 +184,60 @@ fn test_total_issuance_vs_monetary_mass() {
});
});
}
}
 
/// test balance transfer
 
#[test]
 
fn test_simple_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]
 
fn test_simple_transfer_not_enough() {
 
ExtBuilder::new(1, 3, 4)
 
.with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 599)])
 
.build()
 
.execute_with(|| {
 
run_to_block(1);
 
assert_noop!(
 
Balances::transfer_allow_death(
 
frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(),
 
AccountKeyring::Dave.to_account_id().into(),
 
500
 
),
 
sp_runtime::TokenError::Frozen
 
);
 
})
 
}
 
 
/// test balance transfer without enough balance (would prefer TokenError::FundsUnavailable)
 
#[test]
 
fn test_simple_transfer_underflow() {
 
ExtBuilder::new(1, 3, 4)
 
.with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 499)])
 
.build()
 
.execute_with(|| {
 
run_to_block(1);
 
assert_noop!(
 
Balances::transfer_allow_death(
 
frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(),
 
AccountKeyring::Dave.to_account_id().into(),
 
500
 
),
 
sp_runtime::ArithmeticError::Underflow
 
);
 
})
 
}
 
/// test identity go below ED
/// test identity go below ED
#[test]
#[test]
fn test_identity_below_ed() {
fn test_identity_below_ed() {
Loading