test: ser/de for Nullifier and Commitment

This commit is contained in:
Roman 2024-06-14 10:33:49 +02:00
parent 0aadeafe1c
commit 20e34ea770
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
2 changed files with 8 additions and 0 deletions

View File

@ -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 }

View File

@ -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])]);
}
}