mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 01:03:40 +00:00
Use yaml_serde in place of deprecated serde_yaml (#9040)
`serde_yaml` is now deprecated. The API-compatible `yaml_serde` should be used instead. Replace `serde_yaml` with `yaml_serde`. This is purely mechanical as the API is 1-to-1. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -2531,7 +2531,7 @@ impl Config {
|
||||
pub fn from_file(filename: &Path) -> Result<Self, String> {
|
||||
let f = File::open(filename)
|
||||
.map_err(|e| format!("Error opening spec at {}: {:?}", filename.display(), e))?;
|
||||
serde_yaml::from_reader(f)
|
||||
yaml_serde::from_reader(f)
|
||||
.map_err(|e| format!("Error parsing spec at {}: {:?}", filename.display(), e))
|
||||
}
|
||||
|
||||
@@ -2869,7 +2869,7 @@ mod yaml_tests {
|
||||
|
||||
let yamlconfig = Config::from_chain_spec::<MinimalEthSpec>(&minimal_spec);
|
||||
// write fresh minimal config to file
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
@@ -2877,7 +2877,7 @@ mod yaml_tests {
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
// deserialize minimal config from file
|
||||
let from: Config = serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
let from: Config = yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(from, yamlconfig);
|
||||
}
|
||||
|
||||
@@ -2891,14 +2891,14 @@ mod yaml_tests {
|
||||
.expect("error opening file");
|
||||
let mainnet_spec = ChainSpec::mainnet();
|
||||
let yamlconfig = Config::from_chain_spec::<MainnetEthSpec>(&mainnet_spec);
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
let from: Config = serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
let from: Config = yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(from, yamlconfig);
|
||||
}
|
||||
|
||||
@@ -2960,7 +2960,7 @@ mod yaml_tests {
|
||||
MAX_BLOBS_PER_BLOCK: 20
|
||||
"#;
|
||||
let config: Config =
|
||||
serde_yaml::from_str(spec_contents).expect("error while deserializing");
|
||||
yaml_serde::from_str(spec_contents).expect("error while deserializing");
|
||||
let spec =
|
||||
ChainSpec::from_config::<MainnetEthSpec>(&config).expect("error while creating spec");
|
||||
|
||||
@@ -3042,11 +3042,11 @@ mod yaml_tests {
|
||||
assert_eq!(spec.max_blobs_per_block_within_fork(ForkName::Fulu), 20);
|
||||
|
||||
// Check that serialization is in ascending order
|
||||
let yaml = serde_yaml::to_string(&spec.blob_schedule).expect("should serialize");
|
||||
let yaml = yaml_serde::to_string(&spec.blob_schedule).expect("should serialize");
|
||||
|
||||
// Deserialize back to Vec<BlobParameters> to check order
|
||||
let deserialized: Vec<BlobParameters> =
|
||||
serde_yaml::from_str(&yaml).expect("should deserialize");
|
||||
yaml_serde::from_str(&yaml).expect("should deserialize");
|
||||
|
||||
// Should be in ascending order by epoch
|
||||
assert!(
|
||||
@@ -3113,7 +3113,7 @@ mod yaml_tests {
|
||||
MAX_BLOBS_PER_BLOCK: 300
|
||||
"#;
|
||||
let config: Config =
|
||||
serde_yaml::from_str(spec_contents).expect("error while deserializing");
|
||||
yaml_serde::from_str(spec_contents).expect("error while deserializing");
|
||||
let spec =
|
||||
ChainSpec::from_config::<MainnetEthSpec>(&config).expect("error while creating spec");
|
||||
|
||||
@@ -3203,7 +3203,7 @@ mod yaml_tests {
|
||||
SAMPLES_PER_SLOT: 8
|
||||
"#;
|
||||
|
||||
let chain_spec: Config = serde_yaml::from_str(spec).unwrap();
|
||||
let chain_spec: Config = yaml_serde::from_str(spec).unwrap();
|
||||
|
||||
// Asserts that `chain_spec.$name` and `default_$name()` are equal.
|
||||
macro_rules! check_default {
|
||||
|
||||
@@ -174,7 +174,7 @@ mod test {
|
||||
yamlconfig.extra_fields_mut().insert(k3.into(), v3.into());
|
||||
yamlconfig.extra_fields_mut().insert(k4.into(), v4);
|
||||
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
@@ -182,7 +182,7 @@ mod test {
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
let from: ConfigAndPresetGloas =
|
||||
serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(ConfigAndPreset::Gloas(from), yamlconfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ mod test {
|
||||
fn preset_from_file<T: DeserializeOwned>(preset_name: &str, filename: &str) -> T {
|
||||
let f = File::open(presets_base_path().join(preset_name).join(filename))
|
||||
.expect("preset file exists");
|
||||
serde_yaml::from_reader(f).unwrap()
|
||||
yaml_serde::from_reader(f).unwrap()
|
||||
}
|
||||
|
||||
fn preset_test<E: EthSpec>() {
|
||||
|
||||
Reference in New Issue
Block a user