test: conversions for LeaderProof

This commit is contained in:
Roman 2024-06-12 17:25:19 +02:00
parent 7d6ae1b823
commit 408e619e82
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
1 changed files with 26 additions and 1 deletions

View File

@ -386,7 +386,7 @@ impl core::fmt::Debug for LedgerState {
#[cfg(test)]
pub mod tests {
use super::{Coin, EpochState, Ledger, LedgerState};
use super::{Coin, EpochState, LeaderProof, Ledger, LedgerState, Nullifier};
use crate::{crypto::Blake2b, Commitment, Config, LedgerError};
use blake2::Digest;
use cryptarchia_engine::Slot;
@ -741,4 +741,29 @@ pub mod tests {
Err(LedgerError::NullifierExists)
));
}
#[test]
fn test_conversions_for_leader_proof() {
let commitment = Commitment::from([0u8; 32]);
let commitment_bytes: [u8; 32] = commitment.into();
let _zero_bytes = [0u8; 32];
assert!(matches!(commitment_bytes, _zero_bytes));
let commitment_ref = commitment.as_ref();
assert_eq!(commitment_ref, &_zero_bytes);
let nullifier = Nullifier::from([0u8; 32]);
let _nullifier_bytes: [u8; 32] = nullifier.into();
assert!(matches!(_nullifier_bytes, _zero_bytes));
let slot = Slot::genesis();
let leader_proof = LeaderProof::dummy(slot);
assert_eq!(leader_proof.commitment(), &commitment);
assert_eq!(leader_proof.evolved_commitment(), &commitment);
assert_eq!(leader_proof.nullifier(), &nullifier);
}
}