Skip to content

Commit 7505307

Browse files
starknet_os: os resources test - l1 handler tx calldata factor
1 parent b07e51e commit 7505307

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
@@ -448,7 +448,7 @@ async fn test_execute_txs_inner_resources() {
448448
let version = StarknetVersion::LATEST;
449449
let mut raw_vc: RawVersionedConstants =
450450
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
451-
const N_TXS: usize = 6;
451+
const N_TXS: usize = 7;
452452

453453
let (os_resources_contract_address, deployable_class_hash, mut test_builder) =
454454
setup_test_builder().await;
@@ -551,6 +551,13 @@ async fn test_execute_txs_inner_resources() {
551551
calldata![Felt::from(100), Felt::ZERO],
552552
None,
553553
);
554+
test_builder.add_l1_handler(
555+
os_resources_contract_address,
556+
"empty_l1_handler",
557+
// From address, extra args.
558+
calldata![Felt::from(100), Felt::ONE, Felt::ZERO],
559+
None,
560+
);
554561

555562
// Execute the business logic and extract the business logic resources for each tx.
556563
let test_runner = test_builder.build().await;
@@ -590,7 +597,8 @@ async fn test_execute_txs_inner_resources() {
590597
declare_overhead,
591598
deploy_account_base,
592599
deploy_account_extra,
593-
l1_handler_overhead,
600+
l1_handler_base,
601+
l1_handler_extra,
594602
]: [ExecutionResources; N_TXS] = test_output
595603
.runner_output
596604
.txs_trace
@@ -686,7 +694,6 @@ async fn test_execute_txs_inner_resources() {
686694
);
687695

688696
// L1 handler: variable cost, unscaled.
689-
// TODO(Dori): Compute linear factor cost.
690697
let VariableResourceParams::WithFactor(mut l1_handler_resources_params) =
691698
raw_vc.os_resources.execute_txs_inner.get(&TransactionType::L1Handler).unwrap().clone()
692699
else {
@@ -701,7 +708,10 @@ async fn test_execute_txs_inner_resources() {
701708
"L1 handler scaling factor has unexpected structure: {:?}",
702709
l1_handler_resources_params.calldata_factor
703710
);
704-
l1_handler_resources_params.constant = l1_handler_overhead;
711+
l1_handler_resources_params.calldata_factor = VariableCallDataFactor::Unscaled(
712+
(&l1_handler_extra - &l1_handler_base).filter_unused_builtins(),
713+
);
714+
l1_handler_resources_params.constant = l1_handler_base;
705715
raw_vc.os_resources.execute_txs_inner.insert(
706716
TransactionType::L1Handler,
707717
VariableResourceParams::WithFactor(l1_handler_resources_params),

0 commit comments

Comments
 (0)