Skip to content

Commit 81f6bf3

Browse files
benthecarmanclaude
andcommitted
Add e2e config startup tests
Test server startup with various config settings: optional fields, log levels, TLS hosts, LSPS2 variations, and bitcoind RPC with localhost hostname. Add negative tests for invalid configs ensuring proper error messages. Dedicated chain source tests verify each backend explicitly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7ce1cbc commit 81f6bf3

3 files changed

Lines changed: 551 additions & 32 deletions

File tree

e2e-tests/src/lib.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,46 @@ fn spawn_server(
354354
(child, params)
355355
}
356356

357+
/// Start ldk-server with the given config and expect it to fail (exit non-zero).
358+
/// Returns the stderr output for assertion in tests.
359+
pub fn start_expect_failure(
360+
bitcoind: &TestBitcoind, config_fn: impl FnOnce(&TestServerParams) -> String,
361+
) -> String {
362+
let (mut child, ..) = spawn_server(bitcoind, config_fn);
363+
364+
let timeout = Duration::from_secs(30);
365+
let start = std::time::Instant::now();
366+
loop {
367+
match child.try_wait() {
368+
Ok(Some(_)) => break,
369+
Ok(None) => {
370+
if start.elapsed() > timeout {
371+
let _ = child.kill();
372+
panic!(
373+
"Server did not exit within {:?} — it may have started successfully \
374+
instead of failing",
375+
timeout
376+
);
377+
}
378+
std::thread::sleep(Duration::from_millis(100));
379+
},
380+
Err(e) => panic!("Failed to wait for ldk-server process: {}", e),
381+
}
382+
}
383+
384+
let output = child
385+
.wait_with_output()
386+
.unwrap_or_else(|e| panic!("Failed to read ldk-server output: {}", e));
387+
388+
assert!(
389+
!output.status.success(),
390+
"Expected server to fail but it exited with status: {}",
391+
output.status
392+
);
393+
394+
String::from_utf8_lossy(&output.stderr).to_string()
395+
}
396+
357397
/// Find an available TCP port by binding to port 0.
358398
pub fn find_available_port() -> u16 {
359399
let listener = TcpListener::bind("127.0.0.1:0").unwrap();

0 commit comments

Comments
 (0)