Skip to content
Snippets Groups Projects
Commit 64901c01 authored by Wei Tang's avatar Wei Tang Committed by GitHub
Browse files

pallet-evm: fix wrong logic in mutate_account_basic (#6786)

* pallet-evm: fix wrong logic in mutate_account_basic

* Add test for mutate account
parent 36a8c720
No related merge requests found
......@@ -438,11 +438,11 @@ impl<T: Trait> Module<T> {
}
}
if current.balance < new.balance {
let diff = new.balance - current.balance;
T::Currency::slash(&account_id, diff.low_u128().unique_saturated_into());
} else if current.balance > new.balance {
if current.balance > new.balance {
let diff = current.balance - new.balance;
T::Currency::slash(&account_id, diff.low_u128().unique_saturated_into());
} else if current.balance < new.balance {
let diff = new.balance - current.balance;
T::Currency::deposit_creating(&account_id, diff.low_u128().unique_saturated_into());
}
}
......
......@@ -166,3 +166,23 @@ fn fail_call_return_ok() {
));
});
}
#[test]
fn mutate_account_works() {
new_test_ext().execute_with(|| {
EVM::mutate_account_basic(
&H160::from_str("1000000000000000000000000000000000000001").unwrap(),
Account {
nonce: U256::from(10),
balance: U256::from(1000),
},
);
assert_eq!(EVM::account_basic(
&H160::from_str("1000000000000000000000000000000000000001").unwrap()
), Account {
nonce: U256::from(10),
balance: U256::from(1000),
});
});
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment