Yaml rust2 (#5635)

* use yaml-rust2
This commit is contained in:
realbigsean
2024-04-24 02:02:10 -04:00
committed by GitHub
parent 61962898e2
commit c4a2bcb9c7
3 changed files with 43 additions and 393 deletions

View File

@@ -8,5 +8,5 @@ edition = { workspace = true }
bytes = { workspace = true }
[dev-dependencies]
yaml-rust2 = "0.8"
hex = { workspace = true }
serde_yml = "0.0.4"

View File

@@ -78,7 +78,8 @@ pub fn int_to_bytes96(int: u64) -> Vec<u8> {
#[cfg(test)]
mod tests {
use super::*;
use std::{collections::HashMap, fs::File, io::prelude::*, path::PathBuf};
use std::{fs::File, io::prelude::*, path::PathBuf};
use yaml_rust2::yaml;
#[test]
fn fixed_bytes32() {
@@ -110,13 +111,14 @@ mod tests {
file.read_to_string(&mut yaml_str).unwrap();
let docs: HashMap<String, serde_yml::Value> = serde_yml::from_str(&yaml_str).unwrap();
let test_cases = docs["test_cases"].as_sequence().unwrap();
let docs = yaml::YamlLoader::load_from_str(&yaml_str).unwrap();
let doc = &docs[0];
let test_cases = doc["test_cases"].as_vec().unwrap();
for test_case in test_cases {
let byte_length = test_case["byte_length"].as_i64().unwrap() as u64;
let int = test_case["int"].as_i64().unwrap() as u64;
let bytes_string = test_case["bytes"].as_str().unwrap();
let bytes_string = test_case["bytes"].clone().into_string().unwrap();
let bytes = hex::decode(bytes_string.replace("0x", "")).unwrap();
match byte_length {