Skip to content

Commit 9c2eff6

Browse files
starknet_os: os resources test - l1 handler tx calldata factor
1 parent 10ec03a commit 9c2eff6

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

crates/starknet_os_flow_tests/src/os_resources_test.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ async fn test_execute_txs_inner_resources() {
487487
let version = StarknetVersion::LATEST;
488488
let mut raw_vc: RawVersionedConstants =
489489
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
490-
const N_TXS: usize = 6;
490+
const N_TXS: usize = 7;
491491

492492
let OsResourcesTestSetup {
493493
stable_contract_address,
@@ -584,6 +584,13 @@ async fn test_execute_txs_inner_resources() {
584584
calldata![Felt::from(100), Felt::ZERO],
585585
None,
586586
);
587+
test_builder.add_l1_handler(
588+
stable_contract_address,
589+
"l1_handler",
590+
// From address, extra args.
591+
calldata![Felt::from(100), Felt::ONE, Felt::ZERO],
592+
None,
593+
);
587594

588595
// Execute the business logic and extract the business logic resources for each tx.
589596
let test_runner = test_builder.build().await;
@@ -623,7 +630,8 @@ async fn test_execute_txs_inner_resources() {
623630
declare_overhead,
624631
deploy_account_base,
625632
deploy_account_extra,
626-
l1_handler_overhead,
633+
l1_handler_base,
634+
l1_handler_extra,
627635
]: [ExecutionResources; N_TXS] = test_output
628636
.runner_output
629637
.txs_trace
@@ -719,7 +727,6 @@ async fn test_execute_txs_inner_resources() {
719727
);
720728

721729
// L1 handler: variable cost, unscaled.
722-
// TODO(Dori): Compute linear factor cost.
723730
let VariableResourceParams::WithFactor(mut l1_handler_resources_params) =
724731
raw_vc.os_resources.execute_txs_inner.get(&TransactionType::L1Handler).unwrap().clone()
725732
else {
@@ -734,7 +741,10 @@ async fn test_execute_txs_inner_resources() {
734741
"L1 handler scaling factor has unexpected structure: {:?}",
735742
l1_handler_resources_params.calldata_factor
736743
);
737-
l1_handler_resources_params.constant = l1_handler_overhead;
744+
l1_handler_resources_params.calldata_factor = VariableCallDataFactor::Unscaled(
745+
(&l1_handler_extra - &l1_handler_base).filter_unused_builtins(),
746+
);
747+
l1_handler_resources_params.constant = l1_handler_base;
738748
raw_vc.os_resources.execute_txs_inner.insert(
739749
TransactionType::L1Handler,
740750
VariableResourceParams::WithFactor(l1_handler_resources_params),

0 commit comments

Comments
 (0)