mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: convert fuzz test names to snake case (#1390)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -724,6 +724,7 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
|||||||
name = "codecs-derive"
|
name = "codecs-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"convert_case 0.6.0",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"proc-macro2 1.0.50",
|
"proc-macro2 1.0.50",
|
||||||
"quote 1.0.23",
|
"quote 1.0.23",
|
||||||
|
|||||||
@ -21,6 +21,7 @@ proc-macro = true
|
|||||||
proc-macro2 = "1.0.47"
|
proc-macro2 = "1.0.47"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0", features = ["full"] }
|
syn = { version = "1.0", features = ["full"] }
|
||||||
|
convert_case = "0.6.0"
|
||||||
|
|
||||||
# codecs
|
# codecs
|
||||||
serde = { version = "1.0.*", default-features = false }
|
serde = { version = "1.0.*", default-features = false }
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
//! Code generator for the `Compact` trait.
|
//! Code generator for the `Compact` trait.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use convert_case::{Case, Casing};
|
||||||
|
|
||||||
/// Generates code to implement the `Compact` trait for a data type.
|
/// Generates code to implement the `Compact` trait for a data type.
|
||||||
pub fn generate_from_to(ident: &Ident, fields: &FieldList) -> TokenStream2 {
|
pub fn generate_from_to(ident: &Ident, fields: &FieldList) -> TokenStream2 {
|
||||||
@ -9,8 +10,10 @@ pub fn generate_from_to(ident: &Ident, fields: &FieldList) -> TokenStream2 {
|
|||||||
let to_compact = generate_to_compact(fields, ident);
|
let to_compact = generate_to_compact(fields, ident);
|
||||||
let from_compact = generate_from_compact(fields, ident);
|
let from_compact = generate_from_compact(fields, ident);
|
||||||
|
|
||||||
let fuzz = format_ident!("fuzz_test_{ident}");
|
let snake_case_ident = ident.to_string().to_case(Case::Snake);
|
||||||
let test = format_ident!("fuzz_{ident}");
|
|
||||||
|
let fuzz = format_ident!("fuzz_test_{snake_case_ident}");
|
||||||
|
let test = format_ident!("fuzz_{snake_case_ident}");
|
||||||
|
|
||||||
// Build function
|
// Build function
|
||||||
quote! {
|
quote! {
|
||||||
|
|||||||
@ -238,15 +238,15 @@ mod tests {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[test_fuzz::test_fuzz]
|
#[test_fuzz::test_fuzz]
|
||||||
fn fuzz_test_TestStruct(obj: TestStruct) {
|
fn fuzz_test_test_struct(obj: TestStruct) {
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
let len = obj.clone().to_compact(&mut buf);
|
let len = obj.clone().to_compact(&mut buf);
|
||||||
let (same_obj, buf) = TestStruct::from_compact(buf.as_ref(), len);
|
let (same_obj, buf) = TestStruct::from_compact(buf.as_ref(), len);
|
||||||
assert_eq!(obj, same_obj);
|
assert_eq!(obj, same_obj);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
pub fn fuzz_TestStruct() {
|
pub fn fuzz_test_struct() {
|
||||||
fuzz_test_TestStruct(TestStruct::default())
|
fuzz_test_test_struct(TestStruct::default())
|
||||||
}
|
}
|
||||||
impl Compact for TestStruct {
|
impl Compact for TestStruct {
|
||||||
fn to_compact(self, buf: &mut impl bytes::BufMut) -> usize {
|
fn to_compact(self, buf: &mut impl bytes::BufMut) -> usize {
|
||||||
|
|||||||
Reference in New Issue
Block a user