-
Notifications
You must be signed in to change notification settings - Fork 28
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
chore(blockifier): create unit tests for contract_class_manager #2768
base: avivg/blockifier/add_casm_func_in_test_utils
Are you sure you want to change the base?
chore(blockifier): create unit tests for contract_class_manager #2768
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9098814
to
b9b2fa2
Compare
003b9ad
to
d6c6713
Compare
0adfb8c
to
e39a328
Compare
e39a328
to
19dab86
Compare
f4dc017
to
d8e38ab
Compare
19dab86
to
87a8788
Compare
aa7f26a
to
5733e03
Compare
87a8788
to
b7e2924
Compare
a34a9e5
to
445cd55
Compare
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.
Reviewed 7 of 7 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @avi-starkware and @avivg-starkware)
crates/blockifier/src/test_utils/contracts.rs
line 183 at r3 (raw file):
} pub fn get_casm(&self) -> CompiledClassV1 {
Consider sharing code withget_class
.
Code quote:
pub fn get_casm(&self) -> CompiledClassV1 {
crates/blockifier/src/state/contract_class_manager_test.rs
line 19 at r3 (raw file):
let mut contract_class = test_contract.get_contract_class(); // Truncate the sierra program to trigger an error. contract_class.sierra_program = contract_class.sierra_program[..100].to_vec();
Nice :)
Is there a way to cause a compilation error by "damaging" the SierraContractClass
object?
Code quote:
// Truncate the sierra program to trigger an error.
contract_class.sierra_program = contract_class.sierra_program[..100].to_vec();
crates/blockifier/src/state/contract_class_manager_test.rs
line 77 at r3 (raw file):
"Sender should be able to send a request successfully" ); }
Consider unifying these tests with test_cases
.
You can also check: no compiler when cairo-native is off.
Code quote:
#[test]
fn test_sender_with_native_compilation_disabled() {
let config = ContractClassManagerConfig { run_cairo_native: false, ..Default::default() };
let manager = ContractClassManager::start(config);
assert!(manager.sender.is_none(), "Sender should be None when native compilation is disabled");
}
#[test]
fn test_sender_with_native_compilation_enabled() {
let config = ContractClassManagerConfig { run_cairo_native: true, ..Default::default() };
let manager = ContractClassManager::start(config);
assert!(manager.sender.is_some());
assert!(
manager.sender.as_ref().unwrap().try_send(create_test_request()).is_ok(),
"Sender should be able to send a request successfully"
);
}
crates/blockifier/src/state/contract_class_manager_test.rs
line 80 at r3 (raw file):
#[test] fn test_send_request_channel_disconnected() {
Can you please explain this test?
Code quote:
fn test_send_request_channel_disconnected()
crates/blockifier/src/state/contract_class_manager_test.rs
line 108 at r3 (raw file):
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { manager.send_compilation_request(second_request); }));
Why is the catch_unwind
needed?
Code quote:
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
manager.send_compilation_request(second_request);
}));
crates/blockifier/src/state/contract_class_manager_test.rs
line 114 at r3 (raw file):
#[test] fn test_run_compilation_worker_success() {
?
Suggestion:
fn test_process_compilation_request_success() {
crates/blockifier/src/state/contract_class_manager.rs
line 33 at r3 (raw file):
pub const DEFAULT_COMPILATION_REQUEST_CHANNEL_SIZE: usize = 1000; #[cfg(all(test, feature = "cairo_native"))]
We will want to test it even when the cairo-native
flag is off.
Code quote:
#[cfg(all(test, feature = "cairo_native"))]
445cd55
to
9547c32
Compare
cb70f0d
to
0935c4f
Compare
Previously, noaov1 (Noa Oved) wrote…
Done |
Previously, noaov1 (Noa Oved) wrote…
Done. |
Previously, noaov1 (Noa Oved) wrote…
my intention was to check that panic occurs when trying to send massage with disconnected channel, how does it look now? |
Previously, noaov1 (Noa Oved) wrote…
WDYT? not sure if this test is needed and if so, what best way to handle a check that panic doesn't occur |
Previously, noaov1 (Noa Oved) wrote…
I've changed it to test send_compilation_request and added a separate test for process_compilation_request. |
03f2692
to
ea8f100
Compare
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.
Reviewed 2 of 7 files at r2, 1 of 1 files at r3, 1 of 2 files at r5, all commit messages.
Reviewable status: 6 of 7 files reviewed, 8 unresolved discussions (waiting on @avi-starkware, @avivg-starkware, and @noaov1)
crates/blockifier/src/state/global_cache.rs
line 33 at r3 (raw file):
#[cfg(feature = "cairo_native")] #[derive(Debug, Clone, PartialEq)]
Can you derive the PartialEq only for the test config?
Code quote:
#[derive(Debug, Clone, PartialEq)]
93d79f0
to
f0143b5
Compare
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.
Reviewable status: 5 of 7 files reviewed, 7 unresolved discussions (waiting on @avi-starkware, @meship-starkware, and @noaov1)
crates/blockifier/src/state/global_cache.rs
line 33 at r3 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Can you derive the PartialEq only for the test config?
Done
83d1a76
to
f2f15ab
Compare
f2f15ab
to
56c5ea5
Compare
Previously, noaov1 (Noa Oved) wrote…
handled code sharing in #3138 |
No description provided.