Skip to content

Commit

Permalink
workflow test, fix root test
Browse files Browse the repository at this point in the history
  • Loading branch information
chudkowsky committed Aug 14, 2024
1 parent 42a4401 commit 5ca16a2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ci
on: push
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Format
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clippy
run: cargo clippy --fix
- name: Check for diff
run: git diff --exit-code
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- name: Prepare
shell: bash
run: |
sh scripts/0-venv.sh
sh scripts/1-compile.sh
sh scripts/2-merge.sh
ls -Rl examples/
- name: Build
run: cargo build --verbose
- name: Run prover
run: |
set -eux
cargo run -p prover -- --jwt-secret-key "asdf" --authorized-keys "0xd16b71c90dbf897e5964d2f267d04664b3c035036559d712994739ea6cf2fd9f" --message-expiration-time 60 --session-expiration-time 3600 &
while ! curl localhost:3000; do sleep 5; done
- name: Run tests
run: cargo test --no-fail-fast --workspace --verbose
2 changes: 1 addition & 1 deletion prover/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod tests {
#[tokio::test]
async fn test_generate_nonce() -> Result<(), ProveError> {
let private_key_hex: String =
r#"f91350db1ca372b54376b519be8bf73a7bbbbefc4ffe169797bc3f5ea2dec740"#.to_string();
r#"0xf91350db1ca372b54376b519be8bf73a7bbbbefc4ffe169797bc3f5ea2dec740"#.to_string();
let private_key_bytes: Vec<u8> = prefix_hex::decode(&private_key_hex)
.map_err(|err| ProveError::HexDecodeError(err.to_string()))?;
let mut private_key_array = [0u8; 32];
Expand Down
12 changes: 6 additions & 6 deletions prover/src/prove/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ mod tests {
use super::*;
use crate::auth::jwt::Claims;
use axum::Json;
use cairo0::root;
use common::Cairo0ProverInput;
use cairo1::root;
use common::Cairo1ProverInput;
use errors::ProveError;
use tokio::fs::File;
use tokio::io::AsyncReadExt;

#[tokio::test]
async fn test_root_with_input_json() {
// Read input data from resources/input.json
let input_json = read_json_file("../examples/CairoZero/prover_input.json")
let input_json: Cairo1ProverInput = read_json_file("../examples/Cairo/fibonacci_prover_input.json")
.await
.expect("Failed to read input JSON");

// Call the root function with the input data and actual PodmanRunner
let result = root(
Claims {
Expand All @@ -45,12 +45,12 @@ mod tests {
// Add assertions based on the expected behavior of root function
}

async fn read_json_file(file_path: &str) -> Result<Cairo0ProverInput, ProveError> {
async fn read_json_file(file_path: &str) -> Result<Cairo1ProverInput, ProveError> {
let mut file = File::open(file_path).await?;
let mut json_string = String::new();
file.read_to_string(&mut json_string).await?;

let json_value: Cairo0ProverInput = serde_json::from_str(&json_string)?;
let json_value: Cairo1ProverInput = serde_json::from_str(&json_string)?;

Ok(json_value)
}
Expand Down

0 comments on commit 5ca16a2

Please sign in to comment.