Skip to content

Commit 0d52ad4

Browse files
committed
Create test-utils crate.
To speed up compilation of test tools.
1 parent 2e40551 commit 0d52ad4

File tree

20 files changed

+81
-47
lines changed

20 files changed

+81
-47
lines changed

Cargo.lock

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"sailfish-rbc",
1111
"sailfish-types",
1212
"tests",
13+
"test-utils",
1314
"timeboost",
1415
"timeboost-builder",
1516
"timeboost-config",
@@ -94,7 +95,7 @@ thiserror = "2.0"
9495
tokio = { version = "1", default-features = false, features = ["full"] }
9596
tokio-stream = "0.1.17"
9697
tokio-tungstenite = { version = "0.27.0", features = ["rustls-tls-webpki-roots", "url"] }
97-
tokio-util = { version = "0.7.15", features = ["compat"] }
98+
tokio-util = { version = "0.7.15", features = ["compat", "rt"] }
9899
toml = "0.9"
99100
toml_edit = "0.22"
100101
tonic = "0.14.1"

justfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ build-contracts:
2222
forge build
2323

2424
[private]
25-
build-tools:
26-
cargo build --release --features bin --bin run --bin port-alloc
25+
build-test-utils:
26+
cargo build --release -p test-utils --features ports
2727

2828
####################
2929
###CHECK COMMANDS###
@@ -126,25 +126,25 @@ mkconfig_nitro DATETIME *ARGS:
126126
--output "test-configs/nitro-ci-committee" {{ARGS}}
127127

128128
verify_blocks *ARGS:
129-
cargo run --release --bin block-verifier --features bin {{ARGS}}
129+
cargo run --release --bin block-verifier --features verifier {{ARGS}}
130130

131131
####################
132132
####TEST COMMANDS###
133133
####################
134-
test *ARGS: build-tools
134+
test *ARGS: build-test-utils
135135
target/release/run --with target/release/port-alloc cargo nextest run {{ARGS}}
136136
@if [ "{{ARGS}}" == "" ]; then cargo test --doc; fi
137137

138138
test-contracts: build-contracts
139139
forge test
140140

141-
test_ci *ARGS: build-tools
141+
test_ci *ARGS: build-test-utils
142142
env {{LOG_LEVELS}} NO_COLOR=1 target/release/run \
143143
--with target/release/port-alloc \
144144
-- cargo nextest run --workspace {{ARGS}}
145145
env {{LOG_LEVELS}} NO_COLOR=1 cargo test --doc {{ARGS}}
146146

147-
test-individually: build-tools
147+
test-individually: build-test-utils
148148
@for pkg in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name'); do \
149149
echo "Testing $pkg"; \
150150
target/release/run \

test-utils/Cargo.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "test-utils"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
7+
[features]
8+
ports = ["dep:minicbor", "dep:minicbor-io", "dep:tokio-util"]
9+
verifier = ["dep:alloy", "dep:timeboost-utils"]
10+
11+
[dependencies]
12+
anyhow = { workspace = true }
13+
clap = { workspace = true }
14+
futures = { workspace = true }
15+
tokio = { workspace = true }
16+
tracing = { workspace = true }
17+
# optional
18+
alloy = { workspace = true, optional = true }
19+
minicbor = { workspace = true, optional = true }
20+
minicbor-io = { workspace = true, optional = true }
21+
tokio-util = { workspace = true, optional = true }
22+
timeboost-utils = { path = "../timeboost-utils", optional = true }
23+
24+
[[bin]]
25+
name = "block-verifier"
26+
path = "src/binaries/block-verifier.rs"
27+
required-features = ["verifier"]
28+
29+
[[bin]]
30+
name = "run"
31+
path = "src/binaries/run.rs"
32+
33+
[[bin]]
34+
name = "port-alloc"
35+
path = "src/binaries/port-alloc.rs"
36+
required-features = ["ports"]
File renamed without changes.

tests/src/binaries/port-alloc.rs renamed to test-utils/src/binaries/port-alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88

99
use anyhow::{Context, Result};
1010
use minicbor_io::{AsyncReader, AsyncWriter};
11-
use timeboost_utils::ports::{ALLOCATOR_PORT, Request, Response};
11+
use test_utils::ports::{ALLOCATOR_PORT, Request, Response};
1212
use tokio::net::{TcpListener, TcpStream};
1313
use tokio_util::{
1414
compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt},
File renamed without changes.

test-utils/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[cfg(feature = "ports")]
2+
pub mod ports;
File renamed without changes.

tests/Cargo.toml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rand = { workspace = true }
2121
sailfish = { path = "../sailfish", features = ["test"] }
2222
sailfish-types = { path = "../sailfish-types" }
2323
serde = { workspace = true }
24+
test-utils = { path = "../test-utils", features = ["ports"]}
2425
timeboost = { path = "../timeboost" }
2526
timeboost-utils = { path = "../timeboost-utils" }
2627
tokio = { workspace = true }
@@ -29,25 +30,3 @@ tokio-util = { workspace = true }
2930
tracing = { workspace = true }
3031
turmoil = { workspace = true }
3132
url = { workspace = true }
32-
# optional:
33-
anyhow = { workspace = true, optional = true }
34-
clap = { workspace = true, optional = true }
35-
minicbor-io = { workspace = true, optional = true }
36-
37-
[features]
38-
bin = ["dep:anyhow", "dep:clap", "dep:minicbor-io"]
39-
40-
[[bin]]
41-
name = "block-verifier"
42-
path = "src/binaries/block-verifier.rs"
43-
required-features = ["bin"]
44-
45-
[[bin]]
46-
name = "run"
47-
path = "src/binaries/run.rs"
48-
required-features = ["bin"]
49-
50-
[[bin]]
51-
name = "port-alloc"
52-
path = "src/binaries/port-alloc.rs"
53-
required-features = ["bin"]

0 commit comments

Comments
 (0)