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

* pallet-evm: fix wrong logic in mutate_account_basic

* Add test for mutate account
This commit is contained in:
Wei Tang
2020-08-12 12:46:28 +02:00
committed by GitHub
parent 36a8c720f2
commit 64901c015e
2 changed files with 24 additions and 4 deletions
+4 -4
View File
@@ -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());
}
}
+20
View File
@@ -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),
});
});
}