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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ man soroban-debug
man soroban-debug-run
```

## CI / Developer Makefile Targets

For sandbox or restricted CI environments where socket bind may fail, use:

```bash
make ci-sandbox
```

This target runs formatting, lint, non-network tests, VS Code tests, and man-page checks while skipping loopback TCP network-dependent tests.

- `make test-rust-sandbox`: Run Rust tests excluding `parity_dap_server*` tests.
- `make test-rust-network`: Run only network-dependent parity server tests.

## Quick Start

### Basic Usage
Expand Down
8 changes: 8 additions & 0 deletions tests/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ pub fn can_bind_loopback() -> bool {
}
}
}

/// Allocate an ephemeral available port by binding to 0 and reading the assigned value.
/// The temporary listener is dropped after determining the port so it can be re-used.
/// This reduces brittle fixed-port usage in integration tests.
pub fn allocate_ephemeral_port() -> Option<u16> {
let listener = TcpListener::bind("127.0.0.1:0").ok()?;
listener.local_addr().ok().map(|addr| addr.port())
}
4 changes: 2 additions & 2 deletions tests/parity_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ fn parity_dap_server_starts_and_accepts_connection() {
use std::net::TcpStream;
use std::time::Duration;

let port = 19_230u16;
let port = network::allocate_ephemeral_port().expect("Failed to allocate ephemeral port");
let token = "parity-test-token-ok";

let mut server = std::process::Command::new(env!("CARGO_BIN_EXE_soroban-debug"))
Expand Down Expand Up @@ -370,7 +370,7 @@ fn parity_dap_server_rejects_invalid_token() {
use std::net::TcpStream;
use std::time::Duration;

let port = 19_231u16;
let port = network::allocate_ephemeral_port().expect("Failed to allocate ephemeral port");
let real_token = "real-parity-token";
let wrong_token = "wrong-parity-token";

Expand Down
9 changes: 6 additions & 3 deletions tests/remote_run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ fn test_remote_run_execution() {
wasm_path
}

// Allocate an ephemeral free port for this test.
let port = network::allocate_ephemeral_port().expect("Failed to allocate ephemeral port");

// Start server in background
let mut server_cmd = StdCommand::new(assert_cmd::cargo::cargo_bin!("soroban-debug"));

let mut server_child = server_cmd
.arg("server")
.arg("--port")
.arg("9245")
.arg(port.to_string())
.arg("--token")
.arg("secret")
.spawn()
Expand All @@ -76,7 +79,7 @@ fn test_remote_run_execution() {
ping_cmd
.arg("run")
.arg("--remote")
.arg("127.0.0.1:9245")
.arg(format!("127.0.0.1:{}", port))
.arg("--token")
.arg("secret")
.assert()
Expand All @@ -90,7 +93,7 @@ fn test_remote_run_execution() {
let assert = client_cmd
.arg("run")
.arg("--remote")
.arg("127.0.0.1:9245")
.arg(format!("127.0.0.1:{}", port))
.arg("--token")
.arg("secret")
.arg("--contract")
Expand Down
Loading