use betex::{
    book::{BookEvent, BookEventEnvelope, BookMarketState, EventMetadata},
    config::Config,
    disruptor::Envelope,
    engine::{root::EngineRoot, state::EngineState},
    types::{MarketId, unix_epoch},
};

#[test]
#[should_panic(expected = "sequence gap")]
fn apply_panics_on_sequence_gap() {
    let root = EngineRoot::new_with(EngineState::new(Config::default()), 5);

    let env = Envelope {
        seq: 7, // gap: expected 6
        payload: BookEventEnvelope {
            market_id: MarketId(1),
            market_name: String::new(),
            market_seq: 1,
            timestamp: unix_epoch(),
            metadata: EventMetadata::default(),
            event: BookEvent::MarketStateChanged {
                to: BookMarketState::Open,
                reason: String::new(),
            },
        },
        response_cb: None,
        tx_id: 7,
        tx_len: 1,
        tx_ix: 0,
    };

    root.assert_next_seq(env.seq);
}
