add tests for default account

This commit is contained in:
Sergio Chouhy 2025-08-08 13:32:50 -03:00
parent ef6af9a967
commit 3dfcb47534
4 changed files with 33 additions and 21 deletions

View File

@ -5,7 +5,7 @@ edition = "2024"
[dependencies]
risc0-zkvm = "2.3.1"
nssa-core = {path="core"}
nssa-core = { path = "core"}
program-methods = { path = "program_methods" }
serde = "1.0.219"
serde_cbor = "0.11.2"

View File

@ -11,7 +11,7 @@ pub type Nonce = u128;
type Data = Vec<u8>;
/// Account to be used both in public and private contexts
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Account {
pub program_owner: ProgramId,
pub balance: u128,
@ -25,13 +25,35 @@ pub struct AccountWithMetadata {
pub is_authorized: bool,
}
impl Default for Account {
fn default() -> Self {
Self {
program_owner: [0; 8],
balance: 0,
data: vec![],
nonce: 0,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_zero_balance_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.balance, 0);
}
#[test]
fn test_zero_nonce_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.nonce, 0);
}
#[test]
fn test_empty_data_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.data, vec![]);
}
#[test]
fn test_default_program_owner_account_data_creation() {
let new_acc = Account::default();
assert_eq!(new_acc.program_owner, [0; 8]);
}
}

View File

@ -1,7 +1,6 @@
use std::{collections::HashSet, path::Path};
use accounts::account_core::address::AccountAddress;
use accounts_store::SequencerAccountsStore;
use block_store::SequecerBlockStore;
use common::{
block::{Block, HashableBlockData},
@ -13,14 +12,11 @@ use nssa;
use crate::config::AccountInitialData;
pub mod accounts_store;
pub mod block_store;
pub struct SequecerChainStore {
pub state: nssa::V01State,
pub block_store: SequecerBlockStore,
pub nullifier_store: HashSet<UTXONullifier>,
pub utxo_commitments_store: UTXOCommitmentsMerkleTree,
}
impl SequecerChainStore {
@ -44,9 +40,6 @@ impl SequecerChainStore {
.collect();
let state = nssa::V01State::new_with_genesis_accounts(&init_accs);
let nullifier_store = HashSet::new();
let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]);
// let pub_tx_store = PublicTransactionMerkleTree::new(vec![]);
let mut data = [0; 32];
let mut prev_block_hash = [0; 32];
@ -77,9 +70,6 @@ impl SequecerChainStore {
Self {
state,
block_store,
nullifier_store,
utxo_commitments_store,
// pub_tx_store,
}
}
}

View File

@ -481,7 +481,7 @@ mod tests {
let request = serde_json::json!({
"jsonrpc": "2.0",
"method": "get_transaction_by_hash",
"params": { "hash": "e5f0c9b4b7732a2f4946b8e7a5f7c641b004559b1a13b1ccc600f29477725240"},
"params": { "hash":"fc96dbd7603f1f97bfd96c31e09c35dc877a436c4aa71437b3e8f5bbf69b77fc"},
"id": 1
});