test: add can_spend and total_stake check

This commit is contained in:
Roman 2024-06-15 09:15:12 +02:00
parent 2e587084b4
commit 6aba4d6fd7
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
1 changed files with 6 additions and 4 deletions

View File

@ -803,15 +803,17 @@ pub mod tests {
let proof = LeaderProof::dummy(actual_slot, commitment, commitment);
let epoch_state = ledger_state.epoch_state();
assert_eq!(ledger_state.can_lead(&commitment), true);
assert_eq!(epoch_state.is_eligible_leader(&commitment), true);
assert!(ledger_state.can_spend(&commitment));
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
.try_apply_proof::<HeaderId>(&proof, ledger_config)
.err();
assert_eq!(coin.value(), Value::from(1u32));
// Commitment cannot be spent twice
assert!(
matches!(apply_proof_err, Some(LedgerError::CommitmentExists)),