use super::*;
use crate::{model::settlement::SettlementContext, tests::support::operation_plan::hash};
#[test]
fn every_original_identity_field_and_rejection_order_is_bound() {
let expected = IcInventorySettlement {
context: SettlementContext {
authority: hash("12"),
mutation_attempt: 1,
observation_attempt: 2,
challenge: hash("34"),
observation_evidence: hash("56"),
evidence: hash("78"),
},
baseline: hash("90"),
inventory: hash("ab"),
attribution: IcInventoryAttribution::Unresolved {
uncertainty: hash("cd"),
},
};
for (field, error) in [
InventorySettlementMismatch::Authority,
InventorySettlementMismatch::Attempt,
InventorySettlementMismatch::Attempt,
InventorySettlementMismatch::Challenge,
InventorySettlementMismatch::Baseline,
InventorySettlementMismatch::Inventory,
InventorySettlementMismatch::ObservationEvidence,
]
.into_iter()
.enumerate()
{
let mut changed = expected.clone();
match field {
0 => changed.context.authority = hash("ef"),
1 => changed.context.mutation_attempt = 3,
2 => changed.context.observation_attempt = 3,
3 => changed.context.challenge = hash("ef"),
4 => changed.baseline = hash("ef"),
5 => changed.inventory = hash("ef"),
_ => changed.context.observation_evidence = hash("ef"),
}
changed.context.observation_evidence = hash("ef");
assert_eq!(
InventorySettlementIdentity::from(&changed)
.compare(&InventorySettlementIdentity::from(&expected)),
Err(error)
);
}
assert_eq!(
InventorySettlementIdentity::from(&expected)
.compare(&InventorySettlementIdentity::from(&expected)),
Ok(())
);
}