Add symbol conflict test.

This commit is contained in:
Alejandro Cabeza Romero 2026-05-18 15:25:33 +02:00
parent 653c9295e4
commit cec59f55a8
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
5 changed files with 64 additions and 0 deletions

8
rust/Cargo.lock generated
View File

@ -237,6 +237,14 @@ dependencies = [
"logos-blockchain-circuits-types",
]
[[package]]
name = "logos-blockchain-circuits-tests"
version = "0.5.0"
dependencies = [
"logos-blockchain-circuits-pol-sys",
"logos-blockchain-circuits-poq-sys",
]
[[package]]
name = "logos-blockchain-circuits-types"
version = "0.5.0"

View File

@ -15,6 +15,7 @@ members = [
"logos-blockchain-circuits-pol-sys",
"logos-blockchain-circuits-poq-sys",
"logos-blockchain-circuits-signature-sys",
"logos-blockchain-circuits-tests",
"logos-blockchain-circuits-types",
"logos-blockchain-circuits-common",
]

View File

@ -0,0 +1,10 @@
[package]
name = "logos-blockchain-circuits-tests"
edition.workspace = true
license.workspace = true
version.workspace = true
publish = false
[dev-dependencies]
lbc-pol-sys = { workspace = true, features = ["prebuilt"] }
lbc-poq-sys = { workspace = true, features = ["prebuilt"] }

View File

@ -0,0 +1,22 @@
pub mod roots {
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
pub static TESTS: LazyLock<PathBuf> =
LazyLock::new(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")));
pub static REPOSITORY: LazyLock<&Path> =
LazyLock::new(|| TESTS.parent().expect("Failed to find the repository root."));
pub static POL: LazyLock<PathBuf> =
LazyLock::new(|| REPOSITORY.join("logos-blockchain-circuits-pol-sys"));
pub static POQ: LazyLock<PathBuf> =
LazyLock::new(|| REPOSITORY.join("logos-blockchain-circuits-poq-sys"));
}
pub mod inputs {
use super::roots;
use std::path::PathBuf;
use std::sync::LazyLock;
pub static POL: LazyLock<PathBuf> = LazyLock::new(|| roots::POL.join("sample.input.json"));
pub static POQ: LazyLock<PathBuf> = LazyLock::new(|| roots::POQ.join("sample.input.json"));
}

View File

@ -0,0 +1,23 @@
#[cfg(test)]
mod tests {
use lbc_poq_sys::PoqWitnessInput;
use logos_blockchain_circuits_tests::inputs;
#[test]
fn test_both_circuits_generate_witness() {
let pol_inputs_raw = std::fs::read_to_string(inputs::POL.as_path()).unwrap();
let pol_witness_input = lbc_pol_sys::PolWitnessInput::new(pol_inputs_raw).unwrap();
// Each sys crate compiles a copy of the same C++ runtime (loadCircuit, get_size_of_witness, …)
// under identical symbol names. When two crates are linked into the same binary, the linker
// silently keeps one definition of each symbol, so one circuit ends up using the other's
// size constants — corrupting dat parsing and causing a SIGSEGV.
// This test reproduces the conflict by calling generate_witness on both circuits in the same binary.
let _pol_witness = lbc_pol_sys::generate_witness(&pol_witness_input);
let inputs_json_raw = std::fs::read_to_string(inputs::POQ.as_path()).unwrap();
let inputs_json = PoqWitnessInput::new(inputs_json_raw).unwrap();
let poq_result = lbc_poq_sys::generate_witness(&inputs_json);
assert!(poq_result.is_ok());
}
}