Skip to content

Commit 8f3afe6

Browse files
committed
Make libraries optional in YAML
1 parent e9bb276 commit 8f3afe6

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
@@ -728,7 +728,7 @@ struct TestLibrary {
728728
#[derive(Debug, PartialEq, Serialize, Deserialize)]
729729
struct TestBeaconState {
730730
execution_scripts: Vec<String>,
731-
libraries: Vec<TestLibrary>,
731+
libraries: Option<Vec<TestLibrary>>,
732732
}
733733

734734
#[derive(Debug, PartialEq, Serialize, Deserialize)]
@@ -816,16 +816,19 @@ impl TryFrom<TestBeaconState> for BeaconState {
816816
})
817817
})
818818
.collect();
819-
let libraries: Result<Vec<Library>, ScoutError> = input
820-
.libraries
821-
.iter()
822-
.map(|library| {
823-
Ok(Library {
824-
name: library.name.to_string(),
825-
code: std::fs::read(&library.file)?,
819+
let libraries: Result<Vec<Library>, ScoutError> = if let Some(libraries) = input.libraries {
820+
libraries
821+
.iter()
822+
.map(|library| {
823+
Ok(Library {
824+
name: library.name.to_string(),
825+
code: std::fs::read(&library.file)?,
826+
})
826827
})
827-
})
828-
.collect();
828+
.collect()
829+
} else {
830+
Ok(Vec::new())
831+
};
829832
Ok(BeaconState {
830833
execution_scripts: scripts?,
831834
libraries: libraries?,

0 commit comments

Comments
 (0)