Skip to content

Commit ea85357

Browse files
starknet_os: use ERC20 artifact in compiled_class_hash tests (#13493)
Made-with: Cursor
1 parent 12fec5d commit ea85357

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

crates/starknet_os/src/hints/hint_implementation/compiled_class/compiled_class_test.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,31 @@ use crate::test_utils::utils::DEFAULT_PRIME;
5151
use crate::vm_utils::{get_address_of_nested_fields_from_base_address, LoadCairoObject};
5252

5353
// V1 (Poseidon) HASH CONSTS
54-
/// Expected Poseidon hash for the test contract.
54+
/// Expected Poseidon hash for the Cairo1 ERC20 feature contract (committed `erc20.casm.json`).
5555
const EXPECTED_V1_HASH: expect_test::Expect =
56-
expect!["999275515568006028307283908900764751466300037034630245880145212575608036868"];
56+
expect!["1086536622945160114536053561878005579687531094896980931390443771221568164185"];
5757
const EXPECTED_BUILTIN_USAGE_FULL_CONTRACT_V1_HASH: expect_test::Expect =
58-
expect!["poseidon_builtin: 16023"];
59-
const EXPECTED_N_STEPS_FULL_CONTRACT_V1_HASH: Expect = expect!["190705"];
58+
expect!["poseidon_builtin: 11928"];
59+
const EXPECTED_N_STEPS_FULL_CONTRACT_V1_HASH: Expect = expect!["136909"];
6060
// Expected execution resources for loading partial contract.
6161
const EXPECTED_BUILTIN_USAGE_PARTIAL_CONTRACT_V1_HASH: expect_test::Expect =
62-
expect!["poseidon_builtin: 469, range_check_builtin: 233"];
63-
const EXPECTED_N_STEPS_PARTIAL_CONTRACT_V1_HASH: Expect = expect!["14028"];
62+
expect!["poseidon_builtin: 221, range_check_builtin: 85"];
63+
const EXPECTED_N_STEPS_PARTIAL_CONTRACT_V1_HASH: Expect = expect!["6382"];
6464
// Allowed margin between estimated and actual execution resources.
6565
const ALLOWED_MARGIN_N_STEPS: usize = 127;
6666

6767
// V2 (Blake) HASH CONSTS
68-
/// Expected Blake hash for the test contract
68+
/// Expected Blake hash for the Cairo1 ERC20 feature contract.
6969
const EXPECTED_V2_HASH: expect_test::Expect =
70-
expect!["2283996186416818293582511354369937106720755819352182396112367539994319472752"];
70+
expect!["3325824766528769720608805422968547980476991657768956291033663350476760978279"];
7171
// Expected execution resources for loading full contract.
7272
const EXPECTED_BUILTIN_USAGE_FULL_CONTRACT_V2_HASH: expect_test::Expect =
73-
expect!["range_check_builtin: 32600"];
74-
const EXPECTED_N_STEPS_FULL_CONTRACT_V2_HASH: Expect = expect!["616905"];
73+
expect!["range_check_builtin: 24037"];
74+
const EXPECTED_N_STEPS_FULL_CONTRACT_V2_HASH: Expect = expect!["432095"];
7575
// Expected execution resources for loading partial contract.
7676
const EXPECTED_BUILTIN_USAGE_PARTIAL_CONTRACT_V2_HASH: expect_test::Expect =
77-
expect!["range_check_builtin: 1332"];
78-
const EXPECTED_N_STEPS_PARTIAL_CONTRACT_V2_HASH: Expect = expect!["56939"];
77+
expect!["range_check_builtin: 581"];
78+
const EXPECTED_N_STEPS_PARTIAL_CONTRACT_V2_HASH: Expect = expect!["25349"];
7979
// Allowed margin between estimated and actual execution resources.
8080
const ALLOWED_MARGIN_BLAKE_N_STEPS: usize = 267;
8181
const ALLOWED_MARGIN_BLAKE_OPCODE_COUNT: usize = 4;
@@ -98,7 +98,7 @@ trait HashVersionTestSpec {
9898
/// depending on whether the full contract is loaded or not.
9999
fn expected_n_steps_full_contract(&self) -> Expect;
100100
fn expected_n_steps_partial_contract(&self) -> Expect;
101-
/// The expected hash for the test contract.
101+
/// The expected hash for the Cairo1 ERC20 contract under test.
102102
fn expected_hash(&self) -> Expect;
103103
/// The allowed margin for the number of steps.
104104
fn allowed_margin_n_steps(&self) -> usize;
@@ -434,9 +434,8 @@ fn test_compiled_class_hash(
434434
accessed_segments_indicator: AccessSegmentsIndicator,
435435
#[values(HashVersion::V1, HashVersion::V2)] hash_version: HashVersion,
436436
) {
437-
// Get the test contract class.
438-
let feature_contract =
439-
FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm));
437+
// Use Cairo1 ERC20: committed artifact, stable vs the frequently edited test contract.
438+
let feature_contract = FeatureContract::ERC20(CairoVersion::Cairo1(RunnableCairo1::Casm));
440439
let contract_class = match feature_contract.get_class() {
441440
ContractClass::V1((casm, _sierra_version)) => casm,
442441
_ => panic!("Expected ContractClass::V1"),

0 commit comments

Comments
 (0)