Skip to content

Commit

Permalink
chore(mpt): account conversion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Oct 7, 2024
1 parent 5cdb416 commit d1cb7a4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions crates/mpt/src/db/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,45 @@ impl From<(AccountInfo, B256)> for TrieAccount {
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::uint;

#[test]
fn test_trie_account_from_account() {
let account = Account {
info: AccountInfo {
nonce: 1,
balance: uint!(2_U256),
code_hash: B256::default(),
code: Default::default(),
},
status: Default::default(),
storage: Default::default(),
};
let storage_root = B256::default();
let trie_account = TrieAccount::from((account, storage_root));
assert_eq!(trie_account.nonce, 1);
assert_eq!(trie_account.balance, uint!(2_U256));
assert_eq!(trie_account.storage_root, B256::default());
assert_eq!(trie_account.code_hash, B256::default());
}

#[test]
fn test_trie_account_from_account_info() {
let account_info = AccountInfo {
nonce: 1,
balance: uint!(2_U256),
code_hash: B256::default(),
code: Default::default(),
};
let storage_root = B256::default();
let trie_account = TrieAccount::from((account_info, storage_root));
assert_eq!(trie_account.nonce, 1);
assert_eq!(trie_account.balance, uint!(2_U256));
assert_eq!(trie_account.storage_root, B256::default());
assert_eq!(trie_account.code_hash, B256::default());
}
}

0 comments on commit d1cb7a4

Please sign in to comment.