diff --git a/.github/scripts/setup-simplex b/.github/scripts/setup-simplex index 57be0614..3f1ff180 100644 --- a/.github/scripts/setup-simplex +++ b/.github/scripts/setup-simplex @@ -41,7 +41,7 @@ main() { SIMPLEX_BIN_DIR="$SIMPLEX_DIR/bin" BIN_PATH="$SIMPLEX_BIN_DIR/simplexup" - # Ensure bin directory exists and download simplexup into it + # Create the bin directory and download simplexup there mkdir -p "$SIMPLEX_BIN_DIR" say "Fetching ${FILE_PATH} from ${RAW_URL}" diff --git a/SECURITY.md b/SECURITY.md index 6975097d..111a2a8a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,8 +8,8 @@ In your report, please include as much information as you can, including: * a description of the vulnerability and how it could be exploited * its potential impact (e.g. privacy leak, denial of service, theft of funds) -* steps or code for reproducing it -* a proposed patch for remedying it +* steps or code for reproducing the vulnerability +* a proposed patch, if you have one Also, provide us with a secure means to contact you with any follow up questions we might have. @@ -17,7 +17,7 @@ Also, provide us with a secure means to contact you with any follow up questions Please take care not to violate the privacy of users in your report. For example, stack traces or exploit scripts sent to us should never contain private keys or personally identifiable information. -Give us at least one week to investigate the vulnerability you found and up to 90 days to fix it. Also, please give us reasonable advanced notice if at any point you intend to disclose the vulnerability to anyone else. +Give us at least one week to investigate the vulnerability you found and up to 90 days to fix the issue. Also, please give us reasonable advanced notice if at any point you intend to disclose the vulnerability to anyone else. In general, please investigate and report bugs in a way that makes a reasonable, good faith effort not to be disruptive or harmful to us, this software's users, or the users of dependent projects. diff --git a/crates/build/src/config/dependency.rs b/crates/build/src/config/dependency.rs index 20b5b275..7bf75e32 100644 --- a/crates/build/src/config/dependency.rs +++ b/crates/build/src/config/dependency.rs @@ -60,7 +60,7 @@ struct RawDependency { rev: Option, /// The specific tag to download (only applicable if `git` is provided). tag: Option, - /// The specific branch to download (only applicable if `branch` is provided). + /// The specific branch to download (only applicable if `git` is provided). branch: Option, /// The specific directory with contracts to download (only applicable if `git` is provided). package: Option, diff --git a/crates/build/src/generator.rs b/crates/build/src/generator.rs index 382a0da4..b67d31b7 100644 --- a/crates/build/src/generator.rs +++ b/crates/build/src/generator.rs @@ -113,7 +113,7 @@ impl ArtifactsGenerator { .map_err(|e| BuildError::DependencyMap(e.to_string())) } - /// Processes a single `.simf` source file and write it to metadata: + /// Processes a single `.simf` source file into its metadata: /// - Writes its content to the mirrored path under `simf_out_dir` /// - Extracts the contract name /// diff --git a/crates/build/src/resolver.rs b/crates/build/src/resolver.rs index c3665425..98c42ac4 100644 --- a/crates/build/src/resolver.rs +++ b/crates/build/src/resolver.rs @@ -184,7 +184,7 @@ impl ArtifactsResolver { let repo_name = clean_url.split('/').next_back()?; // Only fields that are actually set take part in the key, so adding a new - // optional field never changes the directory of dependencies that don't use it. + // optional field never changes the directory of dependencies that don't set the field. let reference = reference.map(|reference| match reference { GitRef::Rev(rev) => format!("rev={rev}"), GitRef::Tag(tag) => format!("tag={tag}"), diff --git a/crates/cli/src/commands/error.rs b/crates/cli/src/commands/error.rs index 3ccf9c20..25981e2a 100644 --- a/crates/cli/src/commands/error.rs +++ b/crates/cli/src/commands/error.rs @@ -29,8 +29,8 @@ pub enum CommandError { #[error("IO error: {0}")] Io(#[from] std::io::Error), - #[error("Verbosity level should be either -v or -vv, got: -v x {0}")] - BadVersbosityMode(u8), + #[error("Verbosity must be -v or -vv, got {0} -v flags")] + BadVerbosityMode(u8), #[error("test command failed with exit status {0}")] TestFailed(i32), diff --git a/crates/cli/src/commands/fmt.rs b/crates/cli/src/commands/fmt.rs index b3c5073f..5f99dad3 100644 --- a/crates/cli/src/commands/fmt.rs +++ b/crates/cli/src/commands/fmt.rs @@ -141,12 +141,10 @@ impl Format { Ok(Self::normalize_status(status)) } - /// Resolves the file path to the `simfmt` binary in the same directory where `simplex` is situated. - /// Given that `simfmt` would be placed in one directory with `simplex`, this is suitable for our usecase. + /// The path to the `simfmt` binary next to the `simplex` binary, where `simplexup` installs both. /// /// # Warning - /// Can fail to search for binary when env isn't set and `simfmt` binary lies in the other directory. - /// Even when `simfmt` is visible through PATH. + /// Doesn't find a `simfmt` in another directory, even one on `PATH`, unless the env variable is set. #[inline] fn simfmt_binary() -> Result { Ok(env::current_exe() diff --git a/crates/cli/src/commands/install.rs b/crates/cli/src/commands/install.rs index d6caa9ec..620c8637 100644 --- a/crates/cli/src/commands/install.rs +++ b/crates/cli/src/commands/install.rs @@ -203,7 +203,7 @@ impl Install { /// at `reference`, keeping only `package` when it is set. /// /// 1. Clone the history without contents and any checks. - /// 2. If `package` is set, restrict the checkout to it. + /// 2. If `package` is set, restrict the checkout to that directory. /// 3. Check out `rev` (or the cloned ref), downloading only the files it needs. fn git_commands(url: &str, reference: Option<&GitRef>, package: Option<&str>, target_dir: &Path) -> Vec { let mut clone = Command::new("git"); diff --git a/crates/cli/src/commands/test.rs b/crates/cli/src/commands/test.rs index 69f2f843..4080630b 100644 --- a/crates/cli/src/commands/test.rs +++ b/crates/cli/src/commands/test.rs @@ -7,7 +7,7 @@ use smplx_test::{TestConfig, smplx_test_marker}; use super::core::{TestArguments, TestFlags}; use super::error::CommandError; -/// Nextest dsl variable to filter and use only simplex tests +/// Nextest filter expression that selects only Simplex tests. const SMPLX_NEXTEST_DSL_TEST_MARKER: &str = concat!("test(/", smplx_test_marker!(), "$/)"); const SMPLX_NEXTEST_FUZZ_DSL_TEST_MARKER: &str = concat!("test(/", smplx_test_marker!(fuzz), "$/)"); const DEFAULT_THREADS_NUMBER: usize = 1; @@ -26,7 +26,7 @@ impl Test { let cache_path = Self::get_test_config_cache_name()?; if flags.verbose > Verbosity::MAX_VERBOSITY_LEVEL { - return Err(CommandError::BadVersbosityMode(flags.verbose)); + return Err(CommandError::BadVerbosityMode(flags.verbose)); } config.verbosity = std::cmp::max(config.verbosity, Verbosity::new(flags.verbose)); diff --git a/crates/cli/src/config/error.rs b/crates/cli/src/config/error.rs index b67ee5a1..7c15cf97 100644 --- a/crates/cli/src/config/error.rs +++ b/crates/cli/src/config/error.rs @@ -29,7 +29,7 @@ pub enum ConfigError { #[error("Unable to get env variable: {0}")] UnableToGetEnv(#[from] std::env::VarError), - #[error("Path doesn't a file: '{0}'")] + #[error("Path isn't a file: '{0}'")] PathIsNotFile(PathBuf), #[error("Path doesn't exist: '{0}'")] diff --git a/crates/regtest/src/args.rs b/crates/regtest/src/args.rs index bb950474..2ae05a32 100644 --- a/crates/regtest/src/args.rs +++ b/crates/regtest/src/args.rs @@ -24,7 +24,7 @@ pub(super) fn get_elementsd_bin_args(config: &RegtestConfig) -> Vec { ]; if let Some(port) = config.rpc_port { - // A lib works with autoassigned rpcport, so we are required to do this woodoo + // The node library picks the RPC port itself, so a fixed port needs explicit bind settings args.push("-rpcbind=127.0.0.1".to_string()); args.push(format!("-rpcbind=127.0.0.1:{port}")); args.push("-rpcallowip=127.0.0.1/8".to_string()); diff --git a/crates/sdk/src/program/core.rs b/crates/sdk/src/program/core.rs index fd999017..726e453a 100644 --- a/crates/sdk/src/program/core.rs +++ b/crates/sdk/src/program/core.rs @@ -59,7 +59,7 @@ pub trait ProgramTrait: DynClone + Send + Sync { /// /// Doesn't check the witness budget; [`ProgramTrait::finalize`] does. With [`Verbosity`](crate::global::Verbosity) /// `Debug` or `Trace`, the execution output is buffered, not printed: call - /// [`ProgramLogger::flush_logs`] to print it. + /// [`ProgramLogger::flush_logs`] to print the output. /// /// # Errors /// - `ProgramError::WitnessSatisfaction` if the witness doesn't fit the program's witness types. @@ -136,8 +136,8 @@ pub trait ProgramFactory + Sized> { /// and the debug-symbol setting determine the CMR, and the address also depends on the internal /// key and the storage. /// -/// Code generated by `simplex build` wraps a `Program` in one type per contract, which reaches it -/// with `as_ref()`. +/// Code generated by `simplex build` wraps a `Program` in one type per contract. Call `as_ref()` +/// on that type to get the `Program`. #[derive(Clone)] pub struct Program { source: Arc, @@ -319,8 +319,8 @@ impl Program { /// the tree is at most 128 layers deep. pub const MAX_STORAGE_SLOTS: usize = 128; - /// Creates a program from `SimplicityHL` source and its `param::` arguments, without compiling - /// it. + /// Creates a program from `SimplicityHL` source and its `param::` arguments. The source + /// compiles later, on first use. /// /// The Taproot internal key is [`tr_unspendable_key`], and there aren't any storage slots. #[must_use] @@ -433,7 +433,7 @@ impl Program { /// The storage slot at `index`. /// /// # Panics - /// Panics if the `index` is out of bounds for the initiated storage. + /// Panics if the `index` is out of bounds for the initialized storage. #[must_use] pub fn get_storage_at(&self, index: usize) -> Vec { self.storage[index].clone() @@ -485,7 +485,7 @@ impl Program { self.cmr().unwrap_or_else(|error| panic!("{error}")).to_byte_array() } - /// The tapleaf hash of the program's leaf. Storage doesn't change it. + /// The tapleaf hash of the program's leaf. Storage doesn't affect this hash. /// /// # Panics /// Panics if the `SimplicityHL` compilation fails. @@ -640,7 +640,7 @@ mod tests { } #[test] - fn storage_slot_takes_a_full_width_value() { + fn storage_slot_accepts_32_bytes() { let mut program = stateful(1); program.set_storage_at(0, vec![0x11; Program::STORAGE_SLOT_BYTES]); @@ -650,18 +650,18 @@ mod tests { #[test] #[should_panic(expected = "A storage slot is 32 bytes, and this one is 1")] - fn storage_slot_refuses_a_short_value() { + fn storage_slot_rejects_a_short_value() { stateful(1).set_storage_at(0, vec![0x11]); } #[test] #[should_panic(expected = "A storage slot is 32 bytes, and this one is 33")] - fn storage_slot_refuses_a_long_one() { + fn storage_slot_rejects_a_long_value() { stateful(1).set_storage_at(0, vec![0x11; 33]); } #[test] - fn changing_a_slot_changes_the_address_but_not_the_program() { + fn storage_changes_the_address_but_not_the_cmr() { let one = stateful(1); let network = SimplicityNetwork::LiquidTestnet; let address = one.get_tr_address(&network); @@ -722,7 +722,7 @@ mod tests { } #[test] - fn compiles_once_and_keeps_it() { + fn program_is_compiled_once() { let program = dummy_program(); let first = program.load().expect("the dummy program compiles"); @@ -732,7 +732,7 @@ mod tests { } #[test] - fn changed_build_mode_is_not_served_the_old_compilation() { + fn debug_symbols_change_the_cmr() { let plain = dummy_program(); let plain_cmr = plain.get_cmr(); @@ -743,7 +743,7 @@ mod tests { } #[test] - fn test_get_env_idx() { + fn get_env_checks_the_script_pubkey() { let program = dummy_program(); let network = dummy_network(); @@ -764,7 +764,7 @@ mod tests { ..Default::default() }); - // take a script with a wrong pubkey + // Input 0 spends a script that is not the program's assert!(matches!( program.get_env(&pst, 0, &network).unwrap_err(), ProgramError::ScriptPubkeyMismatch { .. } @@ -774,7 +774,7 @@ mod tests { } #[test] - fn input_without_its_utxo_is_an_error() { + fn input_without_witness_utxo_is_an_error() { let network = SimplicityNetwork::default_regtest(); let program = stateful(0); let mut pst = PartiallySignedTransaction::new_v2(); @@ -795,7 +795,7 @@ mod tests { } #[test] - fn storage_is_at_most_as_deep_as_the_taproot_tree() { + fn max_storage_slots_fit_the_taproot_tree() { let network = SimplicityNetwork::default_regtest(); let _ = stateful(Program::MAX_STORAGE_SLOTS).get_tr_address(&network); @@ -803,12 +803,12 @@ mod tests { #[test] #[should_panic(expected = "A program holds at most 128 storage slots, and this one asks for 129")] - fn storage_beyond_the_taproot_tree_is_refused() { + fn too_many_storage_slots_panic() { let _ = stateful(Program::MAX_STORAGE_SLOTS + 1); } #[test] - fn left_folded_depths() { + fn taproot_leaf_depths_are_left_folded() { assert_eq!(Program::taproot_leaf_depths(1), vec![0]); assert_eq!(Program::taproot_leaf_depths(2), vec![1, 1]); assert_eq!(Program::taproot_leaf_depths(3), vec![2, 2, 1]); @@ -816,10 +816,10 @@ mod tests { assert_eq!(Program::taproot_leaf_depths(5), vec![4, 4, 3, 2, 1]); } - // The measured boundary: a balanced tree agrees with a left fold up to three leaves and - // diverges from four. Four leaves balanced is [2, 2, 2, 2]; left-folded it is not. + // A balanced tree and a left fold agree up to three leaves. With four leaves, a balanced tree + // has depths [2, 2, 2, 2] and a left fold doesn't. #[test] - fn diverges_from_a_balanced_tree_at_four_leaves() { + fn left_fold_differs_from_a_balanced_tree_at_four_leaves() { assert_eq!(Program::taproot_leaf_depths(3), vec![2, 2, 1]); assert_ne!(Program::taproot_leaf_depths(4), vec![2, 2, 2, 2]); } diff --git a/crates/sdk/src/program/error.rs b/crates/sdk/src/program/error.rs index cf5cc18c..4a62e667 100644 --- a/crates/sdk/src/program/error.rs +++ b/crates/sdk/src/program/error.rs @@ -1,7 +1,7 @@ /// Errors that can occur when compiling, preparing, and executing Simplicity programs. #[derive(Debug, thiserror::Error)] pub enum ProgramError { - /// The serialized witness stack does not buy enough budget to cover the program's execution cost. + /// The witness budget, set by the serialized witness stack size, doesn't cover the program's execution cost. /// /// Consensus requires `cost <= 1000 * (serialized witness stack size + 50)` milli weight units. /// The 50 is Elements' `VALIDATION_WEIGHT_OFFSET` @@ -15,7 +15,7 @@ pub enum ProgramError { InsufficientBudget { /// Static execution cost of the pruned program, rounded up to whole weight units. cost_wu: u64, - /// Budget bought by the witness stack: its serialized size plus 50 weight units. + /// Witness budget: the serialized witness stack size plus 50 weight units. budget_wu: u64, /// Serialized size of the witness stack in bytes. stack_bytes: usize, @@ -51,7 +51,7 @@ pub enum ProgramError { /// Error indicating an input that doesn't carry the output it spends. #[error("Input {input_index} has no witness UTXO")] MissingWitnessUtxo { - /// The index of the input without one. + /// The index of the input without a witness UTXO. input_index: usize, }, diff --git a/crates/sdk/src/provider/core.rs b/crates/sdk/src/provider/core.rs index a40da8fa..64995b65 100644 --- a/crates/sdk/src/provider/core.rs +++ b/crates/sdk/src/provider/core.rs @@ -19,7 +19,7 @@ pub const DEFAULT_ESPLORA_TIMEOUT_SECS: u64 = 10; pub const DEFAULT_CONFIRMATION_ATTEMPTS: u32 = 9; /// The endpoints of a provider: an Esplora URL, and for a regtest node, its RPC URL and -/// credentials. Neither the SDK nor the test framework reads it. +/// credentials. Neither the SDK nor the test framework reads these. #[cfg(feature = "provider")] #[derive(Debug, Clone)] pub struct ProviderInfo { @@ -34,8 +34,9 @@ pub struct ProviderInfo { /// Access to a Liquid or Elements network: broadcasting, confirmation, chain queries and UTXO /// lookups. /// -/// All methods block. `EsploraProvider` and `SimplexProvider` implement it with the `provider` -/// feature. The trait itself doesn't need the feature, so a host without it can implement it. +/// All methods block. `EsploraProvider` and `SimplexProvider` implement this trait with the +/// `provider` feature. The trait itself doesn't need the feature, so a host without the feature +/// can still implement the trait. /// /// UTXOs come back as the chain has them: a confidential output has `secrets: None`. A /// [`Signer`](crate::signer::Signer) unblinds its own outputs. @@ -43,7 +44,7 @@ pub trait ProviderTrait: Send + Sync { /// The network this provider talks to. fn get_network(&self) -> &SimplicityNetwork; - /// Broadcasts `tx` and returns a receipt for it. + /// Broadcasts `tx` and returns the transaction's receipt. /// /// # Errors /// Returns `ProviderError::BroadcastRejected` if the provider answers with an error status, diff --git a/crates/sdk/src/provider/esplora.rs b/crates/sdk/src/provider/esplora.rs index 397c4357..05546d8d 100644 --- a/crates/sdk/src/provider/esplora.rs +++ b/crates/sdk/src/provider/esplora.rs @@ -67,7 +67,7 @@ impl EsploraProvider { } } - /// Sends a GET to `path` under the Esplora URL, whatever the status it answers with. + /// Sends a GET to `path` under the Esplora URL, whatever the response status. fn request(&self, path: &str) -> Result { minreq::get(format!("{}{path}", self.esplora_url)) .with_timeout(self.timeout.as_secs()) @@ -75,7 +75,7 @@ impl EsploraProvider { .map_err(|e| ProviderError::Request(e.to_string())) } - /// Sends a GET to `path`, failing unless it answers 200. + /// Sends a GET to `path`, failing unless the response status is 200. fn get(&self, path: &str) -> Result { let response = self.request(path)?; @@ -195,7 +195,7 @@ impl ProviderTrait for EsploraProvider { for _ in 0..self.confirmation_attempts { let response = self.request(&path)?; - // an unknown transaction answers 404 until Esplora indexes it + // Esplora answers 404 for a transaction it hasn't indexed yet if response.status_code == 200 { let status: TxStatus = response.json().map_err(|e| ProviderError::Deserialize(e.to_string()))?; diff --git a/crates/sdk/src/signer/core.rs b/crates/sdk/src/signer/core.rs index 08d2a789..c6920ef6 100644 --- a/crates/sdk/src/signer/core.rs +++ b/crates/sdk/src/signer/core.rs @@ -286,7 +286,7 @@ impl Signer { /// /// # Errors /// Returns the errors of [`Signer::finalize`], and `SignerError::Provider` if the broadcast - /// fails. A node's rejection is `ProviderError::BroadcastRejected` inside it. + /// fails. A node's rejection arrives as `SignerError::Provider(ProviderError::BroadcastRejected)`. #[cfg(feature = "provider")] pub fn broadcast(&self, tx: &FinalTransaction) -> Result, SignerError> { let (tx, _fee) = self.finalize(tx)?; @@ -384,7 +384,8 @@ impl Signer { inputs_since_estimate += 1; } - // Need to try one more time after the loop. No UTXO is left to add, so any chance is taken + // One last estimate for the UTXOs added since the previous one. No UTXO is left to add, + // so skip the margin for their fees and let the estimate decide let policy_amount_delta = fee_tx.calculate_fee_delta(&self.network)?; if i128::from(policy_amount_delta) >= i128::from(curr_fee) { @@ -443,9 +444,9 @@ impl Signer { /// The fee `tx` would pay at `fee_rate` sats/kvb with a change output and a fee output added, /// as [`Signer::finalize_strict`] would add them. Doesn't add any wallet inputs. /// - /// Returns the fee even if `tx`'s inputs can't pay it. If the change is blinded and can't be - /// dropped, and the surplus is too small for it, this returns the fee plus [`MIN_FEE`] instead: - /// the smallest surplus that pays both the fee and the change. + /// Returns the fee even if `tx`'s inputs can't cover the fee. If the change is blinded and + /// can't be dropped, and the surplus is too small for the change, this returns the fee plus + /// [`MIN_FEE`] instead: the smallest surplus that pays both the fee and the change. /// /// # Errors /// Returns `SignerError::InvalidFeeRate`, `UnknownInputAmount`, `DuplicateInput`, @@ -725,7 +726,8 @@ impl Signer { /// `0/0`. /// /// # Errors - /// Returns `SignerError::InvalidDerivationPath` if the path is not of the form `m/n`. + /// Returns `SignerError::InvalidDerivationPath` if the path doesn't have exactly two unhardened + /// steps, such as `0/5`. pub fn get_private_key_at(&self, relative: Option<&DerivationPath>) -> Result { match relative { Some(path) => { @@ -873,7 +875,7 @@ impl Signer { return Ok(Estimate::Failure(fee.saturating_add(change_minimum))); } - // Not enough funds for the change, so estimate without it. + // Not enough funds for the change, so estimate without a change output. fee_tx.remove_output(change_index); let final_tx = sign_and_extract_tx(self, &fee_tx)?; @@ -1248,7 +1250,7 @@ mod tests { } #[test] - fn blinded_output_lets_the_explicit_change_target_stand() { + fn explicit_change_target_is_allowed_with_a_blinded_output() { let signer = create_signer(); let mut ft = FinalTransaction::new(); @@ -1270,7 +1272,7 @@ mod tests { } #[test] - fn default_change_target_balances_it_by_itself() { + fn default_change_target_balances_a_confidential_input() { let signer = create_signer(); let mut ft = FinalTransaction::new(); @@ -1304,7 +1306,7 @@ mod tests { } #[test] - fn descriptors() { + fn prints_addresses() { let signer = create_signer(); println!("{}", signer.get_address()); @@ -1520,7 +1522,7 @@ mod tests { } #[test] - fn leftover_too_small_for_change_is_the_fee_unless_it_reveals_a_blinded_amount() { + fn small_leftover_goes_to_the_fee_unless_a_blinded_output_needs_change() { let signer = create_signer(); let policy = signer.network.policy_asset(); let script = signer.get_address().script_pubkey(); @@ -1547,7 +1549,7 @@ mod tests { } #[test] - fn only_wallet_paths_owning_the_input_sign_it() { + fn derivation_path_must_own_the_input() { let signer = create_signer(); let path = |path: &str| DerivationPath::from_str(path).unwrap(); diff --git a/crates/sdk/src/signer/error.rs b/crates/sdk/src/signer/error.rs index 28b2c706..765fdab4 100644 --- a/crates/sdk/src/signer/error.rs +++ b/crates/sdk/src/signer/error.rs @@ -11,7 +11,7 @@ use crate::transaction::{FinalTransactionError, UtxoError}; /// `Provider(ProviderError::BroadcastRejected { .. })`. #[derive(Debug, thiserror::Error)] pub enum SignerError { - /// A program failed while the signer signed for it, before running it: in + /// A program failed while the signer prepared its signature, before the program ran: in /// [`SignerTrait::sign_program`](super::SignerTrait::sign_program), or in /// [`Signer::sign_witnesses`](super::Signer::sign_witnesses) for an input with a /// [`ProgramSignature`](crate::transaction::ProgramSignature). The program doesn't compile, @@ -23,11 +23,11 @@ pub enum SignerError { /// Running a program input failed, so the transaction wasn't finalized. /// /// Raised before broadcast, by [`Signer::sign_tx`](super::Signer::sign_tx) and the methods - /// built on it. `source` says why: `ProgramError::Pruning` when the contract rejects the spend, - /// and other variants, such as `ProgramError::WitnessSatisfaction`, + /// built on `sign_tx`. `source` says why: `ProgramError::Pruning` when the contract rejects + /// the spend, and other variants, such as `ProgramError::WitnessSatisfaction`, /// `ProgramError::ScriptPubkeyMismatch` or `ProgramError::InsufficientBudget`, when the - /// program can't run on this input or its witness doesn't pay for it. The locktime and - /// sequence identify most timelock failures. + /// program can't run on this input or its witness stack doesn't cover the execution cost. The + /// locktime and sequence identify most timelock failures. #[error( "Covenant input {index} did not execute (transaction locktime {locktime}, input sequence {sequence}): {source}" )] @@ -119,12 +119,12 @@ pub enum SignerError { ConfidentialInputWithoutBlindedOutput, /// A derivation path doesn't have exactly two unhardened steps, such as `0/5`. - #[error("The derivation path `{0}` is not of the form m/n")] + #[error("The derivation path `{0}` must have exactly two unhardened steps, such as 0/5")] InvalidDerivationPath(DerivationPath), - /// A native input spends a P2WPKH output locked to another key than the one at its + /// A native input spends a P2WPKH output locked to a different key than the one at its /// derivation path. - #[error("Input {0} is locked to another key than its derivation path gives")] + #[error("Input {0} is locked to a different key than the one at its derivation path")] KeyMismatch(usize), /// Error indicating an invalid upstream `secp256k1` secret key. @@ -161,7 +161,7 @@ pub enum SignerError { /// A [`ProgramSignature`](crate::transaction::ProgramSignature) with a path names a field /// that the program's witness doesn't have. - #[error("Missing such witness field: {0}")] + #[error("The program's witness has no field `{0}`")] WitnessFieldNotFound(String), } @@ -186,7 +186,7 @@ pub enum WitnessWrappingError { RootTypeMismatch(String, String), /// The supplied witness value takes the other branch of an `Either` than the path does. - #[error("Path reached undefined branch of Either")] + #[error("The witness value takes the other branch of an Either than the path")] EitherBranchMismatch, } diff --git a/crates/sdk/src/transaction/final_transaction.rs b/crates/sdk/src/transaction/final_transaction.rs index 2644c3d6..4e6ed6a2 100644 --- a/crates/sdk/src/transaction/final_transaction.rs +++ b/crates/sdk/src/transaction/final_transaction.rs @@ -80,7 +80,7 @@ impl FinalInput { /// Converts this input, with its issuance, into a PSET input. /// /// The input's own sequence and locktime are used as they are. [`FinalTransaction::extract_pst`] - /// fills in the transaction-wide ones first and checks the issuance, so prefer it. + /// fills in the transaction-wide ones first and checks the issuance, so prefer `extract_pst`. /// /// # Panics /// Panics if the input reissues an asset and `partial_input.secrets` is `None`, because the @@ -311,7 +311,8 @@ impl FinalTransaction { self.change.as_ref() } - /// The change target set with [`FinalTransaction::add_change`], if any, for changing it. + /// The change target set with [`FinalTransaction::add_change`], if any, for changing the target + /// in place. #[must_use] pub fn change_mut(&mut self) -> Option<&mut ChangeOutput> { self.change.as_mut() @@ -466,8 +467,8 @@ impl FinalTransaction { /// /// Each input without its own sequence or locktime gets [`FinalTransaction::sequence`] and /// [`FinalTransaction::locktime`]. An explicit input gets secrets with zero blinding - /// factors, so that blinding can balance against it. Outputs are converted as they are: this - /// doesn't add any change or fee output. + /// factors, so that blinding can balance against the explicit amount. Outputs are converted + /// as they are: this doesn't add any change or fee output. /// /// This is where code that signs outside the [`Signer`](crate::signer::Signer) takes over. /// @@ -573,7 +574,7 @@ mod tests { } #[test] - fn explicit_input_is_not_a_confidential_one() { + fn explicit_input_is_not_confidential() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -583,7 +584,7 @@ mod tests { } #[test] - fn input_carrying_secrets_is_a_confidential_one() { + fn input_with_secrets_is_confidential() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -593,7 +594,7 @@ mod tests { } #[test] - fn confidential_input_paying_an_explicit_output_leaves_nothing_blinded() { + fn explicit_output_needs_no_blinding() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -605,7 +606,7 @@ mod tests { } #[test] - fn blinded_output_is_what_balances_the_transaction() { + fn output_with_blinding_key_needs_blinding() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -616,7 +617,7 @@ mod tests { assert!(ft.needs_blinding()); } - // Manually construct PST and check extract_pst correctness based on it + // Build the expected PST by hand and compare `extract_pst` with the result #[test] fn extract_pst_single_explicit_input_single_output() { let policy = dummy_asset_id(0xAA); @@ -645,7 +646,7 @@ mod tests { } #[test] - fn declared_height_becomes_the_transactions_locktime() { + fn locktime_height_applies_to_every_input() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -681,7 +682,7 @@ mod tests { } #[test] - fn transaction_that_declares_no_height_still_has_none() { + fn no_locktime_keeps_final_sequences() { let policy = dummy_asset_id(0xAA); let mut ft = FinalTransaction::new(); @@ -1023,7 +1024,7 @@ mod tests { } #[test] - fn token_only_issuance_has_a_null_amount_and_an_empty_one_is_rejected() { + fn token_only_issuance_is_allowed_and_empty_issuance_is_rejected() { let policy = dummy_asset_id(0xAA); let issuance = |issuance_amount, inflation_amount| { let mut tx = FinalTransaction::new(); diff --git a/crates/sdk/src/transaction/partial_input.rs b/crates/sdk/src/transaction/partial_input.rs index 1de5876d..01d9d1e2 100644 --- a/crates/sdk/src/transaction/partial_input.rs +++ b/crates/sdk/src/transaction/partial_input.rs @@ -39,7 +39,8 @@ pub struct PartialInput { pub derivation_path: Option, } -/// The Simplicity program that locks an input's spent output, and the witness that satisfies it. +/// The Simplicity program that locks an input's spent output, and the witness that satisfies the +/// program. #[derive(Clone)] pub struct ProgramInput { /// The program. Its address must be the spent output's script. diff --git a/crates/sdk/src/transaction/required_signature.rs b/crates/sdk/src/transaction/required_signature.rs index 38ec0e44..490391f3 100644 --- a/crates/sdk/src/transaction/required_signature.rs +++ b/crates/sdk/src/transaction/required_signature.rs @@ -109,7 +109,7 @@ impl ProgramSignature { /// The signer returns `SignerError::WitnessFieldNotFound` if the program doesn't have the /// field, and `SignerError::WitnessInjectError` if the path doesn't fit the field's type or /// value. It panics if the program has the field but the witness supplied in the - /// [`ProgramInput`](super::ProgramInput) doesn't contain it. + /// [`ProgramInput`](super::ProgramInput) doesn't contain the field. #[must_use] pub fn at_path(mut self, path: I) -> Self where diff --git a/crates/sdk/src/transaction/tx_receipt.rs b/crates/sdk/src/transaction/tx_receipt.rs index f924c05d..775eb0d7 100644 --- a/crates/sdk/src/transaction/tx_receipt.rs +++ b/crates/sdk/src/transaction/tx_receipt.rs @@ -38,7 +38,7 @@ impl<'a> TxReceipt<'a> { Self { provider, tx_id } } - /// Returns the ID of the broadcasted transaction. + /// Returns the ID of the broadcast transaction. #[must_use] pub fn txid(self) -> Txid { self.tx_id diff --git a/crates/sdk/src/utils.rs b/crates/sdk/src/utils.rs index 0a1c56f5..3db12852 100644 --- a/crates/sdk/src/utils.rs +++ b/crates/sdk/src/utils.rs @@ -86,7 +86,7 @@ pub fn btc2sat(btc: u64) -> u64 { /// Pass the pruned program's `bounds().cost` and the exact witness stack the input will carry. /// /// # Errors -/// Returns `ProgramError::InsufficientBudget` if the cost exceeds the budget the stack buys. +/// Returns `ProgramError::InsufficientBudget` if the cost exceeds the witness budget. #[allow(clippy::ptr_arg)] // `Cost::is_budget_valid` takes `&Vec>` to reuse its consensus encoding pub fn check_budget(cost: Cost, stack: &Vec>) -> Result<(), ProgramError> { if cost.is_budget_valid(stack) { diff --git a/crates/test/src/context.rs b/crates/test/src/context.rs index 26a6b2fc..e77076f9 100644 --- a/crates/test/src/context.rs +++ b/crates/test/src/context.rs @@ -262,7 +262,7 @@ impl TestContext { self.create_signer(random_mnemonic().as_str()) } - /// Returns the default signer, initiated from the config. + /// Returns the default signer, created from the config. pub fn get_default_signer(&self) -> &Signer { &self.mode.signer } diff --git a/crates/test/src/error.rs b/crates/test/src/error.rs index 3e5943f8..bf65afa0 100644 --- a/crates/test/src/error.rs +++ b/crates/test/src/error.rs @@ -21,7 +21,7 @@ pub enum TestError { #[error(transparent)] BadNetworkName(#[from] NetworkConvertError), - #[error("Occurred a network utils execution error: '{0}'")] + #[error("Network utils failed: '{0}'")] NetworkUtilsExecution(#[from] NetworkUtilsError), } @@ -30,6 +30,6 @@ pub enum NetworkUtilsError { #[error(transparent)] Provider(#[from] ProviderError), - #[error("Unsuccessful action completion, err: '{0}'")] + #[error("Network sync failed: '{0}'")] UnsuccessfulSync(String), } diff --git a/crates/test/src/fuzz/case.rs b/crates/test/src/fuzz/case.rs index 679f2192..110a45fe 100644 --- a/crates/test/src/fuzz/case.rs +++ b/crates/test/src/fuzz/case.rs @@ -101,7 +101,7 @@ impl<'a> FuzzCase<'a> { self.map.new_output_position(old_index) } - /// The SHA-256 hash of the script of the output input `index` spends. + /// The SHA-256 hash of the script that input `index` spends. /// /// # Panics /// Panics when the transaction has no input `index`. @@ -165,12 +165,12 @@ impl<'a> FuzzCase<'a> { self.transaction.outputs()[index].amount } - /// The lock height as the jets see it: zero when every input sequence is final or the locktime is a time. + /// The lock height the jets read: zero when every input sequence is final or the locktime is a time. pub fn lock_height(&self) -> u32 { self.read_lock(|locktime| locktime < LOCK_TIME_THRESHOLD) } - /// The lock time as the jets see it: zero when every input sequence is final or the locktime is a height. + /// The lock time the jets read: zero when every input sequence is final or the locktime is a height. pub fn lock_time(&self) -> u32 { self.read_lock(|locktime| locktime >= LOCK_TIME_THRESHOLD) } diff --git a/crates/test/src/fuzz/outcome.rs b/crates/test/src/fuzz/outcome.rs index 368c85a3..2a274249 100644 --- a/crates/test/src/fuzz/outcome.rs +++ b/crates/test/src/fuzz/outcome.rs @@ -19,7 +19,7 @@ pub(crate) enum Rejection { Panic, /// A pruned branch was reached, e.g. `unwrap(None)`. Unwrap, - /// A Bit Machine limit exceeded. + /// A Bit Machine limit was exceeded. Resource, /// The program costs more than its witness pays for. Budget, diff --git a/crates/test/src/fuzz/program_scenario.rs b/crates/test/src/fuzz/program_scenario.rs index 93a64bca..110019a3 100644 --- a/crates/test/src/fuzz/program_scenario.rs +++ b/crates/test/src/fuzz/program_scenario.rs @@ -27,7 +27,7 @@ pub struct FuzzProgramScenarioBuilder<'a, P> { _program: PhantomData P>, } -/// The FuzzProgram fuzz configuration. +/// The fuzz configuration of one program. pub(crate) struct FuzzProgramScenario { pub(crate) name: String, pub(crate) inputs: Vec, @@ -204,7 +204,7 @@ impl<'a, P: FuzzProgramTrait> FuzzProgramScenarioBuilder<'a, P> { self } - /// Locks the transaction output at `index` to this program with the storage `transition` function returns. + /// Locks the transaction output at `index` to this program with the storage that `transition` returns. pub fn recursive(self, index: usize, transition: impl Fn(&FuzzProgram<'_, P>) -> Vec<[u8; 32]> + 'static) -> Self { let name = self.program_scenario.name.clone(); diff --git a/crates/test/src/fuzz/scenario.rs b/crates/test/src/fuzz/scenario.rs index f9055714..0ad352e7 100644 --- a/crates/test/src/fuzz/scenario.rs +++ b/crates/test/src/fuzz/scenario.rs @@ -39,7 +39,7 @@ impl Scenario { } } - /// Adds a program of type `P`, named `name`, and returns a builder to configure it. + /// Adds a program of type `P`, named `name`, and returns a builder for that program. /// /// Names must be unique. At least one program must spend an input, and an input or output /// can belong to only one program. @@ -379,7 +379,7 @@ impl<'a, 's> CaseBuilder<'a, 's> { Ok(()) } - /// Sets the required witness values, then violates one of them when the case picks it. + /// Sets the required witness values, then violates the one the case picks, if any. fn require_witnesses(&mut self) -> Result>, SetupError> { let scenario = self.scenario; let mut requirements = Requirements::new(); diff --git a/crates/test/src/fuzz/utils.rs b/crates/test/src/fuzz/utils.rs index bda0819b..51788c4c 100644 --- a/crates/test/src/fuzz/utils.rs +++ b/crates/test/src/fuzz/utils.rs @@ -9,12 +9,12 @@ use rand::{Rng, RngExt}; use smplx_sdk::program::ProgramSchema; -/// Random arguments for program `P`, each value drawn as [`generate_random_value_by_ty`] draws it. +/// Random arguments for program `P`, with each value drawn by [`generate_random_value_by_ty`]. pub fn random_arguments(rng: &mut R) -> Arguments { Arguments::from_map(random_fields(&P::argument_types(), rng)) } -/// A random witness for program `P`, each value drawn as [`generate_random_value_by_ty`] draws it. +/// A random witness for program `P`, with each value drawn by [`generate_random_value_by_ty`]. pub fn random_witness(rng: &mut R) -> WitnessValues { WitnessValues::from_map(random_fields(&P::witness_types(), rng)) } diff --git a/crates/test/src/network_utils.rs b/crates/test/src/network_utils.rs index da484989..e84b85ac 100644 --- a/crates/test/src/network_utils.rs +++ b/crates/test/src/network_utils.rs @@ -32,7 +32,7 @@ impl NetworkUtils { } return Err(NetworkUtilsError::UnsuccessfulSync(format!( - "Failed to complete mining until height, got: '{h}', desired height: '{current_height}'", + "Esplora reached height {h} instead of {target_height}", ))); } diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 0fad1f09..c63e298e 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -154,7 +154,7 @@ impl Covenant { /// Compiles the covenant and returns its Commitment Merkle Root as lowercase hex. /// /// # Errors - /// Returns an error the source fails to compile. + /// Returns an error if the source fails to compile. #[wasm_bindgen(js_name = commitmentMerkleRoot)] pub fn commitment_merkle_root(&self) -> Result { self.validate()?; @@ -166,7 +166,7 @@ impl Covenant { /// Compiles the covenant and returns the tapleaf hash of its Simplicity script, as hex. /// /// # Errors - /// Returns an error the source fails to compile. + /// Returns an error if the source fails to compile. #[wasm_bindgen(js_name = tapleafHash)] pub fn tapleaf_hash(&self) -> Result { self.validate()?; @@ -426,7 +426,7 @@ impl TransactionBuilder { } /// Sets the block height this transaction may not be mined before. - /// Unless a sequence is set, the inputs get one that enforces it. + /// Unless a sequence is set, the inputs get one that enforces the locktime. /// /// # Panics /// Panics if `height` is `500_000_000` or greater, which Elements reads as a time. @@ -436,7 +436,7 @@ impl TransactionBuilder { } /// Sets the block time this transaction may not be mined before. - /// Unless a sequence is set, the inputs get one that enforces it. + /// Unless a sequence is set, the inputs get one that enforces the locktime. /// /// # Panics /// Panics if `time` is below `500_000_000`, which Elements reads as a height. @@ -807,10 +807,10 @@ impl TransactionBuilder { self.transaction.n_outputs() } - /// The issuer contract an issuance commits to, which is nothing unless one is named. + /// The issuer contract hash an issuance commits to, all zeroes when none is given. fn issuer_contract(written: Option<&str>) -> Result<[u8; 32], String> { match written.map(str::trim).filter(|hex_id| !hex_id.is_empty()) { - Some(hex_id) if hex_id.len() != 64 => Err("an id is thirty-two bytes".to_string()), + Some(hex_id) if hex_id.len() != 64 => Err("a contract hash is 64 hex characters".to_string()), Some(hex_id) => ContractHash::from_str(hex_id) .map(ContractHash::to_byte_array) .map_err(|e| e.to_string()), @@ -818,8 +818,8 @@ impl TransactionBuilder { } } - /// Which signature a covenant input needs. Can either be a witness name like `SIGNATURE`, - /// or a withess path if the signature is embedded like `SIGNATURE.Left.Right.1` + /// Which signature a covenant input needs: a witness name like `SIGNATURE`, or a witness path + /// like `SIGNATURE.Left.Right.1` when the signature sits inside the field. /// /// `None` means no signature is required. fn program_signature(signature_witness: Option<&str>) -> Option { @@ -1031,19 +1031,19 @@ mod tests { const TRIVIAL: &str = "fn main() { }"; #[test] - fn state_leaf_that_is_not_a_full_slot_is_refused() { + fn short_state_leaf_is_rejected() { let refused = Covenant::state_leaves("[\"00\"]").expect_err("a one byte leaf"); assert!(refused.contains("is 1 bytes, and a leaf is 32"), "{refused}"); } #[test] - fn state_leaf_that_is_not_hex_is_refused() { + fn non_hex_state_leaf_is_rejected() { assert!(Covenant::state_leaves("[\"nonsense\"]").is_err()); } #[test] - fn full_width_leaves_are_read_in_the_order_they_were_given() { + fn state_leaves_keep_their_order() { let read = Covenant::state_leaves(&format!("[\"{}\", \"0x{}\"]", "00".repeat(32), "11".repeat(32))) .expect("two full leaves"); @@ -1051,7 +1051,7 @@ mod tests { } #[test] - fn full_width_state_leaf_is_accepted_and_updates_the_address() { + fn state_leaf_changes_the_address_but_not_the_cmr() { let leaf = "00".repeat(32); let other = format!("{}01", "00".repeat(31)); @@ -1064,7 +1064,7 @@ mod tests { assert_ne!(plain.address(network).unwrap(), stateful.address(network).unwrap()); assert_ne!(stateful.address(network).unwrap(), moved.address(network).unwrap()); - // The program did not change, only where its funds sit. + // The program is the same, only the address changes. assert_eq!( stateful.commitment_merkle_root().unwrap(), moved.commitment_merkle_root().unwrap() @@ -1121,21 +1121,21 @@ mod tests { } #[test] - fn reports_the_assets_liquid_actually_holds() { + fn issuance_report_matches_liquid_asset_ids() { for (txid, vout, contract, asset, _) in ON_CHAIN { assert_eq!(report_for(txid, vout, contract).asset_id, asset); } } #[test] - fn reports_the_reissuance_tokens_liquid_actually_holds() { + fn issuance_report_matches_liquid_token_ids() { for (txid, vout, contract, _, token) in ON_CHAIN { assert_eq!(report_for(txid, vout, contract).reissuance_token_id, token); } } #[test] - fn reports_an_entropy_its_own_asset_can_be_rederived_from() { + fn reported_entropy_derives_the_asset() { for (txid, vout, contract, asset, _) in ON_CHAIN { let reported = report_for(txid, vout, contract).entropy; let read_back = AssetEntropy::from_str(&reported).expect("a reported entropy"); @@ -1145,7 +1145,7 @@ mod tests { } #[test] - fn commits_to_no_issuer_contract_unless_one_is_named() { + fn missing_issuer_contract_is_all_zeroes() { let empty = [0_u8; 32]; assert_eq!(TransactionBuilder::issuer_contract(None), Ok(empty)); @@ -1155,7 +1155,7 @@ mod tests { } #[test] - fn id_leaves_in_the_form_it_arrived_in() { + fn issuer_contract_keeps_its_display_byte_order() { let written = "ce091c998b83c78bb71a632313ba3760f1763d9cfcffae02258ffa9865a37bd2"; let read = TransactionBuilder::issuer_contract(Some(written)).expect("a written id"); @@ -1165,7 +1165,7 @@ mod tests { } #[test] - fn refuses_an_issuer_contract_that_is_not_an_id() { + fn malformed_issuer_contract_is_rejected() { assert!(TransactionBuilder::issuer_contract(Some("not hex at all")).is_err()); assert!(TransactionBuilder::issuer_contract(Some("00ff")).is_err()); } @@ -1178,8 +1178,8 @@ mod tests { }"#; #[test] - fn reads_back_what_the_wallet_unblinded() { - let secrets = TransactionBuilder::blinding_secrets(SECRETS).expect("the wallet's own reading"); + fn blinding_secrets_are_parsed() { + let secrets = TransactionBuilder::blinding_secrets(SECRETS).expect("valid blinding secrets"); assert_eq!(secrets.value, 100_000); assert_eq!( @@ -1189,25 +1189,25 @@ mod tests { } #[test] - fn refuses_secrets_that_leave_a_field_out() { + fn blinding_secrets_without_a_field_are_rejected() { for missing in ["value", "asset", "assetBlindingFactor", "valueBlindingFactor"] { let without = SECRETS.replace(missing, "somethingElse"); assert!( TransactionBuilder::blinding_secrets(&without).is_err(), - "a reading without {missing} is not a reading" + "secrets without {missing} are rejected" ); } } #[test] - fn refuses_secrets_that_are_not_a_reading_at_all() { + fn malformed_blinding_secrets_are_rejected() { assert!(TransactionBuilder::blinding_secrets("not json").is_err()); assert!(TransactionBuilder::blinding_secrets("{}").is_err()); } #[test] - fn reads_a_value_written_as_a_decimal_string_exactly() { + fn decimal_string_value_is_parsed_exactly() { for (written, exact) in [ ("0", 0), ("9007199254740993", 9_007_199_254_740_993), @@ -1222,7 +1222,7 @@ mod tests { } #[test] - fn refuses_a_json_number_above_javascripts_safe_integer_limit() { + fn json_number_above_safe_integer_is_rejected() { let safe = serde_json::json!(9_007_199_254_740_991_u64); let unsafe_number = serde_json::from_str::("288230376151711740") .expect("the decimal digits emitted by JSON.stringify(2 ** 58)"); @@ -1236,7 +1236,7 @@ mod tests { } #[test] - fn refuses_an_amount_that_is_not_plain_decimal_digits() { + fn non_decimal_amount_is_rejected() { for written in [ serde_json::json!(""), serde_json::json!("+1"), @@ -1253,7 +1253,7 @@ mod tests { const TOKEN_BLINDER: &str = "0000000000000000000000000000000000000000000000000000000000000001"; const VALUE_BLINDER: &str = "0000000000000000000000000000000000000000000000000000000000000003"; - /// The entropy of the first chain vector, as `IssuanceReport` writes it. + /// The entropy of the first chain vector, in the format `IssuanceReport` uses. fn first_entropy() -> String { let (txid, vout, contract, _, _) = ON_CHAIN[0]; @@ -1271,8 +1271,8 @@ mod tests { AssetBlindingFactor::from_str(written).expect("a blinder") } - /// An output holding one unit of `asset`, committed with `committed_bf` or left explicit, - /// paired with the opening the wallet claims for it. + /// An input spending one unit of `asset`, blinded with `committed_bf` or left explicit, with + /// `claimed_bf` as its secrets. fn holding( asset: AssetId, committed_bf: Option, @@ -1304,7 +1304,7 @@ mod tests { } #[test] - fn reissuance_mints_the_asset_its_entropy_first_issued() { + fn reissuance_mints_the_original_asset() { let entropy = first_entropy(); let token = token_of(&entropy, false); let spent = holding(token, Some(blinder(TOKEN_BLINDER)), blinder(TOKEN_BLINDER)); @@ -1349,7 +1349,7 @@ mod tests { } #[test] - fn reads_a_path_relative_to_the_account() { + fn relative_path_is_parsed() { assert_eq!( TransactionBuilder::relative_path("0/7").expect("a path").to_string(), "0/7" @@ -1372,7 +1372,7 @@ mod tests { } #[test] - fn covenant_input_is_signed_with_the_key_it_names() { + fn covenant_input_keeps_its_derivation_path() { let mut builder = TransactionBuilder::new(); let added = builder.add_covenant_input( @@ -1393,7 +1393,7 @@ mod tests { } #[test] - fn covenant_input_naming_no_key_keeps_the_signers_default() { + fn covenant_input_without_path_uses_the_default_key() { let mut builder = TransactionBuilder::new(); let added = builder.add_covenant_input( @@ -1414,7 +1414,7 @@ mod tests { } #[test] - fn covenant_issuance_input_is_signed_with_the_key_it_names() { + fn covenant_issuance_input_keeps_its_derivation_path() { let mut builder = TransactionBuilder::new(); let added = builder.add_covenant_issuance_input( @@ -1438,7 +1438,7 @@ mod tests { } #[test] - fn wallet_input_is_signed_with_the_key_it_names() { + fn wallet_input_keeps_its_derivation_path() { let mut builder = TransactionBuilder::new(); let added = builder.add_wallet_input(ON_CHAIN[0].0, 0, &spent_output(), None, Some("0/7".to_string())); diff --git a/fixtures/simf/budget.simf b/fixtures/simf/budget.simf index 551a50b7..fab89feb 100644 --- a/fixtures/simf/budget.simf +++ b/fixtures/simf/budget.simf @@ -6,9 +6,9 @@ fn checksig(sig: Signature) { /// Pruning drops the branch that is not taken, so each branch is costed on its own. fn main() { match witness::SIGNATURE { - // One check fits the budget the witness stack buys. + // One check fits within the witness budget. Left(light: Signature) => checksig(light), - // Eight checks of the same signature exceed it. + // Eight checks of the same signature exceed the witness budget. Right(heavy: Signature) => { checksig(heavy); checksig(heavy); diff --git a/fixtures/simf/sig_message.simf b/fixtures/simf/sig_message.simf index eaf373e5..94281b20 100644 --- a/fixtures/simf/sig_message.simf +++ b/fixtures/simf/sig_message.simf @@ -18,7 +18,7 @@ fn tagged_message() -> u256 { } /// sha256(sig_all_hash). Not a tagged hash and not the sighash itself, -/// so neither Sighash nor Tagged can produce it. +/// so neither Sighash nor Tagged can produce this message. fn custom_message() -> u256 { let ctx: Ctx8 = jet::sha_256_ctx_8_init(); let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::sig_all_hash()); diff --git a/fixtures/tests/fuzz_mutation.rs b/fixtures/tests/fuzz_mutation.rs index 715003cb..9812fadc 100644 --- a/fixtures/tests/fuzz_mutation.rs +++ b/fixtures/tests/fuzz_mutation.rs @@ -102,7 +102,7 @@ fn unbalanced_transaction_is_a_setup_error(test_context: TestContext) test_context.engine(scenario).mutations(Mutations::default()).run(); } -/// The template sets the locktime to 100, which makes input 0 enforce it. +/// The template sets the locktime to 100, and input 0 enforces that locktime. #[simplex::fuzz] fn timelock_passes_with_a_spec_on_the_lock_height(test_context: TestContext) { let mut transaction = FinalTransaction::new(); @@ -185,7 +185,7 @@ fn auth_input_requirement_follows_its_utxo(test_context: TestContext) .run(); } -/// The transaction enables the locktime, so a final input has to override it. +/// The transaction enables the locktime, so a final input has to override the transaction's sequence. #[simplex::fuzz] fn sequence_mutation_reaches_the_signed_transaction(test_context: TestContext) { let mut transaction = FinalTransaction::new(); diff --git a/fixtures/tests/fuzz_testing.rs b/fixtures/tests/fuzz_testing.rs index 39aa404d..de935ea1 100644 --- a/fixtures/tests/fuzz_testing.rs +++ b/fixtures/tests/fuzz_testing.rs @@ -66,7 +66,7 @@ fn signed_witness_is_accepted(test_context: TestContext) -> anyhow::Re Ok(()) } -/// The hot path signs with the first of its two signatures, the second is never checked. +/// The hot path checks the first of its two signatures and never the second. #[simplex::fuzz] fn nested_sig_spends_through_its_hot_path(test_context: TestContext) -> anyhow::Result<()> { let public_key = test_context.get_default_signer().get_schnorr_public_key().serialize(); diff --git a/fixtures/tests/ignore_default_tests.rs b/fixtures/tests/ignore_default_tests.rs index f6007878..e7deab9e 100644 --- a/fixtures/tests/ignore_default_tests.rs +++ b/fixtures/tests/ignore_default_tests.rs @@ -1,14 +1,14 @@ -// Dummy test to insure that `simplex test` runs only `#[simplex::test]` functions +// Checks that `simplex test` runs only `#[simplex::test]` functions #[cfg(test)] mod test { #[simplex::test] - fn smplx_test_invoked(_: simplex::TestContext) -> anyhow::Result<()> { + fn simplex_test_is_run(_: simplex::TestContext) -> anyhow::Result<()> { Ok(()) } #[test] - fn default_tests_should_not_be_invoked() { + fn plain_test_is_not_run() { panic!() } } diff --git a/fixtures/tests/log_level.rs b/fixtures/tests/log_level.rs index ed5084e2..b9db0884 100644 --- a/fixtures/tests/log_level.rs +++ b/fixtures/tests/log_level.rs @@ -15,7 +15,7 @@ fn setup_dummy(context: &simplex::TestContext) -> (DummyPanicProgram, simplex::s } #[simplex::test] -fn dummy_log_level(context: simplex::TestContext) -> anyhow::Result<()> { +fn failing_program_reports_its_error(context: simplex::TestContext) -> anyhow::Result<()> { let provider = context.get_default_provider(); let signer = context.get_default_signer();