Skip to content

Commit

Permalink
initial contract test framework (#314)
Browse files Browse the repository at this point in the history
* initial contract test framework2

* clippy

* fix
  • Loading branch information
edg-l authored Oct 10, 2023
1 parent c80ab87 commit b2a2574
Show file tree
Hide file tree
Showing 7 changed files with 490 additions and 51 deletions.
89 changes: 39 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ pub fn find_entry_point<'a>(
.find(|x| x.id.debug_name.as_deref() == Some(entry_point))
}

/// Given a string representing a function name, searches in the program for the id corresponding to said function, and returns a reference to it.
pub fn find_function<'a>(
program: &'a Program,
function_name: &str,
) -> &'a GenFunction<StatementIdx> {
program
.funcs
.iter()
.find(|x| x.id.debug_name.as_deref() == Some(function_name))
.unwrap()
}

/// Given a string representing a function name, searches in the program for the id corresponding to said function, and returns a reference to it.
pub fn find_function_id<'a>(program: &'a Program, function_name: &str) -> &'a FunctionId {
&program
Expand Down
Loading

0 comments on commit b2a2574

Please sign in to comment.