Skip to content

Commit

Permalink
Add basic setup test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed May 30, 2023
1 parent 4b300c5 commit 8115493
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
18 changes: 10 additions & 8 deletions frame/evm-balances/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ use crate::{self as pallet_evm_balances, *};

pub(crate) const INIT_BALANCE: u64 = 10_000_000;

pub(crate) fn alice() -> H160 {
H160::from_str("1000000000000000000000000000000000000000").unwrap()
}

pub(crate) fn bob() -> H160 {
H160::from_str("2000000000000000000000000000000000000000").unwrap()
}

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

Expand Down Expand Up @@ -193,14 +201,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
nonce: Default::default(),
storage: Default::default(),
};
map.insert(
H160::from_str("1000000000000000000000000000000000000000").unwrap(),
init_genesis_account.clone(),
);
map.insert(
H160::from_str("2000000000000000000000000000000000000000").unwrap(),
init_genesis_account,
);
map.insert(alice(), init_genesis_account.clone());
map.insert(bob(), init_genesis_account);
map
},
},
Expand Down
26 changes: 26 additions & 0 deletions frame/evm-balances/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
//! Unit tests.

use crate::{mock::*, *};

#[test]
fn basic_setup_works() {
new_test_ext().execute_with_ext(|_| {
// Check the accounts.
assert_eq!(
<EvmSystem>::full_account(&alice()),
pallet_evm_system::AccountInfo {
nonce: 0,
data: account_data::AccountData { free: INIT_BALANCE }
}
);
assert_eq!(
<EvmSystem>::full_account(&bob()),
pallet_evm_system::AccountInfo {
nonce: 0,
data: account_data::AccountData { free: INIT_BALANCE }
}
);

// Check the total balance value.
assert_eq!(EvmBalances::total_issuance(), 2 * INIT_BALANCE);
});
}

0 comments on commit 8115493

Please sign in to comment.