Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ ariadne = "=0.5.0"
[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["js"] }

[dev-dependencies]
# Tests always build with `serde`, so test code needs no `cfg(feature = "serde")`.
simplicityhl = { path = ".", default-features = false, features = ["serde"] }

[workspace]
members = ["codegen", "fuzz", "bitcoind-tests"]

Expand Down
24 changes: 1 addition & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod source;
mod template_program;
pub mod unstable;

#[cfg(all(test, feature = "serde"))]
#[cfg(test)]
mod error_cases;
#[cfg(feature = "serde")]
mod serde;
Expand Down Expand Up @@ -701,7 +701,6 @@ pub(crate) mod tests {
}
}

#[cfg(feature = "serde")]
pub fn with_argument_file<P: AsRef<Path>>(
self,
arguments_file_path: P,
Expand Down Expand Up @@ -775,7 +774,6 @@ pub(crate) mod tests {
.with_arguments(Arguments::default())
}

#[cfg(feature = "serde")]
pub fn with_witness_file<P: AsRef<Path>>(
self,
witness_file_path: P,
Expand Down Expand Up @@ -808,7 +806,6 @@ pub(crate) mod tests {
}
}

#[cfg(feature = "serde")]
pub fn get_encoding(self) -> String {
let program_bytes = self.program.commit().to_vec_without_witness();
Base64Display::new(&program_bytes, &STANDARD).to_string()
Expand Down Expand Up @@ -870,7 +867,6 @@ pub(crate) mod tests {
}
}

#[cfg(feature = "serde")]
pub fn get_encoding_with_witness(self) -> (String, String) {
let (program_bytes, witness_bytes) = self.program.redeem().to_vec_with_witness();
(
Expand Down Expand Up @@ -1142,7 +1138,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn sighash_non_interactive_fee_bump() {
let mut t = TestCase::program_file("./examples/non_interactive_fee_bump.simf")
.with_witness_file("./examples/non_interactive_fee_bump.wit");
Expand All @@ -1153,7 +1148,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn escrow_with_delay_timeout() {
TestCase::program_file("./examples/escrow_with_delay.simf")
.with_sequence(1000)
Expand All @@ -1170,7 +1164,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn hodl_vault() {
TestCase::program_file("./examples/hodl_vault.simf")
.with_lock_time(1000)
Expand All @@ -1180,7 +1173,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn htlc_complete() {
TestCase::program_file("./examples/htlc.simf")
.print_sighash_all()
Expand All @@ -1189,7 +1181,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn kitchen_sink() {
TestCase::template_file_with_unstable(
"./examples/kitchen_sink.simf",
Expand All @@ -1201,7 +1192,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn last_will_inherit() {
TestCase::program_file_with_unstable("./examples/last_will.simf", UnstableFeatures::all())
.with_sequence(25920)
Expand Down Expand Up @@ -1320,7 +1310,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn p2ms() {
TestCase::program_file("./examples/p2ms.simf")
.print_sighash_all()
Expand All @@ -1329,7 +1318,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn p2pk() {
TestCase::template_file("./examples/p2pk.simf")
.with_argument_file("./examples/p2pk.args")
Expand All @@ -1339,7 +1327,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn p2pkh() {
TestCase::program_file("./examples/p2pkh.simf")
.print_sighash_all()
Expand All @@ -1348,7 +1335,6 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn presigned_vault_complete() {
TestCase::program_file("./examples/presigned_vault.simf")
.with_sequence(1000)
Expand All @@ -1358,47 +1344,41 @@ pub(crate) mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn sighash_all_anyonecanpay() {
TestCase::program_file("./examples/sighash_all_anyonecanpay.simf")
.with_witness_file("./examples/sighash_all_anyonecanpay.wit")
.assert_run_success();
}

#[test]
#[cfg(feature = "serde")]
fn sighash_all_anyprevout() {
TestCase::program_file("./examples/sighash_all_anyprevout.simf")
.with_witness_file("./examples/sighash_all_anyprevout.wit")
.assert_run_success();
}

#[test]
#[cfg(feature = "serde")]
fn sighash_all_anyprevoutanyscript() {
TestCase::program_file("./examples/sighash_all_anyprevoutanyscript.simf")
.with_witness_file("./examples/sighash_all_anyprevoutanyscript.wit")
.assert_run_success();
}

#[test]
#[cfg(feature = "serde")]
fn sighash_none() {
TestCase::program_file("./examples/sighash_none.simf")
.with_witness_file("./examples/sighash_none.wit")
.assert_run_success();
}

#[test]
#[cfg(feature = "serde")]
fn sighash_single() {
TestCase::program_file("./examples/sighash_single.simf")
.with_witness_file("./examples/sighash_single.wit")
.assert_run_success();
}

#[test]
#[cfg(feature = "serde")]
fn transfer_with_timeout_transfer() {
TestCase::program_file("./examples/transfer_with_timeout.simf")
.print_sighash_all()
Expand Down Expand Up @@ -1571,7 +1551,6 @@ fn main() {
.any(|d| matches!(d.error(), Error::RawHashJetsUnavailable)));
}

#[cfg(feature = "serde")]
mod regression {
use super::TestCase;

Expand Down Expand Up @@ -1826,7 +1805,6 @@ fn main() {
}

#[test]
#[cfg(feature = "serde")]
fn enum_match_witness_file_variant_name() {
// The witness file names the variant; resolution constructs the
// enum value at the declared type.
Expand Down
6 changes: 0 additions & 6 deletions src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ mod tests {
use super::*;
use crate::ast::ElementsJetHinter;
use crate::parse::ParseFromStr;
#[cfg(feature = "serde")]
use crate::str::Identifier;
#[cfg(feature = "serde")]
use crate::types::{EnumInfo, EnumVariantInfo, TypeConstructible};
use crate::value::ValueConstructible;
use crate::{ast, parse, CompiledProgram, SatisfiedProgram};
Expand Down Expand Up @@ -438,7 +436,6 @@ fn main() {
}

#[test]
#[cfg(feature = "serde")]
fn unresolved_values_resolve_against_declared_types() {
let u32_ty = ResolvedType::parse_from_str("u32").unwrap();
let sig_ty = ResolvedType::parse_from_str("Signature").unwrap();
Expand Down Expand Up @@ -494,7 +491,6 @@ fn main() {
}

#[test]
#[cfg(feature = "serde")]
fn unresolved_values_parse_from_json() {
// Bare strings and legacy value/type maps may be mixed in one file.
let s = r#"{
Expand Down Expand Up @@ -523,7 +519,6 @@ fn main() {
}

#[test]
#[cfg(feature = "serde")]
fn enum_witness_resolves_by_variant_name() {
let variants: Arc<[EnumVariantInfo]> = ["Inherit", "ColdSpend", "HotSpend"]
.into_iter()
Expand Down Expand Up @@ -564,7 +559,6 @@ fn main() {
}

#[test]
#[cfg(feature = "serde")]
fn enum_witness_resolves_inside_composite_types() {
let variants: Arc<[EnumVariantInfo]> = ["Hot", "Cold"]
.into_iter()
Expand Down
3 changes: 1 addition & 2 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ fn cli_reserved_crate_mapping_fails() {

/// The output carries the version of the compiler that produced it, so the exact
/// compiler can be identified from a shared artifact (different versions can
/// produce different CMRs from the same source). JSON output requires `serde`.
#[cfg(feature = "serde")]
/// produce different CMRs from the same source).
#[test]
fn cli_output_includes_compiler_version() {
let file = Path::new(env!("CARGO_TARGET_TMPDIR")).join("output_version.simf");
Expand Down
Loading