Compare commits

..

2 Commits

Author SHA1 Message Date
Roman 6aba4d6fd7
test: add can_spend and total_stake check 2024-06-15 09:15:12 +02:00
Roman 2e587084b4
test: add coin value check 2024-06-15 09:02:37 +02:00
1 changed files with 7 additions and 3 deletions

View File

@ -386,7 +386,7 @@ impl core::fmt::Debug for LedgerState {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::{Coin, EpochState, LeaderProof, Ledger, LedgerState, Nullifier}; use super::{Coin, EpochState, LeaderProof, Ledger, LedgerState, Nullifier, Value};
use crate::{crypto::Blake2b, Commitment, Config, LedgerError}; use crate::{crypto::Blake2b, Commitment, Config, LedgerError};
use blake2::Digest; use blake2::Digest;
use cryptarchia_engine::Slot; use cryptarchia_engine::Slot;
@ -803,8 +803,12 @@ pub mod tests {
let proof = LeaderProof::dummy(actual_slot, commitment, commitment); let proof = LeaderProof::dummy(actual_slot, commitment, commitment);
let epoch_state = ledger_state.epoch_state(); let epoch_state = ledger_state.epoch_state();
assert_eq!(ledger_state.can_lead(&commitment), true); assert!(ledger_state.can_spend(&commitment));
assert_eq!(epoch_state.is_eligible_leader(&commitment), true); assert_eq!(epoch_state.total_stake(), Value::from(1u32));
assert_eq!(coin.value(), Value::from(1u32));
assert!(ledger_state.can_lead(&commitment));
assert!(epoch_state.is_eligible_leader(&commitment));
let apply_proof_err = ledger_state let apply_proof_err = ledger_state
.try_apply_proof::<HeaderId>(&proof, ledger_config) .try_apply_proof::<HeaderId>(&proof, ledger_config)