mirror of
https://github.com/logos-blockchain/logos-blockchain-circuits.git
synced 2026-05-18 23:39:47 +00:00
Add symbol conflict test.
This commit is contained in:
parent
653c9295e4
commit
cec59f55a8
8
rust/Cargo.lock
generated
8
rust/Cargo.lock
generated
@ -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"
|
||||
|
||||
@ -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",
|
||||
]
|
||||
|
||||
10
rust/logos-blockchain-circuits-tests/Cargo.toml
Normal file
10
rust/logos-blockchain-circuits-tests/Cargo.toml
Normal 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"] }
|
||||
22
rust/logos-blockchain-circuits-tests/src/lib.rs
Normal file
22
rust/logos-blockchain-circuits-tests/src/lib.rs
Normal 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"));
|
||||
}
|
||||
23
rust/logos-blockchain-circuits-tests/tests/conflicts.rs
Normal file
23
rust/logos-blockchain-circuits-tests/tests/conflicts.rs
Normal 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());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user