Files
VoelinClient/crates/voelin-core/tests/live.rs
T
Claude 216e21fec5 Rename the project to Voelin; packages hold only the app, tsgw is a Linux server package
The product is Voelin (app id io.github.faumaray.Voelin), everywhere:
- crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary
  tsc-desktop -> voelin, the development CLI tsctl -> voelinctl;
- the Android app: applicationId, Kotlin package io.github.faumaray.voelin,
  VoelinApp, libvoelin_android.so (JNI class names follow);
- TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* ->
  voelin.*, signing secrets VOELIN_SIGNING_*;
- the data/config/cache/state folder tsc -> voelin, the keyring service,
  thread names, the dev compose project;
- desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs.
The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env
vars, the tsgw.v1+json protocol, the tsgw image. The window title and the
About page show "Voelin <version>" from voelin_platform::APP_NAME.

Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs,
Flatpak). voelinctl is a development tool and in no package. tsgw is for
servers and now its own Linux package, tsgw_<v>_amd64.deb and
tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit
(packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and
dependencies of its own (no GUI libraries). docs/gateway-admin.md has an
Install section.

Fixes:
- package-windows: makensis on Windows found no file through "D:/a/..."
  paths; pass Windows paths (cygpath -w).
- StartupWMClass is the app id, which the app sets as its X11 WM_CLASS
  (it was the binary name, so desktops could not match the window).
- Gradle wrapper download timeout 10 s -> 60 s (slow proxies).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-26 21:11:17 +00:00

125 lines
3.7 KiB
Rust

//! Engine against the development servers (dev/docker-compose.yml).
//! Runs only with `VOELIN_LIVE=1`; `scripts/it-smoke.sh` sets it.
use std::time::Duration;
use tokio::sync::broadcast::Receiver;
use tokio::time::{Instant, timeout_at};
use voelin_core::{Command, Engine, Event, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_model::ChatTarget;
fn live() -> bool {
std::env::var("VOELIN_LIVE").is_ok_and(|v| v == "1")
}
/// Wait for an event matching `f`, failing after 20 s.
async fn wait_for(
rx: &mut Receiver<Event>,
what: &str,
mut f: impl FnMut(&Event) -> bool,
) -> Event {
let deadline = Instant::now() + Duration::from_secs(20);
loop {
match timeout_at(deadline, rx.recv()).await {
Ok(Ok(e)) if f(&e) => return e,
Ok(Ok(Event::Error { message, .. })) => eprintln!("engine error: {message}"),
Ok(_) => {}
Err(_) => panic!("timed out waiting for {what}"),
}
}
}
async fn engine_roundtrip(voice_addr: &str, query: voelin_query::Connect) {
let engine = Engine::start();
let mut events = engine.subscribe();
let nick = format!("engine-{}", std::process::id() % 10_000);
// Session 1: voice.
engine.send(Command::ConnectVoice {
session: 1,
options: Box::new(VoiceOptions::new(voice_addr, &nick)),
});
wait_for(&mut events, "voice connected", |e| {
matches!(e, Event::State { session: 1, state } if state.voice == VoiceState::Connected && state.own_channel.is_some())
})
.await;
// Session 2: invisible, through own query credentials.
engine.send(Command::ObserveQuery { session: 2, connect: Box::new(query) });
let (mut observing, mut sees_voice_client) = (false, false);
wait_for(&mut events, "query presence with the voice client", |e| {
match e {
Event::State { session: 2, state } => {
observing = state.observe == ObserveState::Observing
&& state.presence_source == Some(Source::Query);
}
Event::Presence { session: 2, presence } => {
sees_voice_client = presence.clients.values().any(|c| c.nickname == nick);
}
_ => {}
}
observing && sees_voice_client
})
.await;
// Channel chat: voice -> relay.
engine.send(Command::OpenChat { session: 2, target: ChatTarget::Channel(1) });
tokio::time::sleep(Duration::from_secs(2)).await;
engine.send(Command::SendChat {
session: 1,
target: ChatTarget::Channel(1),
text: "engine-hello".into(),
});
wait_for(&mut events, "relayed channel message", |e| {
matches!(e, Event::Chat { session: 2, message } if message.text == "engine-hello" && message.target == ChatTarget::Channel(1))
})
.await;
// And back: relay -> voice.
engine.send(Command::SendChat {
session: 2,
target: ChatTarget::Channel(1),
text: "from-query".into(),
});
wait_for(
&mut events,
"message posted by the relay",
|e| matches!(e, Event::Chat { session: 1, message } if message.text.ends_with("from-query")),
)
.await;
engine.send(Command::CloseSession { session: 1 });
engine.send(Command::CloseSession { session: 2 });
tokio::time::sleep(Duration::from_millis(500)).await;
}
fn query(transport: voelin_query::Transport, addr: &str) -> voelin_query::Connect {
voelin_query::Connect {
transport,
addr: addr.into(),
user: "serveradmin".into(),
secret: Some("voelin-dev-admin".into()),
server_port: Some(9987),
server_id: None,
line: voelin_query::LineOptions { rate_limit: None, ..Default::default() },
}
}
#[tokio::test(flavor = "multi_thread")]
async fn ts6_engine() {
if !live() {
return;
}
engine_roundtrip("127.0.0.1:9988", query(voelin_query::Transport::Ssh, "127.0.0.1:10022"))
.await;
}
#[tokio::test(flavor = "multi_thread")]
async fn ts3_engine() {
if !live() {
return;
}
engine_roundtrip("127.0.0.1:9987", query(voelin_query::Transport::Raw, "127.0.0.1:10011"))
.await;
}