Skip to content

Commit c3c674c

Browse files
BiliqisOg4titanx
andauthored
feat(zint): support foundry tests (#328)
* feat(zint): add initial implementation of Zink testing utilities and CLI * feat(zint): update Ztest testing utilities and correct path * feat(zint): support foundry tests * fix(ci): remove unnecessary feat * feat(zint): support foundry tests * feat(zint): support foundry tests --------- Co-authored-by: g4titanx <g4titan1@gmail.com>
1 parent 9ed8642 commit c3c674c

File tree

20 files changed

+508
-14
lines changed

20 files changed

+508
-14
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
- name: Build Examples
2626
run: cargo build --examples --target wasm32-unknown-unknown --release
2727

28+
- name: Build and Install zint-cli
29+
run: |
30+
cargo build --release -p zint-cli
31+
cargo install --path crates/zint/cli
32+
2833
- name: Run Tests
2934
run: cargo nextest run --workspace --no-fail-fast --release
3035

@@ -33,10 +38,17 @@ jobs:
3338

3439
- name: Test Elko Addition Example
3540
run: |
36-
cargo run -p elko -- new addition
37-
cd addition
38-
cargo run -p elko --manifest-path ../Cargo.toml -- build
39-
cargo test
41+
cargo run -p elko -- new addition
42+
cd addition
43+
cargo run -p elko --manifest-path ../Cargo.toml -- build
44+
cargo test
45+
46+
- name: Test Foundry Integration
47+
run: |
48+
cd crates/zint/storage
49+
forge build
50+
cargo zint new
51+
cargo zint run
4052
4153
check:
4254
name: Check

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ members = [
77
"codegen",
88
"compiler",
99
"compiler/filetests",
10+
"crates/zint",
11+
"crates/zint/cli",
1012
"evm/opcodes",
1113
"evm/abi",
1214
"zink/abi",
1315
"zink/codegen",
1416
"zink/elko",
15-
"zink/zint",
1617
"zink/abi-macro",
1718
]
1819
resolver = "2"
@@ -28,6 +29,7 @@ repository = "https://github.com/clearloop/zink.git"
2829
[workspace.dependencies]
2930
anyhow = "1.0.79"
3031
cargo_metadata = "0.18.1"
32+
clap = { version = "4.5.35", features = ["derive"] }
3133
ccli = "0.0.1"
3234
colored = "2.1.0"
3335
etc = "0.1.19"
@@ -71,7 +73,7 @@ zink = { path = ".", version = "0.1.12" }
7173
zink-abi-macro = { path = "zink/abi-macro", version = "0.1.12" }
7274
zink-codegen = { path = "zink/codegen", version = "0.1.12" }
7375
zinkc = { path = "compiler", version = "0.1.12" }
74-
zint = { path = "zink/zint", version = "0.1.12" }
76+
zint = { path = "crates/zint", version = "0.1.12" }
7577

7678
[workspace.metadata.conta]
7779
packages = [
@@ -83,6 +85,7 @@ packages = [
8385
"zink-codegen",
8486
"zink-abi-macro",
8587
"zink",
88+
"cargo-zint",
8689
"elko",
8790
]
8891

@@ -111,6 +114,7 @@ zink-codegen.workspace = true
111114
zink-abi-macro = { workspace = true, optional = true }
112115
zabi.workspace = true
113116
smallvec.workspace = true
117+
clap.workspace = true
114118

115119
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
116120
tiny-keccak.workspace = true
File renamed without changes.
File renamed without changes.

crates/zint/cli/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "zint-cli"
3+
description = "CLI tool for Zink testing with Foundry projects"
4+
version.workspace = true
5+
authors.workspace = true
6+
edition.workspace = true
7+
license.workspace = true
8+
homepage.workspace = true
9+
repository.workspace = true
10+
11+
[[bin]]
12+
name = "cargo-zint"
13+
path = "src/main.rs"
14+
15+
[dependencies]
16+
anyhow.workspace = true
17+
cargo_metadata.workspace = true
18+
clap.workspace = true
19+
serde.workspace = true
20+
serde_json.workspace = true
21+
toml.workspace = true
22+
zint.workspace = true
23+
zink.workspace = true
24+
25+
[dev-dependencies]
26+
tempfile.workspace = true
27+
28+
[build-dependencies]
29+
cargo_metadata.workspace = true

crates/zint/cli/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use cargo_metadata::MetadataCommand;
2+
3+
fn main() {
4+
// Rerun the build script if Cargo.toml changes
5+
println!("cargo:rerun-if-changed=Cargo.toml");
6+
7+
// Fetch metadata from the workspace
8+
let metadata = MetadataCommand::new()
9+
.manifest_path("Cargo.toml")
10+
.exec()
11+
.expect("Failed to fetch cargo metadata");
12+
13+
// Find the zink package in the workspace
14+
let zink_version = metadata
15+
.packages
16+
.iter()
17+
.find(|p| p.name == "zink")
18+
.map(|p| p.version.to_string())
19+
.expect("Could not find zink dependency in metadata");
20+
21+
// Emit the version as a cargo key-value pair
22+
println!("cargo:ZINK_VERSION={}", zink_version);
23+
}

0 commit comments

Comments
 (0)