Skip to content

Commit 3ce087d

Browse files
committed
Merge #357: Lock human_encoding module under a feature
a86927e Add human_encoding feature (ivanlele) Pull request description: This PR introduces a new feature flag, `human_encoding`, which locks the module of the same name. It is a followup to the discussion in #354. ACKs for top commit: apoelstra: ACK a86927e; successfully ran local tests; thanks for the quick iteration! Tree-SHA512: b29dde060422c71269871952ea88adb080e2d723a4b727f4bbafe723c8dc9c5f824c6b442895f7114d63f1868a287799b90db0e159ca7c2f16eb034a51ba7ca9
2 parents 3d047c0 + a86927e commit 3ce087d

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ default = ["elements"]
1616
elements = ["dep:elements", "bitcoin"]
1717
test-utils = ["simplicity-sys/test-utils"]
1818
serde = ["dep:serde", "bitcoin/serde", "elements/serde"]
19+
human_encoding = ["dep:logos"]
1920

2021
[lib]
2122
name = "simplicity"
@@ -29,7 +30,7 @@ elements = { version = "0.25.0", optional = true, default-features = false }
2930
ghost-cell = { version = "0.2.6", default-features = false }
3031
hashes = { package = "bitcoin_hashes", version = "0.14" }
3132
hex = { package = "hex-conservative", version = "0.2.1" }
32-
logos = "0.15"
33+
logos = { version = "0.15", optional = true }
3334
simplicity-sys = { version = "0.6.2", path = "./simplicity-sys" }
3435
serde = { version = "1.0.103", features = ["derive"], optional = true }
3536

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ path = "fuzz_lib/lib.rs"
1616
libfuzzer-sys = "0.4"
1717
# We shouldn't need an explicit version on the next line, but Andrew's tools
1818
# choke on it otherwise. See https://github.com/nix-community/crate2nix/issues/373
19-
simplicity-lang = { path = "..", features = ["test-utils"], version = "0.7.0" }
19+
simplicity-lang = { path = "..", features = ["test-utils", "human_encoding"], version = "0.7.0" }
2020
old_simplicity = { package = "simplicity-lang", version = "0.3.1", default-features = false }
2121

2222
[dev-dependencies]

simpcli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2018"
77

88
[dependencies]
99
# todo add lexopt for command line parsing
10-
simplicity-lang = { version = "0.7.0", path = "..", features = [ "base64", "serde", "elements" ] }
10+
simplicity-lang = { version = "0.7.0", path = "..", features = [ "base64", "serde", "elements", "human_encoding" ] }
1111

1212
[[bin]]
1313
name = "simpcli"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ mod analysis;
9090
mod bit_encoding;
9191
pub mod bit_machine;
9292
pub mod dag;
93+
#[cfg(feature = "human_encoding")]
9394
pub mod human_encoding;
9495
pub mod jet;
9596
mod merkle;

src/node/commit.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,11 @@ mod tests {
309309
use std::fmt;
310310

311311
use crate::decode::Error;
312-
use crate::human_encoding::Forest;
313-
use crate::jet::{Core, CoreEnv};
314-
use crate::node::SimpleFinalizer;
315-
use crate::{BitMachine, Value};
312+
use crate::jet::Core;
313+
#[cfg(feature = "human_encoding")]
314+
use crate::{human_encoding::Forest, jet::CoreEnv, node::SimpleFinalizer, BitMachine, Value};
316315

316+
#[cfg(feature = "human_encoding")]
317317
#[cfg_attr(not(feature = "base64"), allow(unused_variables))]
318318
#[track_caller]
319319
fn assert_program_deserializable<J: Jet>(
@@ -473,6 +473,7 @@ mod tests {
473473
}
474474

475475
#[test]
476+
#[cfg(feature = "human_encoding")]
476477
fn shared_witnesses() {
477478
assert_program_deserializable::<Core>(
478479
"main := witness",
@@ -577,6 +578,7 @@ mod tests {
577578
}
578579

579580
#[test]
581+
#[cfg(feature = "human_encoding")]
580582
fn regression_177() {
581583
// `case (drop iden) iden` from upstream occurs-check test. Has an infinitely sized
582584
// input type. Will fail trying to unify the input type with the unit type before

src/node/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn shorten<S: AsRef<str>>(s: S, max_len: usize) -> String {
359359
}
360360
}
361361

362-
#[cfg(test)]
362+
#[cfg(all(test, feature = "human_encoding"))]
363363
mod tests {
364364
use crate::human_encoding::Forest;
365365
use crate::jet::Core;

src/node/redeem.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,14 @@ impl<J: Jet> RedeemNode<J> {
610610
#[cfg(test)]
611611
mod tests {
612612
use super::*;
613+
#[cfg(feature = "human_encoding")]
613614
use crate::human_encoding::Forest;
614615
use crate::jet::Core;
615616
use crate::node::SimpleFinalizer;
616-
use crate::types::Final;
617617
use hex::DisplayHex;
618-
use std::collections::HashMap;
619618
use std::fmt;
619+
#[cfg(all(feature = "elements", feature = "human_encoding"))]
620+
use {crate::types::Final, std::collections::HashMap};
620621

621622
#[cfg_attr(not(feature = "base64"), allow(unused_variables))]
622623
#[track_caller]
@@ -965,7 +966,7 @@ mod tests {
965966
);
966967
}
967968

968-
#[cfg(feature = "elements")]
969+
#[cfg(all(feature = "elements", feature = "human_encoding"))]
969970
fn assert_correct_pruning<JE: JetEnvironment>(
970971
unpruned_prog: &str,
971972
unpruned_wit: &HashMap<Arc<str>, Value>,
@@ -1017,7 +1018,7 @@ mod tests {
10171018
}
10181019

10191020
#[test]
1020-
#[cfg(feature = "elements")]
1021+
#[cfg(all(feature = "elements", feature = "human_encoding"))]
10211022
fn prune() {
10221023
use crate::jet::ElementsTxEnv;
10231024

0 commit comments

Comments
 (0)