diff --git a/.github/workflows/cargo_fmt.yml b/.github/workflows/cargo_fmt.yml index 59757a4..fa04d31 100644 --- a/.github/workflows/cargo_fmt.yml +++ b/.github/workflows/cargo_fmt.yml @@ -43,6 +43,12 @@ jobs: with: command: fmt args: --manifest-path libraries/cbor/Cargo.toml --all -- --check + + - name: Cargo format libraries/cbor/fuzz + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --manifest-path libraries/cbor/fuzz/Cargo.toml --all -- --check - name: Cargo format libraries/crypto uses: actions-rs/cargo@v1 diff --git a/libraries/cbor/fuzz/Cargo.toml b/libraries/cbor/fuzz/Cargo.toml index 439e4c0..e1374e6 100644 --- a/libraries/cbor/fuzz/Cargo.toml +++ b/libraries/cbor/fuzz/Cargo.toml @@ -20,7 +20,7 @@ path = ".." members = ["."] [[bin]] -name = "fuzz_target_1" -path = "fuzz_targets/fuzz_target_1.rs" +name = "fuzz_target_cbor" +path = "fuzz_targets/fuzz_target_cbor.rs" test = false doc = false diff --git a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs deleted file mode 100644 index c83e339..0000000 --- a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#[macro_use] -extern crate libfuzzer_sys; -extern crate cbor; -extern crate alloc; - -use alloc::vec::Vec; - -fuzz_target!(|data: &[u8]| { - let encoded = cbor::read(data); - match encoded{ - Ok(value) => { - let mut decoded = Vec::new(); - let _ = cbor::write(value, &mut decoded); - assert_eq!(decoded, data); - } - Err(_) => {} - }; -}); - diff --git a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs new file mode 100644 index 0000000..8474d51 --- /dev/null +++ b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs @@ -0,0 +1,18 @@ +#![no_main] +#[macro_use] +extern crate libfuzzer_sys; +extern crate alloc; +extern crate cbor; + +use alloc::vec::Vec; + +fuzz_target!(|data: &[u8]| { + let encoded = cbor::read(data); + if let Ok(value) = encoded { + let mut decoded = Vec::new(); + let result = cbor::write(value, &mut decoded); + assert!(result); + assert_eq!(decoded, data); + }; +}); +