Skip to content

Commit

Permalink
test(sequencing): add a bouncer_weights serialization test for cende (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware authored Jan 1, 2025
1 parent f937485 commit 617b639
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ tracing.workspace = true
url = { workspace = true, features = ["serde"] }

[dev-dependencies]
blockifier.workspace = true
infra_utils.workspace = true
lazy_static.workspace = true
mockall.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"builtin_count": {
"add_mod": 0,
"bitwise": 0,
"ecdsa": 0,
"ec_op": 0,
"keccak": 0,
"mul_mod": 0,
"pedersen": 4948,
"poseidon": 54,
"range_check": 2301,
"range_check96": 0
},
"l1_gas": 0,
"message_segment_length": 0,
"n_events": 2,
"n_steps": 121095,
"state_diff_size": 45,
"sierra_gas": 0
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use blockifier::bouncer::{BouncerWeights, BuiltinCount};
use indexmap::indexmap;
use rstest::rstest;
use serde_json::Value;
Expand Down Expand Up @@ -56,6 +57,7 @@ pub const CENTRAL_INVOKE_TX_JSON_PATH: &str = "central_invoke_tx.json";
pub const CENTRAL_DEPLOY_ACCOUNT_TX_JSON_PATH: &str = "central_deploy_account_tx.json";
pub const CENTRAL_DECLARE_TX_JSON_PATH: &str = "central_declare_tx.json";
pub const CENTRAL_L1_HANDLER_TX_JSON_PATH: &str = "central_l1_handler_tx.json";
pub const CENTRAL_BOUNCER_WEIGHTS_JSON_PATH: &str = "central_bouncer_weights.json";

fn central_state_diff_json() -> Value {
let state_diff = ThinStateDiff {
Expand Down Expand Up @@ -240,12 +242,30 @@ fn central_l1_handler_tx_json() -> Value {
serde_json::to_value(central_transaction_written).unwrap()
}

fn central_bouncer_weights_json() -> Value {
let bouncer_weights = BouncerWeights {
builtin_count: BuiltinCount {
pedersen: 4948,
poseidon: 54,
range_check: 2301,
..BuiltinCount::empty()
},
n_events: 2,
n_steps: 121095,
state_diff_size: 45,
..BouncerWeights::empty()
};

serde_json::to_value(bouncer_weights).unwrap()
}

#[rstest]
#[case::state_diff(central_state_diff_json(), CENTRAL_STATE_DIFF_JSON_PATH)]
#[case::invoke_tx(central_invoke_tx_json(), CENTRAL_INVOKE_TX_JSON_PATH)]
#[case::deploy_account_tx(central_deploy_account_tx_json(), CENTRAL_DEPLOY_ACCOUNT_TX_JSON_PATH)]
#[case::declare_tx(central_declare_tx_json(), CENTRAL_DECLARE_TX_JSON_PATH)]
#[case::l1_handler_tx(central_l1_handler_tx_json(), CENTRAL_L1_HANDLER_TX_JSON_PATH)]
#[case::bouncer_weights(central_bouncer_weights_json(), CENTRAL_BOUNCER_WEIGHTS_JSON_PATH)]
fn serialize_central_objects(#[case] rust_json: Value, #[case] python_json_path: &str) {
let python_json = read_json_file(python_json_path);

Expand Down

0 comments on commit 617b639

Please sign in to comment.