-
Notifications
You must be signed in to change notification settings - Fork 22
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
test(blockifier): add from file trait #1720
Conversation
Artifacts upload triggered. View details here |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1720 +/- ##
===========================================
+ Coverage 40.10% 68.99% +28.89%
===========================================
Files 26 100 +74
Lines 1895 13461 +11566
Branches 1895 13461 +11566
===========================================
+ Hits 760 9288 +8528
- Misses 1100 3771 +2671
- Partials 35 402 +367 ☔ View full report in Codecov by Sentry. |
34599b9
to
95fba20
Compare
Artifacts upload triggered. View details here |
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: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware and @noaov1)
crates/blockifier/src/test_utils/struct_impls.rs
line 216 at r1 (raw file):
pub trait LoadFile { fn from_file(contract_path: &str) -> Self;
I see that many paths are saved as &str
with this infra, including get_raw_contract_class
but not as PathBuf
(or something).
I see not many functions are using this infra. We can still fix that before the type keeps spreading!
(probably an issue for another PR).
Code quote:
fn from_file(contract_path: &str) -> Self;
crates/blockifier/src/test_utils/struct_impls.rs
line 217 at r1 (raw file):
pub trait LoadFile { fn from_file(contract_path: &str) -> Self; }
Either document or rename. With this name for the trait and the function, this trait can be used more generally than for contract classes.
Third option: this seems very useful - can this be shared more generally?
Maybe all of these comments should be non-blocking.
Code quote:
pub trait LoadFile {
fn from_file(contract_path: &str) -> Self;
}
crates/blockifier/src/test_utils/struct_impls.rs
line 231 at r1 (raw file):
serde_json::from_str(&raw_contract_class).unwrap() } }
Code dedup.
Suggestion:
pub trait LoadFile: serde::de::DeserializeOwned {
fn from_file(contract_path: &str) -> Self {
let raw_contract_class = get_raw_contract_class(contract_path);
serde_json::from_str(&raw_contract_class).unwrap()
}
}
impl LoadFile for DeprecatedContractClass {}
impl LoadFile for CasmContractClass {}
95fba20
to
48b0df8
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: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @ArniStarkware and @dorimedini-starkware)
crates/blockifier/src/test_utils/struct_impls.rs
line 216 at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
I see that many paths are saved as
&str
with this infra, includingget_raw_contract_class
but not asPathBuf
(or something).
I see not many functions are using this infra. We can still fix that before the type keeps spreading!(probably an issue for another PR).
Another PR. I added a TODO.
crates/blockifier/src/test_utils/struct_impls.rs
line 217 at r1 (raw file):
With this name for the trait and the function, this trait can be used more generally than for contract classes.
Is this bad?
With the default implantation of the trait it must be contract specific. I changed the name of the trait.
crates/blockifier/src/test_utils/struct_impls.rs
line 231 at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
Code dedup.
Like. Done.
Artifacts upload triggered. View details here |
delete? Code quote: impl ContractClassV1 {
pub fn from_file(contract_path: &str) -> Self {
let raw_contract_class = get_raw_contract_class(contract_path);
Self::try_from_json_string(&raw_contract_class).unwrap()
}
} |
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 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @noaov1)
48b0df8
to
037e230
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: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dorimedini-starkware)
crates/blockifier/src/test_utils/struct_impls.rs
line 232 at r2 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
delete?
I deleted the CairoV0
one by accident. It is still used. Will be deleted in this PR.
Artifacts upload triggered. View details here |
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 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)
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 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
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: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
No description provided.