Skip to content

Commit

Permalink
Parse libraries in YAML format
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 25, 2020
1 parent d9518a4 commit e9bb276
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,16 @@ pub fn process_shard_block(
Ok(deposit_receipts)
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct TestLibrary {
name: String,
file: String,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct TestBeaconState {
execution_scripts: Vec<String>,
libraries: Vec<TestLibrary>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -809,10 +816,19 @@ impl TryFrom<TestBeaconState> for BeaconState {
})
})
.collect();
let libraries: Result<Vec<Library>, ScoutError> = input
.libraries
.iter()
.map(|library| {
Ok(Library {
name: library.name.to_string(),
code: std::fs::read(&library.file)?,
})
})
.collect();
Ok(BeaconState {
execution_scripts: scripts?,
// FIXME: add parser here
libraries: Vec::new(),
libraries: libraries?,
})
}
}
Expand Down

0 comments on commit e9bb276

Please sign in to comment.