use digdigdig3_station::{AccountType, ExchangeId, Station, Stream, SubscriptionSet};
#[tokio::test]
async fn two_handles_share_one_multiplex_actor() {
let station = Station::builder()
.build()
.await
.expect("Station::build");
let s1 = SubscriptionSet::new().add(
ExchangeId::Binance,
"BTC-USDT",
AccountType::Spot,
[Stream::Trade],
);
let s2 = SubscriptionSet::new().add(
ExchangeId::Binance,
"BTC-USDT",
AccountType::Spot,
[Stream::Trade],
);
let h1 = station.subscribe(s1).await.expect("subscribe 1");
let h2 = station.subscribe(s2).await.expect("subscribe 2");
assert_eq!(station.active_streams(), 1, "expected 1 shared mux after 2 subscribes");
drop(h1);
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
assert_eq!(station.active_streams(), 1, "mux still alive while h2 holds it");
drop(h2);
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
assert_eq!(station.active_streams(), 0, "all handles dropped — mux should retire");
}