minerva 0.2.0

Causal ordering for distributed systems
use crate::kairos::Kairos;
use crate::metis::{Anchor, Locus, Rhapsody};
use proptest::prelude::*;

use super::super::d;
use crate::metis::dot::RawDot;

proptest! {
    /// A dangling anchor round-trips faithfully: a single element woven after a
    /// dot that was never itself woven is legal and remains unreachable.
    #[test]
    fn prop_rhapsody_dangling_anchor_round_trips(
        station in 1u32..=3, index in 1u64..=8,
        astation in 1u32..=3, aindex in 1u64..=8,
        tick in 0u64..64,
    ) {
        prop_assume!((astation, aindex) != (station, index));
        let mut rhapsody = Rhapsody::new();
        let rank = Kairos::new(tick, 0u16, station, 0u16);
        let locus = Locus {
            anchor: Anchor::After(RawDot { station: astation, counter: aindex }),
            rank,
        };
        let wove = rhapsody.weave(d(station, index), locus);
        prop_assert!(wove);
        prop_assert!(rhapsody.order().is_empty());
        prop_assert_eq!(Rhapsody::from_bytes(&rhapsody.to_bytes()), Ok(rhapsody));
    }
}