diff --git a/.cargo/config.toml b/.cargo/config.toml index f0c444881c..9d4008b22c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,7 @@ [alias] stacks-node = "run --package stacks-node --" fmt-stacks = "fmt -- --config group_imports=StdExternalCrate,imports_granularity=Module" -clippy-stacks = "clippy -p stx-genesis -p libstackerdb -p stacks-signer -p pox-locking -p clarity -p libsigner -p stacks-common --no-deps --tests --all-features -- -D warnings" +clippy-stacks = "clippy -p stx-genesis -p libstackerdb -p stacks-signer -p pox-locking -p clarity-serialization -p clarity -p libsigner -p stacks-common --no-deps --tests --all-features -- -D warnings" clippy-stackslib = "clippy -p stackslib --no-deps -- -Aclippy::all -Wclippy::indexing_slicing" # Uncomment to improve performance slightly, at the cost of portability diff --git a/Cargo.lock b/Cargo.lock index 68ef0a0ac5..b0894455cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -644,6 +644,21 @@ dependencies = [ "time 0.2.27", ] +[[package]] +name = "clarity-serialization" +version = "0.0.1" +dependencies = [ + "lazy_static", + "mutants", + "regex", + "rstest", + "serde", + "serde_derive", + "slog", + "stacks-common 0.0.1", + "thiserror", +] + [[package]] name = "colorchoice" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 7b575b1f71..72b167a3d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "stackslib", "stacks-common", "pox-locking", + "clarity-serialization", "clarity", "stx-genesis", "libstackerdb", @@ -12,8 +13,6 @@ members = [ "stacks-node", "contrib/tools/config-docs-generator"] -exclude = ["contrib/clarity-serialization"] - # Dependencies we want to keep the same between workspace members [workspace.dependencies] ed25519-dalek = { version = "2.1.1", default-features = false } diff --git a/contrib/clarity-serialization/Cargo.toml b/clarity-serialization/Cargo.toml similarity index 67% rename from contrib/clarity-serialization/Cargo.toml rename to clarity-serialization/Cargo.toml index 44fd938004..341d8c0c29 100644 --- a/contrib/clarity-serialization/Cargo.toml +++ b/clarity-serialization/Cargo.toml @@ -10,17 +10,17 @@ keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized" readme = "README.md" [dependencies] -lazy_static = "1.4.0" +lazy_static = { workspace = true } regex = { version = "1", default-features = false } -serde = { version = "1", features = ["derive"] } -serde_derive = { version = "1" } -slog = { version = "2.5.2", features = [ "max_level_trace" ] } -stacks_common = { package = "stacks-common", path = "../../stacks-common", default-features = false } -thiserror = { version = "1.0.65" } +serde = { workspace = true } +serde_derive = { workspace = true } +slog = { workspace = true } +stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false } +thiserror = { workspace = true } [dev-dependencies] mutants = "0.0.3" -test-case = { version = "3.3.1", default-features = false } +rstest = "0.17.0" [features] default = [] diff --git a/contrib/clarity-serialization/README.md b/clarity-serialization/README.md similarity index 100% rename from contrib/clarity-serialization/README.md rename to clarity-serialization/README.md diff --git a/contrib/clarity-serialization/src/errors.rs b/clarity-serialization/src/errors.rs similarity index 100% rename from contrib/clarity-serialization/src/errors.rs rename to clarity-serialization/src/errors.rs diff --git a/contrib/clarity-serialization/src/lib.rs b/clarity-serialization/src/lib.rs similarity index 100% rename from contrib/clarity-serialization/src/lib.rs rename to clarity-serialization/src/lib.rs diff --git a/contrib/clarity-serialization/src/representations.rs b/clarity-serialization/src/representations.rs similarity index 100% rename from contrib/clarity-serialization/src/representations.rs rename to clarity-serialization/src/representations.rs diff --git a/contrib/clarity-serialization/src/tests/mod.rs b/clarity-serialization/src/tests/mod.rs similarity index 100% rename from contrib/clarity-serialization/src/tests/mod.rs rename to clarity-serialization/src/tests/mod.rs diff --git a/clarity-serialization/src/tests/representations.rs b/clarity-serialization/src/tests/representations.rs new file mode 100644 index 0000000000..b4e2219d4f --- /dev/null +++ b/clarity-serialization/src/tests/representations.rs @@ -0,0 +1,211 @@ +// Copyright (C) 2025 Stacks Open Internet Foundation +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use rstest::rstest; + +use crate::errors::CodecError; +use crate::representations::{ + CONTRACT_MAX_NAME_LENGTH, CONTRACT_MIN_NAME_LENGTH, ClarityName, ContractName, MAX_STRING_LEN, +}; +use crate::stacks_common::codec::StacksMessageCodec; + +#[rstest] +#[case::valid_name("hello")] +#[case::dash("hello-dash")] +#[case::underscore("hello_underscore")] +#[case::numbers("test123")] +#[case::single_letter("a")] +#[case::exclamation_mark("set-token-uri!")] +#[case::question_mark("is-owner?")] +#[case::plus("math+")] +#[case::less_than("greater-than<")] +#[case::greater_than("less-than>")] +#[case::less_than_or_equal_to("<=")] +#[case::greater_than_or_equal_to(">=")] +#[case::asterisk("*")] +#[case::slash("/")] +#[case::dash_only("-")] +#[case::equals("=")] +fn test_clarity_name_valid(#[case] name: &str) { + let clarity_name = ClarityName::try_from(name.to_string()) + .unwrap_or_else(|_| panic!("Should parse valid clarity name: {name}")); + assert_eq!(clarity_name.as_str(), name); +} + +#[rstest] +#[case::empty("")] +#[case::starts_with_number("123abc")] +#[case::contains_space("hello world")] +#[case::contains_at("hello@world")] +#[case::contains_hash("hello#world")] +#[case::contains_dollar("hello$world")] +#[case::contains_percent("hello%world")] +#[case::contains_ampersand("hello&world")] +#[case::contains_dot("hello.world")] +#[case::contains_comma("hello,world")] +#[case::contains_semicolon("hello;world")] +#[case::contains_colon("hello:world")] +#[case::contains_pipe("hello|world")] +#[case::contains_backslash("hello\\world")] +#[case::contains_quote("hello\"world")] +#[case::contains_apostrophe("hello'world")] +#[case::contains_bracket_open("hello[world")] +#[case::contains_bracket_close("hello]world")] +#[case::contains_curly_open("hello{world")] +#[case::contains_curly_close("hello}world")] +#[case::contains_parenthesis_open("hello(world")] +#[case::contains_parenthesis_close("hello)world")] +#[case::too_long(&"a".repeat(MAX_STRING_LEN as usize + 1))] +fn test_clarity_name_invalid(#[case] name: &str) { + let result = ClarityName::try_from(name.to_string()); + assert!(result.is_err()); + assert!(matches!( + result.unwrap_err(), + CodecError::InvalidClarityName(_, _) + )); +} + +#[rstest] +#[case("test-name")] +#[case::max_length(&"a".repeat(MAX_STRING_LEN as usize))] +fn test_clarity_name_serialization(#[case] name: &str) { + let name = ClarityName::try_from(name.to_string()).unwrap(); + + let mut buffer = Vec::new(); + name.consensus_serialize(&mut buffer) + .unwrap_or_else(|_| panic!("Serialization should succeed for name: {name}")); + + // Should have length byte followed by the string bytes + assert_eq!(buffer[0], name.len()); + assert_eq!(&buffer[1..], name.as_bytes()); + + // Test deserialization + let deserialized = ClarityName::consensus_deserialize(&mut buffer.as_slice()).unwrap(); + assert_eq!(deserialized, name); +} + +// the first byte is the length of the buffer. +#[rstest] +#[case::invalid_utf8(vec![4, 0xFF, 0xFE, 0xFD, 0xFC], "Failed to parse Clarity name: could not contruct from utf8")] +#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Clarity name: InvalidClarityName(\"ClarityName\", \"2i\")")] // starts with number +#[case::too_long(vec![MAX_STRING_LEN + 1], "Failed to deserialize clarity name: too long")] +#[case::wrong_length(vec![3, b'a'], "failed to fill whole buffer")] +fn test_clarity_name_deserialization_errors(#[case] buffer: Vec, #[case] error_message: &str) { + let result = ClarityName::consensus_deserialize(&mut buffer.as_slice()); + assert!(result.is_err()); + assert_eq!(result.unwrap_err().to_string(), error_message); +} + +#[rstest] +#[case::valid_name("hello")] +#[case::dash("contract-name")] +#[case::underscore("hello_world")] +#[case::numbers("test123")] +#[case::transient("__transient")] +#[case::min_length("a")] +#[case::max_length(&"a".repeat(CONTRACT_MAX_NAME_LENGTH))] +#[case::max_string_len(&"a".repeat(MAX_STRING_LEN as usize))] +fn test_contract_name_valid(#[case] name: &str) { + let contract_name = ContractName::try_from(name.to_string()) + .unwrap_or_else(|_| panic!("Should parse valid contract name: {name}")); + assert_eq!(contract_name.as_str(), name); +} + +#[rstest] +#[case::empty("")] +#[case::starts_with_number("123contract")] +#[case::contains_space("hello world")] +#[case::contains_at("hello@world")] +#[case::contains_dot("hello.world")] +#[case::contains_exclamation("hello!world")] +#[case::contains_question("hello?world")] +#[case::contains_plus("hello+world")] +#[case::contains_asterisk("hello*world")] +#[case::contains_equals("hello=world")] +#[case::contains_slash("hello/world")] +#[case::contains_less_than("helloworld")] +#[case::contains_comma("hello,world")] +#[case::contains_semicolon("hello;world")] +#[case::contains_colon("hello:world")] +#[case::contains_pipe("hello|world")] +#[case::contains_backslash("hello\\world")] +#[case::contains_quote("hello\"world")] +#[case::contains_apostrophe("hello'world")] +#[case::contains_bracket_open("hello[world")] +#[case::contains_bracket_close("hello]world")] +#[case::contains_curly_open("hello{world")] +#[case::contains_curly_close("hello}world")] +#[case::contains_parenthesis_open("hello(world")] +#[case::contains_parenthesis_close("hello)world")] +#[case::too_short(&"a".repeat(CONTRACT_MIN_NAME_LENGTH - 1))] +#[case::too_long(&"a".repeat(MAX_STRING_LEN as usize + 1))] +fn test_contract_name_invalid(#[case] name: &str) { + let result = ContractName::try_from(name.to_string()); + assert!(result.is_err()); + assert!(matches!( + result.unwrap_err(), + CodecError::InvalidContractName(_, _) + )); +} + +#[rstest] +#[case::valid_name("test-contract")] +#[case::dash("contract-name")] +#[case::underscore("hello_world")] +#[case::numbers("test123")] +#[case::transient("__transient")] +#[case::min_length("a")] +#[case::max_length(&"a".repeat(CONTRACT_MAX_NAME_LENGTH))] +fn test_contract_name_serialization(#[case] name: &str) { + let name = ContractName::try_from(name.to_string()).unwrap(); + let mut buffer = Vec::with_capacity((name.len() + 1) as usize); + name.consensus_serialize(&mut buffer) + .unwrap_or_else(|_| panic!("Serialization should succeed for name: {name}")); + assert_eq!(buffer[0], name.len()); + assert_eq!(&buffer[1..], name.as_bytes()); + + // Test deserialization + let deserialized = ContractName::consensus_deserialize(&mut buffer.as_slice()).unwrap(); + assert_eq!(deserialized, name); +} + +#[test] +fn test_contract_name_serialization_too_long() { + let name = + ContractName::try_from("a".repeat(CONTRACT_MAX_NAME_LENGTH + 1)).expect("should parse"); + let mut buffer = Vec::with_capacity((name.len() + 1) as usize); + let result = name.consensus_serialize(&mut buffer); + assert!(result.is_err()); + assert_eq!( + result.unwrap_err().to_string(), + format!( + "Failed to serialize contract name: too short or too long: {}", + name.len() + ) + ); +} + +// the first byte is the length of the buffer. +#[rstest] +#[case::invalid_utf8(vec![4, 0xFF, 0xFE, 0xFD, 0xFC], "Failed to parse Contract name: could not construct from utf8")] +#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Contract name: InvalidContractName(\"ContractName\", \"2i\")")] // starts with number +#[case::too_long(vec![MAX_STRING_LEN + 1], &format!("Failed to deserialize contract name: too short or too long: {}", MAX_STRING_LEN + 1))] +#[case::wrong_length(vec![3, b'a'], "failed to fill whole buffer")] +fn test_contract_name_deserialization_errors(#[case] buffer: Vec, #[case] error_message: &str) { + let result = ContractName::consensus_deserialize(&mut buffer.as_slice()); + assert!(result.is_err()); + assert_eq!(result.unwrap_err().to_string(), error_message); +} diff --git a/contrib/clarity-serialization/src/tests/types/mod.rs b/clarity-serialization/src/tests/types/mod.rs similarity index 98% rename from contrib/clarity-serialization/src/tests/types/mod.rs rename to clarity-serialization/src/tests/types/mod.rs index fd317e9e77..40f6aec738 100644 --- a/contrib/clarity-serialization/src/tests/types/mod.rs +++ b/clarity-serialization/src/tests/types/mod.rs @@ -17,11 +17,11 @@ mod signatures; use stacks_common::types::StacksEpochId; +use crate::CodecError; use crate::types::{ - BuffData, ListTypeData, PrincipalData, SequenceData, TupleData, TypeSignature, Value, - MAX_VALUE_SIZE, + BuffData, ListTypeData, MAX_VALUE_SIZE, PrincipalData, SequenceData, TupleData, TypeSignature, + Value, }; -use crate::CodecError; #[test] fn test_constructors() { diff --git a/contrib/clarity-serialization/src/tests/types/serialization.rs b/clarity-serialization/src/tests/types/serialization.rs similarity index 97% rename from contrib/clarity-serialization/src/tests/types/serialization.rs rename to clarity-serialization/src/tests/types/serialization.rs index 15256b14a5..5e6112d061 100644 --- a/contrib/clarity-serialization/src/tests/types/serialization.rs +++ b/clarity-serialization/src/tests/types/serialization.rs @@ -16,8 +16,8 @@ use std::io::Write; use crate::errors::CodecError; use crate::types::{ - PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TupleData, TypeSignature, - Value, MAX_VALUE_SIZE, + MAX_VALUE_SIZE, PrincipalData, QualifiedContractIdentifier, StandardPrincipalData, TupleData, + TypeSignature, Value, }; fn test_deser_ser(v: Value) { @@ -51,12 +51,9 @@ fn test_bad_expectation(v: Value, e: TypeSignature) { #[test] fn test_lists() { - let list_list_int = Value::list_from(vec![Value::list_from(vec![ - Value::Int(1), - Value::Int(2), - Value::Int(3), + let list_list_int = Value::list_from(vec![ + Value::list_from(vec![Value::Int(1), Value::Int(2), Value::Int(3)]).unwrap(), ]) - .unwrap()]) .unwrap(); test_deser_ser(list_list_int.clone()); test_deser_ser(Value::list_from(vec![]).unwrap()); @@ -290,8 +287,8 @@ fn test_vectors() { Ok(StandardPrincipalData::new( 0x00, [ - 0x11, 0xde, 0xad, 0xbe, 0xef, 0x11, 0xab, 0xab, 0xff, 0xff, 0x11, 0xde, - 0xad, 0xbe, 0xef, 0x11, 0xab, 0xab, 0xff, 0xff, + 0x11, 0xde, 0xad, 0xbe, 0xef, 0x11, 0xab, 0xab, 0xff, 0xff, 0x11, 0xde, 0xad, + 0xbe, 0xef, 0x11, 0xab, 0xab, 0xff, 0xff, ], ) .unwrap() diff --git a/contrib/clarity-serialization/src/tests/types/signatures.rs b/clarity-serialization/src/tests/types/signatures.rs similarity index 100% rename from contrib/clarity-serialization/src/tests/types/signatures.rs rename to clarity-serialization/src/tests/types/signatures.rs index 41dfa7a657..d04949c183 100644 --- a/contrib/clarity-serialization/src/tests/types/signatures.rs +++ b/clarity-serialization/src/tests/types/signatures.rs @@ -15,8 +15,8 @@ use std::collections::HashSet; use crate::errors::CodecError; -use crate::types::signatures::{CallableSubtype, TypeSignature}; use crate::types::TypeSignature::{BoolType, IntType, ListUnionType, UIntType}; +use crate::types::signatures::{CallableSubtype, TypeSignature}; use crate::types::{ QualifiedContractIdentifier, SequenceSubtype, TraitIdentifier, TupleTypeSignature, }; diff --git a/contrib/clarity-serialization/src/types/mod.rs b/clarity-serialization/src/types/mod.rs similarity index 100% rename from contrib/clarity-serialization/src/types/mod.rs rename to clarity-serialization/src/types/mod.rs diff --git a/contrib/clarity-serialization/src/types/serialization.rs b/clarity-serialization/src/types/serialization.rs similarity index 100% rename from contrib/clarity-serialization/src/types/serialization.rs rename to clarity-serialization/src/types/serialization.rs diff --git a/contrib/clarity-serialization/src/types/signatures.rs b/clarity-serialization/src/types/signatures.rs similarity index 100% rename from contrib/clarity-serialization/src/types/signatures.rs rename to clarity-serialization/src/types/signatures.rs diff --git a/contrib/clarity-serialization/Cargo.lock b/contrib/clarity-serialization/Cargo.lock deleted file mode 100644 index 753ab4093a..0000000000 --- a/contrib/clarity-serialization/Cargo.lock +++ /dev/null @@ -1,1191 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bumpalo" -version = "3.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" - -[[package]] -name = "cc" -version = "1.2.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" -dependencies = [ - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - -[[package]] -name = "chrono" -version = "0.4.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "windows-link", -] - -[[package]] -name = "clarity-serialization" -version = "0.0.1" -dependencies = [ - "lazy_static", - "mutants", - "regex", - "serde", - "serde_derive", - "slog", - "stacks-common", - "test-case", - "thiserror", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto", - "rustc_version", - "serde", - "subtle", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "deranged" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" -dependencies = [ - "powerfmt", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" -dependencies = [ - "curve25519-dalek", - "ed25519", - "sha2 0.10.9", - "subtle", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "hashbrown" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", - "serde", -] - -[[package]] -name = "hermit-abi" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" - -[[package]] -name = "hmac" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - -[[package]] -name = "hmac-drbg" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" -dependencies = [ - "digest 0.9.0", - "generic-array", - "hmac", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "is-terminal" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - -[[package]] -name = "itoa" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" - -[[package]] -name = "js-sys" -version = "0.3.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.174" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" - -[[package]] -name = "libredox" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4488594b9328dee448adb906d8b126d9b7deb7cf5c22161ee591610bb1be83c0" -dependencies = [ - "bitflags", - "libc", -] - -[[package]] -name = "libsecp256k1" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79019718125edc905a079a70cfa5f3820bc76139fc91d6f9abc27ea2a887139" -dependencies = [ - "arrayref", - "base64", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", - "rand", - "serde", - "sha2 0.9.9", - "typenum", -] - -[[package]] -name = "libsecp256k1-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle", -] - -[[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "libsecp256k1-gen-genmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "log" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" - -[[package]] -name = "memchr" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" - -[[package]] -name = "mutants" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126" - -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" - -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rustversion" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" - -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - -[[package]] -name = "secp256k1" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" -dependencies = [ - "secp256k1-sys", - "serde", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" - -[[package]] -name = "serde" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.141" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", - "sha2-asm", -] - -[[package]] -name = "sha2-asm" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b845214d6175804686b2bd482bcffe96651bb2d1200742b712003504a2dac1ab" -dependencies = [ - "cc", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" - -[[package]] -name = "slog" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" - -[[package]] -name = "slog-json" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e1e53f61af1e3c8b852eef0a9dee29008f55d6dd63794f3f12cef786cf0f219" -dependencies = [ - "serde", - "serde_json", - "slog", - "time", -] - -[[package]] -name = "slog-term" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e022d0b998abfe5c3782c1f03551a596269450ccd677ea51c56f8b214610e8" -dependencies = [ - "is-terminal", - "slog", - "term", - "thread_local", - "time", -] - -[[package]] -name = "stacks-common" -version = "0.0.1" -dependencies = [ - "chrono", - "curve25519-dalek", - "ed25519-dalek", - "getrandom", - "hashbrown", - "lazy_static", - "libsecp256k1", - "rand", - "ripemd", - "secp256k1", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.9", - "sha3", - "slog", - "slog-json", - "slog-term", - "toml", -] - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - -[[package]] -name = "test-case" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" -dependencies = [ - "test-case-macros", -] - -[[package]] -name = "test-case-core" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" -dependencies = [ - "cfg-if", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "test-case-macros" -version = "3.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "test-case-core", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "time" -version = "0.3.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" - -[[package]] -name = "time-macros" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "typenum" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" - -[[package]] -name = "unicode-ident" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasm-bindgen" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-core" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings", -] - -[[package]] -name = "windows-implement" -version = "0.60.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-interface" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - -[[package]] -name = "windows-result" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "zerocopy" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/contrib/clarity-serialization/src/tests/representations.rs b/contrib/clarity-serialization/src/tests/representations.rs deleted file mode 100644 index 19fca84708..0000000000 --- a/contrib/clarity-serialization/src/tests/representations.rs +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (C) 2025 Stacks Open Internet Foundation -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -use std::io::Read; - -use test_case::test_case; - -use crate::errors::CodecError; -use crate::representations::{ - ClarityName, ContractName, CONTRACT_MAX_NAME_LENGTH, CONTRACT_MIN_NAME_LENGTH, MAX_STRING_LEN, -}; -use crate::stacks_common::codec::StacksMessageCodec; - -#[test_case("hello"; "valid_name")] -#[test_case("hello-dash"; "dash")] -#[test_case("hello_underscore"; "underscore")] -#[test_case("test123"; "numbers")] -#[test_case("a"; "single_letter")] -#[test_case("set-token-uri!"; "exclamation_mark")] -#[test_case("is-owner?"; "question_mark")] -#[test_case("math+"; "plus")] -#[test_case("greater-than<"; "less_than")] -#[test_case("less-than>"; "greater_than")] -#[test_case("<="; "less_than_or_equal_to")] -#[test_case(">="; "greater_than_or_equal_to")] -#[test_case("*"; "asterisk")] -#[test_case("/"; "slash")] -#[test_case("-"; "dash-only")] -#[test_case("="; "equals")] -fn test_clarity_name_valid(name: &str) { - let clarity_name = ClarityName::try_from(name.to_string()) - .unwrap_or_else(|_| panic!("Should parse valid clarity name: {name}")); - assert_eq!(clarity_name.as_str(), name); -} - -#[test_case(""; "empty")] -#[test_case("123abc"; "starts_with_number")] -#[test_case("hello world"; "contains_space")] -#[test_case("hello@world"; "contains_at")] -#[test_case("hello#world"; "contains_hash")] -#[test_case("hello$world"; "contains_dollar")] -#[test_case("hello%world"; "contains_percent")] -#[test_case("hello&world"; "contains_ampersand")] -#[test_case("hello.world"; "contains_dot")] -#[test_case("hello,world"; "contains_comma")] -#[test_case("hello;world"; "contains_semicolon")] -#[test_case("hello:world"; "contains_colon")] -#[test_case("hello|world"; "contains_pipe")] -#[test_case("hello\\world"; "contains_backslash")] -#[test_case("hello\"world"; "contains_quote")] -#[test_case("hello'world"; "contains_apostrophe")] -#[test_case("hello[world"; "contains_bracket_open")] -#[test_case("hello]world"; "contains_bracket_close")] -#[test_case("hello{world"; "contains_curly_open")] -#[test_case("hello}world"; "contains_curly_close")] -#[test_case("hello(world"; "contains_parenthesis_open")] -#[test_case("hello)world"; "contains_parenthesis_close")] -#[test_case(&"a".repeat(MAX_STRING_LEN as usize + 1); "too_long")] -fn test_clarity_name_invalid(name: &str) { - let result = ClarityName::try_from(name.to_string()); - assert!(result.is_err()); - assert!(matches!( - result.unwrap_err(), - CodecError::InvalidClarityName(_, _) - )); -} - -#[test_case("test-name")] -#[test_case(&"a".repeat(MAX_STRING_LEN as usize); "max-length")] -fn test_clarity_name_serialization(name: &str) { - let name = ClarityName::try_from(name.to_string()).unwrap(); - - let mut buffer = Vec::new(); - name.consensus_serialize(&mut buffer) - .unwrap_or_else(|_| panic!("Serialization should succeed for name: {name}")); - - // Should have length byte followed by the string bytes - assert_eq!(buffer[0], name.len()); - assert_eq!(&buffer[1..], name.as_bytes()); - - // Test deserialization - let deserialized = ClarityName::consensus_deserialize(&mut buffer.as_slice()).unwrap(); - assert_eq!(deserialized, name); -} - -// the first byte is the length of the buffer. -#[test_case(vec![4, 0xFF, 0xFE, 0xFD, 0xFC].as_slice(), "Failed to parse Clarity name: could not contruct from utf8"; "invalid_utf8")] -#[test_case(vec![2, b'2', b'i'].as_slice(), "Failed to parse Clarity name: InvalidClarityName(\"ClarityName\", \"2i\")"; "invalid_name")] // starts with number -#[test_case(vec![MAX_STRING_LEN + 1].as_slice(), "Failed to deserialize clarity name: too long"; "too_long")] -#[test_case(vec![3, b'a'].as_slice(), "failed to fill whole buffer"; "wrong_length")] -fn test_clarity_name_deserialization_errors(mut buffer: R, error_message: &str) { - let result = ClarityName::consensus_deserialize(&mut buffer); - assert!(result.is_err()); - assert_eq!(result.unwrap_err().to_string(), error_message); -} - -#[test_case("hello"; "valid_name")] -#[test_case("contract-name"; "dash")] -#[test_case("hello_world"; "underscore")] -#[test_case("test123"; "numbers")] -#[test_case("__transient"; "transient")] -#[test_case("a"; "min_length")] -#[test_case(&"a".repeat(CONTRACT_MAX_NAME_LENGTH); "max_length")] -#[test_case(&"a".repeat(MAX_STRING_LEN as usize); "max_string_len")] -fn test_contract_name_valid(name: &str) { - let contract_name = ContractName::try_from(name.to_string()) - .unwrap_or_else(|_| panic!("Should parse valid contract name: {name}")); - assert_eq!(contract_name.as_str(), name); -} - -#[test_case(""; "emtpy")] -#[test_case("123contract"; "starts_with_number")] -#[test_case("hello world"; "contains_space")] -#[test_case("hello@world"; "contains_at")] -#[test_case("hello.world"; "contains_dot")] -#[test_case("hello!world"; "contains_exclamation")] -#[test_case("hello?world"; "contains_question")] -#[test_case("hello+world"; "contains_plus")] -#[test_case("hello*world"; "contains_asterisk")] -#[test_case("hello=world"; "contains_equals")] -#[test_case("hello/world"; "contains_slash")] -#[test_case("helloworld"; "contains_greater_than")] -#[test_case("hello,world"; "contains_comma")] -#[test_case("hello;world"; "contains_semicolon")] -#[test_case("hello:world"; "contains_colon")] -#[test_case("hello|world"; "contains_pipe")] -#[test_case("hello\\world"; "contains_backslash")] -#[test_case("hello\"world"; "contains_quote")] -#[test_case("hello'world"; "contains_apostrophe")] -#[test_case("hello[world"; "contains_bracket_open")] -#[test_case("hello]world"; "contains_bracket_close")] -#[test_case("hello{world"; "contains_curly_open")] -#[test_case("hello}world"; "contains_curly_close")] -#[test_case("hello(world"; "contains_parenthesis_open")] -#[test_case("hello)world"; "contains_parenthesis_close")] -#[test_case(&"a".repeat(CONTRACT_MIN_NAME_LENGTH - 1); "too_short")] -#[test_case(&"a".repeat(MAX_STRING_LEN as usize + 1); "too_long")] -fn test_contract_name_invalid(name: &str) { - let result = ContractName::try_from(name.to_string()); - assert!(result.is_err()); - assert!(matches!( - result.unwrap_err(), - CodecError::InvalidContractName(_, _) - )); -} - -#[test_case("test-contract"; "valid_name")] -#[test_case("contract-name"; "dash")] -#[test_case("hello_world"; "underscore")] -#[test_case("test123"; "numbers")] -#[test_case("__transient"; "transient")] -#[test_case("a"; "min_length")] -#[test_case(&"a".repeat(CONTRACT_MAX_NAME_LENGTH); "max_length")] -fn test_contract_name_serialization(name: &str) { - let name = ContractName::try_from(name.to_string()).unwrap(); - let mut buffer = Vec::with_capacity((name.len() + 1) as usize); - name.consensus_serialize(&mut buffer) - .unwrap_or_else(|_| panic!("Serialization should succeed for name: {name}")); - assert_eq!(buffer[0], name.len()); - assert_eq!(&buffer[1..], name.as_bytes()); - - // Test deserialization - let deserialized = ContractName::consensus_deserialize(&mut buffer.as_slice()).unwrap(); - assert_eq!(deserialized, name); -} - -#[test_case(&"a".repeat(CONTRACT_MAX_NAME_LENGTH + 1); "too_long")] -fn test_contract_name_serialization_too_long_or_short(name: &str) { - let name = ContractName::try_from(name.to_string()).expect("should parse"); - let mut buffer = Vec::with_capacity((name.len() + 1) as usize); - let result = name.consensus_serialize(&mut buffer); - assert!(result.is_err()); - assert_eq!( - result.unwrap_err().to_string(), - format!( - "Failed to serialize contract name: too short or too long: {}", - name.len() - ) - ); -} - -// the first byte is the length of the buffer. -#[test_case(vec![4, 0xFF, 0xFE, 0xFD, 0xFC].as_slice(), "Failed to parse Contract name: could not construct from utf8"; "invalid_utf8")] -#[test_case(vec![2, b'2', b'i'].as_slice(), "Failed to parse Contract name: InvalidContractName(\"ContractName\", \"2i\")"; "invalid_name")] // starts with number -#[test_case(vec![MAX_STRING_LEN + 1].as_slice(), &format!("Failed to deserialize contract name: too short or too long: {}", MAX_STRING_LEN + 1); "too_long")] -#[test_case(vec![3, b'a'].as_slice(), "failed to fill whole buffer"; "wrong_length")] -fn test_contract_name_deserialization_errors(mut buffer: R, error_message: &str) { - let result = ContractName::consensus_deserialize(&mut buffer); - assert!(result.is_err()); - assert_eq!(result.unwrap_err().to_string(), error_message); -} diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix index 3e09913ea3..e038fa4058 100644 --- a/contrib/nix/flake.nix +++ b/contrib/nix/flake.nix @@ -85,6 +85,8 @@ (lib.fileset.fileFilter (file: file.hasExt "clar") ../..) # (craneLib.fileset.commonCargoSources ../../clarity) + (craneLib.fileset.commonCargoSources ../../clarity-serialization) + ../../clarity-serialization/README.md (craneLib.fileset.commonCargoSources ../../libsigner) (craneLib.fileset.commonCargoSources ../../libstackerdb) (craneLib.fileset.commonCargoSources ../../pox-locking)