Skip to content

Commit ebdeac0

Browse files
starknet_os: os resources test - l1 handler tx calldata factor
1 parent 4ff38f8 commit ebdeac0

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
@@ -475,7 +475,7 @@ async fn test_execute_txs_inner_resources() {
475475
let version = StarknetVersion::LATEST;
476476
let mut raw_vc: RawVersionedConstants =
477477
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
478-
const N_TXS: usize = 6;
478+
const N_TXS: usize = 7;
479479

480480
let (os_resources_contract_address, deployable_class_hash, mut test_builder) =
481481
setup_test_builder().await;
@@ -578,6 +578,13 @@ async fn test_execute_txs_inner_resources() {
578578
calldata![Felt::from(100), Felt::ZERO],
579579
None,
580580
);
581+
test_builder.add_l1_handler(
582+
os_resources_contract_address,
583+
"empty_l1_handler",
584+
// From address, extra args.
585+
calldata![Felt::from(100), Felt::ONE, Felt::ZERO],
586+
None,
587+
);
581588

582589
// Execute the business logic and extract the business logic resources for each tx.
583590
let test_runner = test_builder.build().await;
@@ -617,7 +624,8 @@ async fn test_execute_txs_inner_resources() {
617624
declare_overhead,
618625
deploy_account_base,
619626
deploy_account_extra,
620-
l1_handler_overhead,
627+
l1_handler_base,
628+
l1_handler_extra,
621629
]: [ExecutionResources; N_TXS] = test_output
622630
.runner_output
623631
.txs_trace
@@ -713,7 +721,6 @@ async fn test_execute_txs_inner_resources() {
713721
);
714722

715723
// L1 handler: variable cost, unscaled.
716-
// TODO(Dori): Compute linear factor cost.
717724
let VariableResourceParams::WithFactor(mut l1_handler_resources_params) =
718725
raw_vc.os_resources.execute_txs_inner.get(&TransactionType::L1Handler).unwrap().clone()
719726
else {
@@ -728,7 +735,10 @@ async fn test_execute_txs_inner_resources() {
728735
"L1 handler scaling factor has unexpected structure: {:?}",
729736
l1_handler_resources_params.calldata_factor
730737
);
731-
l1_handler_resources_params.constant = l1_handler_overhead;
738+
l1_handler_resources_params.calldata_factor = VariableCallDataFactor::Unscaled(
739+
(&l1_handler_extra - &l1_handler_base).filter_unused_builtins(),
740+
);
741+
l1_handler_resources_params.constant = l1_handler_base;
732742
raw_vc.os_resources.execute_txs_inner.insert(
733743
TransactionType::L1Handler,
734744
VariableResourceParams::WithFactor(l1_handler_resources_params),

0 commit comments

Comments
 (0)