Resolve pull request comments: refactoring and workflow

This commit is contained in:
mingxguo27
2020-08-12 10:18:17 +00:00
parent 1e9da1e2d6
commit b09d64a015
4 changed files with 26 additions and 22 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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(_) => {}
};
});

View File

@@ -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);
};
});