diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6149a8dd3..11401b800 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -265,6 +265,61 @@ jobs: path: target/release/mina retention-days: 7 + unit-tests: + runs-on: ubuntu-24.04 + steps: + - name: Git checkout + uses: actions/checkout@v5 + + - name: Load versions + uses: ./.github/actions/load-versions + + - name: Setup build dependencies + uses: ./.github/actions/setup-build-deps + + - name: Setup Rust + uses: ./.github/actions/setup-rust + with: + toolchain: ${{ env.RUST_STABLE_VERSION }} + cache-prefix: unit-tests-${{ env.CACHE_VERSION }} + + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest + + # TODO: add this to the makefile + - name: Run unit tests + run: | + cargo nextest run --workspace --lib \ + --exclude mina-core \ + --exclude mina-fuzzer \ + --exclude mina-macros \ + --exclude mina-p2p-messages \ + --exclude poseidon \ + --exclude snark \ + --exclude p2p \ + --exclude salsa-simple \ + --exclude p2p-testing \ + --exclude libp2p-rpc-behaviour \ + --exclude node \ + --exclude mina-node-account \ + --exclude vrf \ + --exclude mina-node-common \ + --exclude mina-node-native \ + --exclude mina-node-web \ + --exclude mina-node-invariants \ + --exclude mina-node-testing \ + --exclude cli \ + --exclude replay_dynamic_effects \ + --exclude mina-transport \ + --exclude mina-bootstrap-sandbox \ + --exclude mina-gossipsub-sandbox \ + --exclude hash-tool \ + --exclude ledger-tool \ + --exclude transaction_fuzzer \ + --exclude mina-archive-breadcrumb-compare \ + --exclude webrtc-sniffer + # --exclude mina-tree + account-tests: timeout-minutes: 20 runs-on: ubuntu-24.04 diff --git a/ledger/src/proofs/transaction.rs b/ledger/src/proofs/transaction.rs index b0f68f2a3..f5c232544 100644 --- a/ledger/src/proofs/transaction.rs +++ b/ledger/src/proofs/transaction.rs @@ -4364,6 +4364,7 @@ mod tests_with_wasm { #[cfg(test)] pub(super) mod tests { + use core::panic; use std::path::Path; use ::poseidon::hash::params::MINA_ZKAPP_EVENT; @@ -4399,13 +4400,6 @@ pub(super) mod tests { PerformJob(mina_p2p_messages::v2::SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse), } - pub fn panic_in_ci() { - fn is_ci() -> bool { - std::env::var("CI").is_ok() - } - assert!(!is_ci(), "missing circuit files !"); - } - fn read_binprot(mut r: R) -> T where T: binprot::BinProtRead, @@ -4644,19 +4638,13 @@ pub(super) mod tests { #[test] #[ignore = "Failing due to circuits"] fn test_regular_tx() { - let Ok(data) = - // std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("request_signed.bin")) - // std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("rampup4").join("request_payment_0_rampup4.bin")) - std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join(devnet_circuit_directory()).join("tests").join("command-0-1.bin")) - // std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("rampup4").join("request_payment_1_rampup4.bin")) - // std::fs::read("/tmp/fee_transfer_1_rampup4.bin") - // std::fs::read("/tmp/coinbase_1_rampup4.bin") - // std::fs::read("/tmp/stake_0_rampup4.bin") - else { - eprintln!("request not found"); - panic_in_ci(); - return; - }; + let data = std::fs::read( + Path::new(env!("CARGO_MANIFEST_DIR")) + .join(devnet_circuit_directory()) + .join("tests") + .join("command-0-1.bin"), + ) + .unwrap(); let (statement, tx_witness, message) = extract_request(&data); let TransactionProver { @@ -4771,19 +4759,13 @@ pub(super) mod tests { #[test] #[ignore = "Failing due to circuits"] fn test_merge_proof() { - let Ok(data) = - // std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("request_signed.bin")) - // std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("rampup4").join("merge_0_rampup4.bin")) - std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join(devnet_circuit_directory()).join("tests").join("merge-100-0.bin")) - // std::fs::read("/tmp/minaa/mina-works-dump/merge-100-0.bin") - // std::fs::read("/tmp/fee_transfer_1_rampup4.bin") - // std::fs::read("/tmp/coinbase_1_rampup4.bin") - // std::fs::read("/tmp/stake_0_rampup4.bin") - else { - eprintln!("request not found"); - panic_in_ci(); - return; - }; + let data = std::fs::read( + Path::new(env!("CARGO_MANIFEST_DIR")) + .join(devnet_circuit_directory()) + .join("tests") + .join("merge-100-0.bin"), + ) + .unwrap(); let (statement, proofs, message) = extract_merge(&data); let TransactionProver { @@ -4821,16 +4803,13 @@ pub(super) mod tests { #[test] #[ignore = "Failing due to circuits"] fn test_proof_zkapp_sig() { - let Ok(data) = std::fs::read( + let data = std::fs::read( Path::new(env!("CARGO_MANIFEST_DIR")) .join(devnet_circuit_directory()) .join("tests") .join("command-1-0.bin"), - ) else { - eprintln!("request not found"); - panic_in_ci(); - return; - }; + ) + .unwrap(); let (statement, tx_witness, message) = extract_request(&data); @@ -4867,16 +4846,13 @@ pub(super) mod tests { #[test] #[ignore = "Failing due to circuits"] fn test_proof_zkapp_proof() { - let Ok(data) = std::fs::read( + let data = std::fs::read( Path::new(env!("CARGO_MANIFEST_DIR")) .join(devnet_circuit_directory()) .join("tests") .join("zkapp-command-with-proof-128-1.bin"), - ) else { - eprintln!("request not found"); - panic_in_ci(); - return; - }; + ) + .unwrap(); let (statement, tx_witness, message) = extract_request(&data); @@ -4911,16 +4887,13 @@ pub(super) mod tests { #[test] #[ignore = "Failing due to circuits"] fn test_block_proof() { - let Ok(data) = std::fs::read( + let data = std::fs::read( Path::new(env!("CARGO_MANIFEST_DIR")) .join(devnet_circuit_directory()) .join("tests") .join("block_input-2483246-0.bin"), - ) else { - eprintln!("request not found"); - panic_in_ci(); - return; - }; + ) + .unwrap(); let blockchain_input: v2::ProverExtendBlockchainInputStableV2 = read_binprot(&mut data.as_slice()); @@ -5038,8 +5011,7 @@ pub(super) mod tests { if !base_dir.exists() { eprintln!("{:?} not found", base_dir); - panic_in_ci(); - return; + panic!(); } let BlockProver { diff --git a/ledger/src/proofs/verification.rs b/ledger/src/proofs/verification.rs index 351c3ac34..1bc91bde4 100644 --- a/ledger/src/proofs/verification.rs +++ b/ledger/src/proofs/verification.rs @@ -1033,7 +1033,7 @@ mod tests { use mina_curves::pasta::Fp; use mina_p2p_messages::{binprot::BinProtRead, v2}; - use crate::proofs::{provers::devnet_circuit_directory, transaction::tests::panic_in_ci}; + use crate::proofs::provers::devnet_circuit_directory; use super::*; @@ -1041,6 +1041,7 @@ mod tests { use wasm_bindgen_test::wasm_bindgen_test as test; #[test] + #[ignore = "the file are missing"] fn test_verify_zkapp() { use mina_p2p_messages::{ binprot, @@ -1066,10 +1067,7 @@ mod tests { ]; for filename in cases { - let Ok(file) = std::fs::read(base_dir.join(filename)) else { - panic_in_ci(); - return; - }; + let file = std::fs::read(base_dir.join(filename)).expect("file not found"); let VerifyZkapp { vk,