Skip to content

Commit 207bbbf

Browse files
juanbonoJrigadafmoletta
authored
Return pyrelocatable from add_additional_hash_builtin (#149)
* 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]>
1 parent 29704a5 commit 207bbbf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default = ["pyo3/num-bigint", "pyo3/auto-initialize"]
1313

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

src/cairo_runner.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,10 @@ impl PyCairoRunner {
536536
}
537537

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

@@ -1515,7 +1516,13 @@ mod test {
15151516
)
15161517
.unwrap();
15171518

1518-
runner.add_additional_hash_builtin();
1519+
let expected_relocatable = PyRelocatable {
1520+
segment_index: 0,
1521+
offset: 0,
1522+
};
1523+
let relocatable = runner.add_additional_hash_builtin();
1524+
assert_eq!(expected_relocatable, relocatable);
1525+
15191526
assert_eq!(
15201527
(*runner.pyvm.vm)
15211528
.borrow()

0 commit comments

Comments
 (0)