Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
lint-and-test:
name: lint and test
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- name: install stable rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: cache cargo
uses: Swatinem/rust-cache@v2

- name: run clippy
run: cargo clippy --workspace --all-targets

- name: run tests
run: cargo test --workspace
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ Then open a capture. The DZ-TOB dissector triggers on frame magic `0x445A`; the
tshark -X lua_script:spec/dz_depthofbook.lua -f "udp port 6000" -i lo
```

## Test fixtures

`server/tests/fixtures/hl_block_mode/` contains a reduced real Hyperliquid
by-block replay fixture used by the multicast e2e tests. The test replays the
fixture through the block-mode listener, captures TOB/DoB UDP output on
loopback sockets, normalizes runtime-only fields, and compares each stream to
golden packet files. The reduced unfiltered source extracts are versioned beside
the fixture, so the BTC-only replay inputs can be regenerated without fetching
from the validator again. The same fixture directory also includes a host-fetch
script for refreshing the source archive and goldens from an SSH-accessible HL
node. See `server/tests/fixtures/hl_block_mode/regenerate.md` for source paths
and regeneration commands.

## CI

GitHub Actions runs `cargo clippy --workspace --all-targets` and
`cargo test --workspace` on pushes to `main` and on pull requests.

## Caveats

- This server does **not** show untriggered trigger orders.
Expand Down
16 changes: 12 additions & 4 deletions server/src/listeners/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod tests {
use notify::{RecursiveMode, Watcher, recommended_watcher};
use rand::{Rng, SeedableRng, rngs::StdRng};
use std::{
io::{Seek, SeekFrom},
io::{Read, Seek, SeekFrom},
path::{Path, PathBuf},
sync::{Arc, Mutex},
time::Duration,
Expand Down Expand Up @@ -177,6 +177,7 @@ mod tests {
// will listen to file events and collect their results in the history field
struct TestListener {
file: Option<File>,
path: Option<PathBuf>,
history: Arc<Mutex<String>>,
}

Expand All @@ -189,9 +190,16 @@ mod tests {
&mut self.file
}

fn on_file_creation(&mut self, new_file: PathBuf, _event_source: EventSource) -> Result<()> {
let file = File::open(new_file)?;
fn on_file_creation(&mut self, new_file: PathBuf, event_source: EventSource) -> Result<()> {
if self.path.as_ref() == Some(&new_file) {
return Ok(());
}
let mut file = File::open(&new_file)?;
let mut buf = String::new();
file.read_to_string(&mut buf)?;
self.process_data(buf, event_source)?;
self.file = Some(file);
self.path = Some(new_file);
Ok(())
}

Expand All @@ -205,7 +213,7 @@ mod tests {

impl TestListener {
fn new(history: Arc<Mutex<String>>) -> Self {
Self { file: None, history }
Self { file: None, path: None, history }
}
}

Expand Down
Loading
Loading