Skip to content
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

Squash dict add test tags #145

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
28c78f9
Add dict_manager
Juan-M-V Nov 4, 2022
e05eeb8
Create new structs
Juan-M-V Nov 10, 2022
389f73e
Merge memory segments
Juan-M-V Nov 10, 2022
6094622
Merge branch 'main' of github.com:lambdaclass/cairo-rs-py into dict-m…
Juan-M-V Nov 10, 2022
dc8d66d
Expose vm
Juan-M-V Nov 10, 2022
abfc657
Add Dict tracker and Dict
Juan-M-V Nov 14, 2022
75fbc8f
Modify structs
Juan-M-V Nov 14, 2022
0f781b4
Solve merge conflicts
Juan-M-V Nov 14, 2022
4ba36d0
Fix dereferencing ids
Juan-M-V Nov 14, 2022
8250fe8
Uncomment tests
Juan-M-V Nov 14, 2022
b568348
Fix tests
Juan-M-V Nov 14, 2022
7d31599
Clean up and modify refereces
Juan-M-V Nov 15, 2022
75c6e43
Remove todo
Juan-M-V Nov 15, 2022
c9d393f
Merge branch 'main' of github.com:lambdaclass/cairo-rs-py into dict-m…
Juan-M-V Nov 15, 2022
0d22b0b
Improve asterix stripping
Juan-M-V Nov 15, 2022
94065d3
Make fields private
Juan-M-V Nov 15, 2022
5c1dfac
Ignore clippy warnings
Juan-M-V Nov 15, 2022
f79bc1e
Fix clippy warnings
Juan-M-V Nov 16, 2022
92fd3b2
Add test tags
Juan-M-V Nov 16, 2022
0c6e440
Update hints_tests.py
Juan-M-V Nov 16, 2022
e72e2f4
Merge branch 'dict-manager' of github.com:lambdaclass/cairo-rs-py int…
Juan-M-V Nov 16, 2022
e161553
Remove test comment
Juan-M-V Nov 16, 2022
e034b03
Merge with main and fix errors
Juan-M-V Nov 17, 2022
525c200
Uncomment test
Juan-M-V Nov 17, 2022
255bc69
Merge branch 'main' of github.com:lambdaclass/cairo-rs-py into dict-m…
Juan-M-V Nov 18, 2022
a649c7a
Merge branch 'dict-manager' of github.com:lambdaclass/cairo-rs-py int…
Juan-M-V Nov 18, 2022
85619ee
Update ids.rs
Juan-M-V Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cairo_programs/squash_dict.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func squash_dict{range_check_ptr}(
squashed_dict=squashed_dict,
big_keys=big_keys)
%{
#TEST
vm_exit_scope()
%}
return (squashed_dict=squashed_dict)
Expand Down Expand Up @@ -173,7 +174,10 @@ func squash_dict_inner(
[ap] = dict_accesses_end_minus1 - cast(last_loop_locals.access_ptr, felt)
[ap] = [last_loop_locals.range_check_ptr]; ap++
tempvar n_used_accesses = last_loop_locals.range_check_ptr - range_check_ptr
%{ assert ids.n_used_accesses == len(access_indices[key]) %}
%{
#TEST
assert ids.n_used_accesses == len(access_indices[key])
%}

# Write last value to dict_diff.
last_loop_locals.value = dict_diff.new_value
Expand Down
8 changes: 4 additions & 4 deletions hints_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def test_program(program_name: str):
test_program("memcpy")
test_program("memset")
test_program("dict_new")
# test_program("dict_read") # Waiting on starkware PR
# test_program("dict_write") # ValueError: Custom Hint Error: AttributeError: 'PyTypeId' object has no attribute 'segment_index'
# test_program("dict_update") # Waiting on starkware PR
test_program("dict_read")
test_program("dict_write")
test_program("dict_update")
test_program("default_dict_new")
# test_program("squash_dict") # ValueError: Custom Hint Error: ValueError: Failed to get ids value
test_program("squash_dict")
# test_program("dict_squash") # Custom Hint Error: AttributeError: 'PyTypeId' object has no attribute 'segment_index'
test_program("ids_size")
test_program("split_felt")
Expand Down
25 changes: 16 additions & 9 deletions src/cairo_run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(test)]
mod test {
use crate::cairo_runner::PyCairoRunner;
use pyo3::Python;
use std::fs;

#[test]
Expand All @@ -9,9 +10,11 @@ mod test {
let program = fs::read_to_string(path).unwrap();
let mut runner =
PyCairoRunner::new(program, Some("main".to_string()), None, false).unwrap();
runner
.cairo_run_py(false, None, None, None, None, None)
.expect("Couldn't run program");
Python::with_gil(|py| {
runner
.cairo_run_py(false, None, None, None, py, None, None)
.expect("Couldn't run program");
});
}

#[test]
Expand All @@ -25,9 +28,11 @@ mod test {
false,
)
.unwrap();
runner
.cairo_run_py(false, None, None, None, None, None)
.expect("Couldn't run program");
Python::with_gil(|py| {
runner
.cairo_run_py(false, None, None, None, py, None, None)
.expect("Couldn't run program");
});
}

#[test]
Expand All @@ -36,8 +41,10 @@ mod test {
let program = fs::read_to_string(path).unwrap();
let mut runner =
PyCairoRunner::new(program, Some("main".to_string()), None, false).unwrap();
runner
.cairo_run_py(false, None, None, None, None, None)
.expect("Couldn't run program");
Python::with_gil(|py| {
runner
.cairo_run_py(false, None, None, None, py, None, None)
.expect("Couldn't run program");
});
}
}
Loading