Skip to content

Commit

Permalink
Add serialization tests for models
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Sep 19, 2023
1 parent 71d36a5 commit 71cc96f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/models/shard/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ use super::*;
use crate::models::Block;
use crate::prelude::Boc;

fn check_state(data: Cell) {
let data = data.parse::<ShardStateUnsplit>().unwrap();

fn check_state(cell: Cell) {
let data = cell.parse::<ShardStateUnsplit>().unwrap();
println!("data: {data:#?}");
assert_eq!(CellBuilder::build_from(&data).unwrap(), cell);

let shard_accounts = data.load_accounts().unwrap();
assert_eq!(
CellBuilder::build_from(&shard_accounts).unwrap(),
data.accounts.cell
);

for entry in shard_accounts.iter() {
let (id, shard_state) = entry.unwrap();
let account = shard_state.load_account().unwrap();
Expand All @@ -28,6 +33,10 @@ fn check_state(data: Cell) {

let custom = data.load_custom().unwrap().unwrap();
println!("custom: {custom:#?}");
assert_eq!(
CellBuilder::build_from(&custom).unwrap(),
data.custom.unwrap().cell
);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions src/models/transaction/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn check_tx(boc: &[u8]) -> Cell {

let info = tx.load_info().unwrap();
println!("info: {info:#?}");
assert_eq!(tx.info.cell, CellBuilder::build_from(info).unwrap());

let serialized = CellBuilder::build_from(tx).unwrap();
assert_eq!(serialized.as_ref(), boc.as_ref());
Expand Down

0 comments on commit 71cc96f

Please sign in to comment.