Skip to content

Commit 473691b

Browse files
committed
Make libraries optional in YAML
1 parent 8bde5fe commit 473691b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/main.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ struct TestLibrary {
730730
#[derive(Debug, PartialEq, Serialize, Deserialize)]
731731
struct TestBeaconState {
732732
execution_scripts: Vec<String>,
733-
libraries: Vec<TestLibrary>,
733+
libraries: Option<Vec<TestLibrary>>,
734734
}
735735

736736
#[derive(Debug, PartialEq, Serialize, Deserialize)]
@@ -818,16 +818,19 @@ impl TryFrom<TestBeaconState> for BeaconState {
818818
})
819819
})
820820
.collect();
821-
let libraries: Result<Vec<Library>, ScoutError> = input
822-
.libraries
823-
.iter()
824-
.map(|library| {
825-
Ok(Library {
826-
name: library.name.to_string(),
827-
code: std::fs::read(&library.file)?,
821+
let libraries: Result<Vec<Library>, ScoutError> = if let Some(libraries) = input.libraries {
822+
libraries
823+
.iter()
824+
.map(|library| {
825+
Ok(Library {
826+
name: library.name.to_string(),
827+
code: std::fs::read(&library.file)?,
828+
})
828829
})
829-
})
830-
.collect();
830+
.collect()
831+
} else {
832+
Ok(Vec::new())
833+
};
831834
Ok(BeaconState {
832835
execution_scripts: scripts?,
833836
libraries: libraries?,

0 commit comments

Comments
 (0)