Replace OpenOptions::new with File::options to be readable (#3059)

## Issue Addressed

Closes #3049 

This PR updates widely but this replace is safe as `File::options()` is equivelent to `OpenOptions::new()`.
ref: https://doc.rust-lang.org/stable/src/std/fs.rs.html#378-380
This commit is contained in:
Akihito Nakano
2022-03-07 06:30:18 +00:00
parent cbda0a2f0a
commit 4186d117af
16 changed files with 40 additions and 41 deletions

View File

@@ -1163,14 +1163,13 @@ mod tests {
#[cfg(test)]
mod yaml_tests {
use super::*;
use std::fs::OpenOptions;
use tempfile::NamedTempFile;
#[test]
fn minimal_round_trip() {
// create temp file
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
let writer = OpenOptions::new()
let writer = File::options()
.read(false)
.write(true)
.open(tmp_file.as_ref())
@@ -1181,7 +1180,7 @@ mod yaml_tests {
// write fresh minimal config to file
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
let reader = OpenOptions::new()
let reader = File::options()
.read(true)
.write(false)
.open(tmp_file.as_ref())
@@ -1194,7 +1193,7 @@ mod yaml_tests {
#[test]
fn mainnet_round_trip() {
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
let writer = OpenOptions::new()
let writer = File::options()
.read(false)
.write(true)
.open(tmp_file.as_ref())
@@ -1203,7 +1202,7 @@ mod yaml_tests {
let yamlconfig = Config::from_chain_spec::<MainnetEthSpec>(&mainnet_spec);
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
let reader = OpenOptions::new()
let reader = File::options()
.read(true)
.write(false)
.open(tmp_file.as_ref())

View File

@@ -92,13 +92,13 @@ impl ConfigAndPreset {
mod test {
use super::*;
use crate::MainnetEthSpec;
use std::fs::OpenOptions;
use std::fs::File;
use tempfile::NamedTempFile;
#[test]
fn extra_fields_round_trip() {
let tmp_file = NamedTempFile::new().expect("failed to create temp file");
let writer = OpenOptions::new()
let writer = File::options()
.read(false)
.write(true)
.open(tmp_file.as_ref())
@@ -116,7 +116,7 @@ mod test {
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
let reader = OpenOptions::new()
let reader = File::options()
.read(true)
.write(false)
.open(tmp_file.as_ref())