Skip to content

Commit eb66da4

Browse files
chore(blockifier): add is_legacy method (#196)
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/sequencer/196) <!-- Reviewable:end -->
1 parent 10b4be1 commit eb66da4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/blockifier/src/test_utils/contracts.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ impl FeatureContract {
180180
}
181181
}
182182

183+
pub fn is_legacy(&self) -> bool {
184+
matches!(self, Self::LegacyTestContract)
185+
}
186+
183187
/// Unique integer representing each unique contract. Used to derive "class hash" and "address".
184188
fn get_integer_base(self) -> u32 {
185189
self.get_cairo_version_bit()
@@ -275,15 +279,16 @@ impl FeatureContract {
275279
cairo0_compile(self.get_source_path(), extra_arg, false)
276280
}
277281
CairoVersion::Cairo1 => {
278-
let (tag_override, cargo_nightly_arg) = match self {
279-
Self::LegacyTestContract => (
282+
let (tag_override, cargo_nightly_arg) = if self.is_legacy() {
283+
(
280284
// Legacy contract is designed to test behavior of code compiled with a
281285
// specific (old) compiler tag. To run the (old) compiler, older rust
282286
// version is required.
283287
Some(LEGACY_CONTRACT_COMPILER_TAG.into()),
284288
Some(LEGACY_CONTRACT_RUST_TOOLCHAIN.into()),
285-
),
286-
_ => (None, None),
289+
)
290+
} else {
291+
(None, None)
287292
};
288293
cairo1_compile(self.get_source_path(), tag_override, cargo_nightly_arg)
289294
}

0 commit comments

Comments
 (0)