Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Make review work easier
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Jun 8, 2021
1 parent 989775b commit ece7559
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions frame/dvm/src/tests.rs
Expand Up @@ -374,79 +374,79 @@ fn call_should_handle_errors() {
}

#[test]
fn withdraw_without_enough_balance_should_fail() {
fn withdraw_with_enough_balance() {
let (pairs, mut ext) = new_test_ext(1);
let alice = &pairs[0];

ext.execute_with(|| {
let mut unsigned_tx = default_withdraw_unsigned_transaction();
unsigned_tx.value = U256::from(120000000000000000000u128);
let t = sign_transaction(alice, unsigned_tx);

let res = Ethereum::execute(
let t = sign_transaction(alice, default_withdraw_unsigned_transaction());
assert_ok!(Ethereum::execute(
alice.address,
t.input,
t.input.clone(),
t.value,
t.gas_limit,
None,
Some(t.nonce),
t.action,
None,
);

assert_err!(
res,
DispatchError::Module {
index: 4,
error: 0,
message: Some("BalanceLow")
}
);
));

// Check caller balance
assert_eq!(
<Test as darwinia_evm::Config>::RingAccountBasic::account_basic(&alice.address).balance,
U256::from(100000000000000000000u128)
U256::from(70_000_000_000_000_000_000u128)
);
// Check target balance
// Check the target balance
let input_bytes: Vec<u8> = array_bytes::hex2bytes_unchecked(WITH_DRAW_INPUT);
let dest =
<Test as frame_system::Config>::AccountId::decode(&mut &input_bytes[..]).unwrap();
assert_eq!(<Test as Config>::RingCurrency::free_balance(&dest), 0);
assert_eq!(
<Test as Config>::RingCurrency::free_balance(dest),
30000000000
);
});
}

#[test]
fn withdraw_with_enough_balance() {
fn withdraw_without_enough_balance_should_fail() {
let (pairs, mut ext) = new_test_ext(1);
let alice = &pairs[0];

ext.execute_with(|| {
let t = sign_transaction(alice, default_withdraw_unsigned_transaction());
assert_ok!(Ethereum::execute(
let mut unsigned_tx = default_withdraw_unsigned_transaction();
unsigned_tx.value = U256::from(120000000000000000000u128);
let t = sign_transaction(alice, unsigned_tx);

let res = Ethereum::execute(
alice.address,
t.input.clone(),
t.input,
t.value,
t.gas_limit,
None,
Some(t.nonce),
t.action,
None,
));
);

assert_err!(
res,
DispatchError::Module {
index: 4,
error: 0,
message: Some("BalanceLow")
}
);

// Check caller balance
assert_eq!(
<Test as darwinia_evm::Config>::RingAccountBasic::account_basic(&alice.address).balance,
U256::from(70_000_000_000_000_000_000u128)
U256::from(100000000000000000000u128)
);
// Check the target balance
// Check target balance
let input_bytes: Vec<u8> = array_bytes::hex2bytes_unchecked(WITH_DRAW_INPUT);
let dest =
<Test as frame_system::Config>::AccountId::decode(&mut &input_bytes[..]).unwrap();
assert_eq!(
<Test as Config>::RingCurrency::free_balance(dest),
30000000000
);
assert_eq!(<Test as Config>::RingCurrency::free_balance(&dest), 0);
});
}

Expand Down

0 comments on commit ece7559

Please sign in to comment.