diff --git a/frame/dvm/src/tests.rs b/frame/dvm/src/tests.rs index 525c7d006e..f2a0d46541 100644 --- a/frame/dvm/src/tests.rs +++ b/frame/dvm/src/tests.rs @@ -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!( ::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 = array_bytes::hex2bytes_unchecked(WITH_DRAW_INPUT); let dest = ::AccountId::decode(&mut &input_bytes[..]).unwrap(); - assert_eq!(::RingCurrency::free_balance(&dest), 0); + assert_eq!( + ::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!( ::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 = array_bytes::hex2bytes_unchecked(WITH_DRAW_INPUT); let dest = ::AccountId::decode(&mut &input_bytes[..]).unwrap(); - assert_eq!( - ::RingCurrency::free_balance(dest), - 30000000000 - ); + assert_eq!(::RingCurrency::free_balance(&dest), 0); }); }