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 committed Dec 30, 2024
1 parent 9e3b0d0 commit d10483d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
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 @@ -54,6 +55,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() -> CentralStateDiff {
// TODO(yael): compute the CentralStateDiff with into().
Expand Down Expand Up @@ -239,12 +241,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(serde_json::to_value(central_state_diff()).unwrap(), 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 d10483d

Please sign in to comment.