Skip to content

Commit d5aaebf

Browse files
starknet_os: os resources test - l1 handler tx calldata factor
1 parent 77fc062 commit d5aaebf

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
@@ -402,7 +402,7 @@ async fn test_execute_txs_inner_resources() {
402402
let version = StarknetVersion::LATEST;
403403
let mut raw_vc: RawVersionedConstants =
404404
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
405-
const N_TXS: usize = 6;
405+
const N_TXS: usize = 7;
406406

407407
let (os_resources_contract_address, mut test_builder) = setup_test_builder().await;
408408

@@ -499,6 +499,13 @@ async fn test_execute_txs_inner_resources() {
499499
calldata![Felt::from(100), Felt::ZERO],
500500
None,
501501
);
502+
test_builder.add_l1_handler(
503+
os_resources_contract_address,
504+
"empty_l1_handler",
505+
// From address, extra args.
506+
calldata![Felt::from(100), Felt::ONE, Felt::ZERO],
507+
None,
508+
);
502509

503510
// Execute the business logic and extract the business logic resources for each tx.
504511
let test_runner = test_builder.build().await;
@@ -538,7 +545,8 @@ async fn test_execute_txs_inner_resources() {
538545
declare_overhead,
539546
deploy_account_base,
540547
deploy_account_extra,
541-
l1_handler_overhead,
548+
l1_handler_base,
549+
l1_handler_extra,
542550
]: [ExecutionResources; N_TXS] = test_output
543551
.runner_output
544552
.txs_trace
@@ -634,7 +642,6 @@ async fn test_execute_txs_inner_resources() {
634642
);
635643

636644
// L1 handler: variable cost, unscaled.
637-
// TODO(Dori): Compute linear factor cost.
638645
let VariableResourceParams::WithFactor(mut l1_handler_resources_params) =
639646
raw_vc.os_resources.execute_txs_inner.get(&TransactionType::L1Handler).unwrap().clone()
640647
else {
@@ -649,7 +656,10 @@ async fn test_execute_txs_inner_resources() {
649656
"L1 handler scaling factor has unexpected structure: {:?}",
650657
l1_handler_resources_params.calldata_factor
651658
);
652-
l1_handler_resources_params.constant = l1_handler_overhead;
659+
l1_handler_resources_params.calldata_factor = VariableCallDataFactor::Unscaled(
660+
(&l1_handler_extra - &l1_handler_base).filter_unused_builtins(),
661+
);
662+
l1_handler_resources_params.constant = l1_handler_base;
653663
raw_vc.os_resources.execute_txs_inner.insert(
654664
TransactionType::L1Handler,
655665
VariableResourceParams::WithFactor(l1_handler_resources_params),

0 commit comments

Comments
 (0)