use serde::{Deserialize, Serialize}; /// Account state in the account-based model. #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct AccountState { pub balance: u64, pub nonce: u64, } impl AccountState { pub fn new() -> Self { Self::default() } pub fn with_balance(balance: u64) -> Self { AccountState { balance, nonce: 0 } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_default_account() { let account = AccountState::new(); assert_eq!(account.balance, 0); assert_eq!(account.nonce, 0); } }