-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement extend_additional_data
for BuiltinRunner
#1726
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0fd1c39
Implement extend_additional_data for hash
fmoletta c1a221d
Handle check
fmoletta 4b36813
Simplify
fmoletta 23821e9
Simplify
fmoletta f4b40de
Implement extend_additional_data for ecdsa
fmoletta 11c7ed4
Add test
fmoletta 301557d
Implement extend_additional_data for output
fmoletta 1214c9f
Implement extend_additional_data for enum
fmoletta 45392b1
Add changelog entry
fmoletta e993661
Merge branch 'main' into extend-additional-data
fmoletta 34a1a96
Add doc comments to get_additional_data & extend_additional_data
fmoletta 8e7936b
Merge branch 'extend-additional-data' of https://github.com/lambdacla…
fmoletta bf13e53
Merge branch 'main' into extend-additional-data
fmoletta 46afb38
Merge branch 'main' into extend-additional-data
fmoletta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,19 @@ | |
}) | ||
} | ||
|
||
pub fn extend_additional_data( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have some docs about what is the intent of this function |
||
&mut self, | ||
additional_data: &BuiltinAdditionalData, | ||
) -> Result<(), RunnerError> { | ||
let additional_data = match additional_data { | ||
BuiltinAdditionalData::Output(d) => d, | ||
_ => return Err(RunnerError::InvalidAdditionalData(BuiltinName::output)), | ||
}; | ||
self.pages.extend(additional_data.pages.clone()); | ||
self.attributes.extend(additional_data.attributes.clone()); | ||
Ok(()) | ||
} | ||
|
||
pub(crate) fn set_stop_ptr_offset(&mut self, offset: usize) { | ||
self.stop_ptr = Some(offset) | ||
} | ||
|
@@ -456,7 +469,7 @@ | |
} | ||
|
||
#[test] | ||
fn get_additional_info_no_pages_no_attributes() { | ||
fn get_additional_data_no_pages_no_attributes() { | ||
let builtin = OutputBuiltinRunner::new(true); | ||
assert_eq!( | ||
builtin.get_additional_data(), | ||
|
@@ -599,4 +612,26 @@ | |
vec![(0, 0), (1, 0), (2, 1), (3, 1), (4, 2), (5, 2), (6, 2)] | ||
); | ||
} | ||
|
||
#[test] | ||
fn get_and_extend_additional_data() { | ||
let builtin_a = OutputBuiltinRunner { | ||
base: 0, | ||
pages: HashMap::from([(1, PublicMemoryPage { start: 0, size: 3 })]), | ||
attributes: HashMap::from([("gps_fact_topology".to_string(), vec![0, 2, 0])]), | ||
stop_ptr: None, | ||
included: true, | ||
}; | ||
let additional_data = builtin_a.get_additional_data(); | ||
let mut builtin_b = OutputBuiltinRunner { | ||
base: 0, | ||
pages: Default::default(), | ||
attributes: Default::default(), | ||
stop_ptr: None, | ||
included: true, | ||
}; | ||
builtin_b.extend_additional_data(&additional_data).unwrap(); | ||
assert_eq!(builtin_a.attributes, builtin_b.attributes); | ||
assert_eq!(builtin_a.pages, builtin_b.pages); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wen docs