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

Commit

Permalink
Fix ci test
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Jun 8, 2021
1 parent 1ff55c9 commit c49f7de
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions frame/evm/src/tests.rs
Expand Up @@ -109,7 +109,7 @@ impl FeeCalculator for FixedGasPrice {
}

pub struct RawAccountBasic<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> AccountBasic for RawAccountBasic<T> {
impl<T: Config> AccountBasic<T> for RawAccountBasic<T> {
/// Get the account basic in EVM format.
fn account_basic(address: &H160) -> Account {
let account_id = T::AddressMapping::into_account_id(*address);
Expand All @@ -123,30 +123,35 @@ impl<T: Config> AccountBasic for RawAccountBasic<T> {
}
}

fn mutate_account_basic_balance(address: &H160, new: Account) {
fn mutate_account_basic_balance(address: &H160, new_balance: U256) {
let account_id = T::AddressMapping::into_account_id(*address);
let current = T::RingAccountBasic::account_basic(address);

if current.nonce < new.nonce {
// ASSUME: in one single EVM transaction, the nonce will not increase more than
// `u128::max_value()`.
for _ in 0..(new.nonce - current.nonce).low_u128() {
<frame_system::Pallet<T>>::inc_account_nonce(&account_id);
}
}
// if current.nonce < new.nonce {
// // ASSUME: in one single EVM transaction, the nonce will not increase more than
// // `u128::max_value()`.
// for _ in 0..(new.nonce - current.nonce).low_u128() {
// <frame_system::Pallet<T>>::inc_account_nonce(&account_id);
// }
// }

if current.balance > new.balance {
let diff = current.balance - new.balance;
if current.balance > new_balance {
let diff = current.balance - new_balance;
T::RingCurrency::slash(&account_id, diff.low_u128().unique_saturated_into());
} else if current.balance < new.balance {
let diff = new.balance - current.balance;
} else if current.balance < new_balance {
let diff = new_balance - current.balance;
T::RingCurrency::deposit_creating(&account_id, diff.low_u128().unique_saturated_into());
}
}

fn transfer(_source: &H160, _target: &H160, _value: U256) -> Result<(), ExitError> {
Ok(())
}

fn account_balance(_account_id: &T::AccountId) -> U256 {
U256::default()
}
fn mutate_account_balance(_account_id: &T::AccountId, _balance: U256) {}
}

/// Ensure that the origin is root.
Expand Down

0 comments on commit c49f7de

Please sign in to comment.