Skip to content

Commit

Permalink
Return pyrelocatable from add_additional_hash_builtin (#149)
Browse files Browse the repository at this point in the history
* return a pyrelocatable

* update test

* check that it returns a pyrelocatable

* Update src/cairo_runner.rs

Co-authored-by: fmoletta <[email protected]>

* change Cargo.toml

* fix test

Co-authored-by: Juan Rigada <[email protected]>
Co-authored-by: fmoletta <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2022
1 parent 29704a5 commit 207bbbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default = ["pyo3/num-bigint", "pyo3/auto-initialize"]

[dependencies]
pyo3 = { version = "0.16.5" }
cairo-rs = { git = "https://github.com/lambdaclass/cairo-rs.git", rev = "c7c3e4fca78d38da968e92c6586ec3a518697745" }
cairo-rs = { git = "https://github.com/lambdaclass/cairo-rs.git", rev = "2ddf78e20cc25e660263a0c9c1b942780d95a0e6" }
num-bigint = "0.4"
lazy_static = "1.4.0"

Expand Down
13 changes: 10 additions & 3 deletions src/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,10 @@ impl PyCairoRunner {
}

/// Add (or replace if already present) a custom hash builtin.
pub fn add_additional_hash_builtin(&self) {
/// Returns a Relocatable with the new hash builtin base.
pub fn add_additional_hash_builtin(&self) -> PyRelocatable {
let mut vm = (*self.pyvm.vm).borrow_mut();
self.inner.add_additional_hash_builtin(&mut vm);
self.inner.add_additional_hash_builtin(&mut vm).into()
}
}

Expand Down Expand Up @@ -1515,7 +1516,13 @@ mod test {
)
.unwrap();

runner.add_additional_hash_builtin();
let expected_relocatable = PyRelocatable {
segment_index: 0,
offset: 0,
};
let relocatable = runner.add_additional_hash_builtin();
assert_eq!(expected_relocatable, relocatable);

assert_eq!(
(*runner.pyvm.vm)
.borrow()
Expand Down

0 comments on commit 207bbbf

Please sign in to comment.