Monorepo for Tangled tangled.org
8

Configure Feed

Select the types of activity you want to include in your feed.

at master 2.3 kB View raw
1use std::num::NonZeroUsize; 2use std::time::Duration; 3 4use bobbin_sim::workloads::{SlingshotFlap, SlingshotFlapConfig}; 5use bobbin_sim::{Sim, SimConfig, SimOutcome}; 6use tokio::runtime::Builder as TokioBuilder; 7 8#[test] 9fn shadow_buffer_bounded_by_cross_did_attachment_cohort_and_drains_to_zero() { 10 let cfg = SlingshotFlapConfig { 11 cross_did_stars: 5000, 12 normal_latency_ms: 2, 13 brownout_start_ms: 0, 14 brownout_duration_ms: 0, 15 brownout_latency_ms: 0, 16 brownout_enabled: false, 17 hydrant_send_timeout_ms: 30_000, 18 hydrant_frame_pace_us: 1_000, 19 omit_target_repos: false, 20 emit_live_promotion_frame: false, 21 }; 22 let mut sim_config = SimConfig::new(7); 23 sim_config.parallelism = NonZeroUsize::new(16).unwrap(); 24 sim_config.max_virtual_runtime = Duration::from_secs(120); 25 26 let workload = Box::new(SlingshotFlap::new(cfg.clone())); 27 let runtime = TokioBuilder::new_current_thread() 28 .enable_all() 29 .start_paused(true) 30 .build() 31 .expect("build current_thread runtime"); 32 let report = runtime.block_on(Sim::new(sim_config, workload).run()); 33 34 let stars = cfg.cross_did_stars as u64; 35 let total = stars * 2; 36 37 assert_eq!( 38 report.outcome, 39 SimOutcome::Passed, 40 "expected clean drain with brownout disabled, got {:?} reason={:?}", 41 report.outcome, 42 report.failure_reason, 43 ); 44 assert_eq!(report.events_processed, total); 45 46 let s = report.warming_shadow; 47 assert_eq!( 48 s.enqueued_total, stars, 49 "every cross-DID star must enqueue exactly once: {s:?}", 50 ); 51 assert_eq!( 52 s.drained_via_observe_total, stars, 53 "every observe must drain its corresponding enqueue (stars send their repos in this workload): {s:?}", 54 ); 55 assert_eq!( 56 s.distinct_keys_seen, stars, 57 "one (owner, rkey) pair per repo: {s:?}", 58 ); 59 assert_eq!( 60 s.residual, 0, 61 "no entry must remain pending after observe arrives: {s:?}", 62 ); 63 assert!( 64 s.max_concurrent > 0 && s.max_concurrent <= stars, 65 "peak depth must be bounded by the cross-DID attachment cohort, got max_concurrent={} for {stars} stars: {s:?}", 66 s.max_concurrent, 67 ); 68}