Skip to content

Commit ced15dd

Browse files
authored
Verify tipjar pause test targets (#433)
1 parent 559ce2f commit ced15dd

5 files changed

Lines changed: 83 additions & 4 deletions

File tree

.github/workflows/contract-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ jobs:
3333
# disk before `cargo test -p tipjar` runs.
3434
run: cargo build -p tipjar-v2-fixture --target wasm32v1-none --release
3535

36+
- name: Verify pause_tests / partial_pause_tests wiring
37+
# Guard against the orphaned-test-tree failure mode: confirm the two
38+
# root-level integration tests are still registered as real [[test]]
39+
# targets of the `tipjar` package (see tests/README.md).
40+
run: cargo test -p tipjar --test pause_tests --test partial_pause_tests -- --list
41+
3642
- name: Run tests
3743
run: cargo test -p tipjar
3844

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
# disk before `cargo test -p tipjar` runs.
3131
run: cargo build -p tipjar-v2-fixture --target wasm32v1-none --release
3232

33+
- name: Verify pause_tests / partial_pause_tests wiring
34+
# Guard against the orphaned-test-tree failure mode: confirm the two
35+
# root-level integration tests are still registered as real [[test]]
36+
# targets of the `tipjar` package (see tests/README.md).
37+
run: cargo test -p tipjar --test pause_tests --test partial_pause_tests -- --list
38+
3339
- name: Run unit & integration tests
3440
run: cargo test -p tipjar -- --test-threads=4
3541

contracts/tipjar/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use soroban_sdk::{
88
#[cfg(test)]
99
mod test;
1010
#[cfg(test)]
11+
mod test_coverage_gaps;
12+
#[cfg(test)]
1113
mod test_exhaustive;
1214
#[cfg(test)]
1315
mod test_invariants;
1416
#[cfg(test)]
1517
mod test_upgrade;
16-
#[cfg(test)]
17-
mod test_coverage_gaps;
1818

1919
/// Ledger TTL bump applied to instance and persistent storage on every write.
2020
const LEDGER_THRESHOLD: u32 = 100_000;

scripts/run-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ COVERAGE=${COVERAGE:-0}
88
echo "==> Building contract (WASM)..."
99
cargo build -p tipjar --target wasm32v1-none --release
1010

11+
echo "==> Building v2 upgrade test fixture (WASM)..."
12+
# contracts/tipjar/src/test_upgrade.rs embeds this via contractimport! at
13+
# compile time, so it must exist on disk before `cargo test -p tipjar` runs.
14+
cargo build -p tipjar-v2-fixture --target wasm32v1-none --release
15+
16+
echo "==> Verifying pause_tests / partial_pause_tests wiring..."
17+
# Guard against the orphaned-test-tree failure mode: confirm the two
18+
# root-level integration tests are still registered as real [[test]]
19+
# targets of the `tipjar` package (see tests/README.md).
20+
cargo test -p tipjar --test pause_tests --test partial_pause_tests -- --list
21+
1122
echo "==> Running unit & integration tests (threads=${THREADS})..."
1223
cargo test -p tipjar -- --test-threads="${THREADS}"
1324

tests/README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
# Tests Directory
22

3-
This folder is reserved for integration and end-to-end tests as the project grows.
3+
This folder holds **integration tests that are compiled as part of the
4+
`tipjar` package** (`contracts/tipjar`), even though the files live at the
5+
repo root rather than under `contracts/tipjar/tests/`.
46

5-
Current contract unit tests live in `contracts/tipjar/src/lib.rs` and use Soroban's testing framework.
7+
## Why the files are here, not under `contracts/tipjar/tests/`
8+
9+
`pause_tests.rs` and `partial_pause_tests.rs` share a common harness in
10+
`tests/common/mod.rs`. Cargo compiles `mod common;` fresh into each
11+
`[[test]]` binary, so a single shared `tests/common/` directory is the
12+
simplest way to avoid duplicating the harness across two packages.
13+
14+
Because Cargo's test auto-discovery only looks in a package's *own*
15+
`tests/` directory, these root-level files are **not** auto-discovered.
16+
They are wired in explicitly via `[[test]]` entries in
17+
`contracts/tipjar/Cargo.toml`:
18+
19+
```toml
20+
[[test]]
21+
name = "pause_tests"
22+
path = "../../tests/pause_tests.rs"
23+
24+
[[test]]
25+
name = "partial_pause_tests"
26+
path = "../../tests/partial_pause_tests.rs"
27+
```
28+
29+
## How to verify the wiring
30+
31+
These targets are real `[[test]]` targets of the `tipjar` package — they
32+
are **not** orphaned. You can confirm this directly:
33+
34+
```bash
35+
# 1. They appear as `test` targets of the `tipjar` package in cargo metadata:
36+
cargo metadata --no-deps --format-version 1 \
37+
| jq -r '.packages[] | select(.name=="tipjar") | .targets[] | select(.kind[0]=="test") | .name'
38+
# => pause_tests
39+
# => partial_pause_tests
40+
41+
# 2. They enumerate their expected test functions:
42+
cargo test -p tipjar --test pause_tests --test partial_pause_tests -- --list
43+
44+
# 3. They pass:
45+
cargo test -p tipjar --test pause_tests --test partial_pause_tests
46+
```
47+
48+
> Note: `cargo test -p tipjar` (the full suite) additionally compiles the
49+
> in-tree unit tests under `contracts/tipjar/src/`, which embed a v2 upgrade
50+
> fixture WASM via `soroban_sdk::contractimport!`. That fixture must be built
51+
> first — see `docs/UPGRADE_GUIDE.md` and `.github/workflows/test.yml`.
52+
> The two integration targets above do **not** depend on that fixture and can
53+
> be run independently.
54+
55+
## Other files in this directory
56+
57+
The remaining `*.rs` files (`core_functionality.rs`, `edge_cases.rs`,
58+
`security_tests.rs`, etc.) are **not** wired to any package and are not
59+
compiled by `cargo test`. They are legacy/scratch integration tests kept
60+
for reference; see `tests/README.md` history and the audit notes in
61+
`docs/SECURITY.md` for the orphaned-test-tree context.

0 commit comments

Comments
 (0)