use std::path::PathBuf;
use dusk_cdf::*;
#[test]
fn decoder_works() {
let asset = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("failed to find root workspace dir")
.join("assets")
.join("test.cdf")
.canonicalize()
.expect("failed to find CDF test asset");
let mut cdf = CircuitDescription::open(asset).expect("failed to read test asset");
assert_ne!(cdf.preamble().witnesses, 0);
assert_ne!(cdf.preamble().constraints, 0);
for idx in 0..cdf.preamble().witnesses {
cdf.fetch_witness(idx).expect("failed to read witness");
}
for idx in 0..cdf.preamble().constraints {
cdf.fetch_constraint(idx)
.expect("failed to read constraint");
}
cdf.fetch_witness(cdf.preamble().witnesses)
.expect_err("witness doesn't exist in the set");
cdf.fetch_constraint(cdf.preamble().constraints)
.expect_err("constraint doesn't exist in the set");
}