diff --git a/ledger/cryptarchia-ledger/Cargo.toml b/ledger/cryptarchia-ledger/Cargo.toml index fd819d29..d0b27194 100644 --- a/ledger/cryptarchia-ledger/Cargo.toml +++ b/ledger/cryptarchia-ledger/Cargo.toml @@ -10,6 +10,7 @@ blake2 = "0.10" rpds = "1" thiserror = "1" serde = { version = "1.0", features = ["derive"], optional = true } +serde_test = "1.0.176" # TODO: we only need types definition from this crate cryptarchia-engine = { path = "../../consensus/cryptarchia-engine" } nomos-utils = { path = "../../nomos-utils", optional = true } diff --git a/ledger/cryptarchia-ledger/src/lib.rs b/ledger/cryptarchia-ledger/src/lib.rs index a2483a1a..8a1dd848 100644 --- a/ledger/cryptarchia-ledger/src/lib.rs +++ b/ledger/cryptarchia-ledger/src/lib.rs @@ -390,6 +390,7 @@ pub mod tests { use crate::{crypto::Blake2b, Commitment, Config, LedgerError}; use blake2::Digest; use cryptarchia_engine::Slot; + use serde_test::{assert_tokens, Configure, Token}; type HeaderId = [u8; 32]; @@ -763,5 +764,11 @@ pub mod tests { assert_eq!(leader_proof.commitment(), &commitment); assert_eq!(leader_proof.evolved_commitment(), &commitment); assert_eq!(leader_proof.nullifier(), &nullifier); + + // Test ser/de of compact representation for Nullifier + assert_tokens(&nullifier.compact(), &[Token::BorrowedBytes(&[0; 32])]); + + // Test ser/de of compact representation for Commitment + assert_tokens(&commitment.compact(), &[Token::BorrowedBytes(&[0; 32])]); } }