diff --git a/crates/apollo_consensus_orchestrator/Cargo.toml b/crates/apollo_consensus_orchestrator/Cargo.toml index f841971aa67..c2913ac8a3f 100644 --- a/crates/apollo_consensus_orchestrator/Cargo.toml +++ b/crates/apollo_consensus_orchestrator/Cargo.toml @@ -84,4 +84,4 @@ serde_json.workspace = true workspace = true [features] -testing = [] +testing = ["shared_execution_objects/deserialize", "shared_execution_objects/testing"] diff --git a/crates/apollo_consensus_orchestrator/src/cende/central_objects.rs b/crates/apollo_consensus_orchestrator/src/cende/central_objects.rs index 5b1ac235467..4e78070195d 100644 --- a/crates/apollo_consensus_orchestrator/src/cende/central_objects.rs +++ b/crates/apollo_consensus_orchestrator/src/cende/central_objects.rs @@ -60,6 +60,7 @@ mod central_objects_test; /// Subset of BouncerWeights sent to the centralized pipeline. /// Excludes `receipt_l2_gas` which is only used internally by the decentralized sequencer. +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Serialize)] pub(crate) struct CentralBouncerWeights { pub l1_gas: usize, @@ -91,12 +92,14 @@ pub(crate) type CentralCasmContractClassEntry = (CompiledClassHash, CentralCasmC pub(crate) type CentralCasmHashComputationData = CasmHashComputationData; pub(crate) type CentralCompiledClassHashesForMigration = CompiledClassHashesForMigration; +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Serialize)] struct CentralResourcePrice { price_in_wei: NonzeroGasPrice, price_in_fri: NonzeroGasPrice, } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Serialize)] pub(crate) struct CentralBlockInfo { block_number: BlockNumber, @@ -133,6 +136,7 @@ impl From<(BlockInfo, StarknetVersion)> for CentralBlockInfo { } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] pub(crate) struct CentralStateDiff { address_to_class_hash: IndexMap, @@ -178,6 +182,7 @@ impl From<(CommitmentStateDiff, CentralBlockInfo)> for CentralStateDiff { } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] struct CentralResourceBounds { #[serde(rename = "L1_GAS")] @@ -198,6 +203,7 @@ impl From for CentralResourceBounds { } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] struct CentralInvokeTransactionV3 { resource_bounds: CentralResourceBounds, @@ -236,6 +242,7 @@ impl From<(InternalRpcInvokeTransactionV3, TransactionHash)> for CentralInvokeTr } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] #[serde(tag = "version")] enum CentralInvokeTransaction { @@ -243,6 +250,7 @@ enum CentralInvokeTransaction { V3(CentralInvokeTransactionV3), } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] struct CentralDeployAccountTransactionV3 { resource_bounds: CentralResourceBounds, @@ -285,6 +293,7 @@ impl From<(InternalRpcDeployAccountTransaction, TransactionHash)> } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] #[serde(tag = "version")] enum CentralDeployAccountTransaction { @@ -296,6 +305,7 @@ fn into_string_tuple(val: SierraVersion) -> (String, String, String) { (format!("0x{:x}", val.major), format!("0x{:x}", val.minor), format!("0x{:x}", val.patch)) } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] struct CentralDeclareTransactionV3 { resource_bounds: CentralResourceBounds, @@ -349,6 +359,7 @@ impl TryFrom<(InternalRpcDeclareTransactionV3, &SierraContractClass, Transaction } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] #[serde(tag = "version")] enum CentralDeclareTransaction { @@ -356,6 +367,7 @@ enum CentralDeclareTransaction { V3(CentralDeclareTransactionV3), } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] struct CentralL1HandlerTransaction { contract_address: ContractAddress, @@ -379,6 +391,7 @@ impl From for CentralL1HandlerTransaction { } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] #[serde(tag = "type")] enum CentralTransaction { @@ -427,6 +440,7 @@ impl TryFrom<(InternalConsensusTransaction, Option<&SierraContractClass>)> for C } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Debug, PartialEq, Serialize)] pub(crate) struct CentralTransactionWritten { tx: CentralTransaction, @@ -449,11 +463,13 @@ impl TryFrom<(InternalConsensusTransaction, Option<&SierraContractClass>, u64)> }) } } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Serialize)] pub(crate) struct CentralSierraContractClass { contract_class: SierraContractClass, } +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Serialize)] pub(crate) struct CentralCasmContractClass { compiled_class: CasmContractClass, diff --git a/crates/apollo_consensus_orchestrator/src/cende/mod.rs b/crates/apollo_consensus_orchestrator/src/cende/mod.rs index aa5f6d0ccc1..f2dc66d7c35 100644 --- a/crates/apollo_consensus_orchestrator/src/cende/mod.rs +++ b/crates/apollo_consensus_orchestrator/src/cende/mod.rs @@ -70,6 +70,7 @@ pub(crate) const N_BLOCK_HASHES_BACK_IN_BLOB: u64 = STORED_BLOCK_HASH_BUFFER; pub type CendeAmbassadorResult = Result; /// A chunk of all the data to write to Aersopike. +#[cfg_attr(any(feature = "testing", test), derive(Deserialize, PartialEq))] #[derive(Debug, Serialize)] pub struct AerospikeBlob { block_number: BlockNumber, diff --git a/crates/apollo_consensus_orchestrator/src/fee_market/mod.rs b/crates/apollo_consensus_orchestrator/src/fee_market/mod.rs index 507b6cfa1c4..1bd20882504 100644 --- a/crates/apollo_consensus_orchestrator/src/fee_market/mod.rs +++ b/crates/apollo_consensus_orchestrator/src/fee_market/mod.rs @@ -21,6 +21,7 @@ mod test; const MIN_GAS_PRICE_INCREASE_DENOMINATOR: u128 = 333; /// Fee market information for the next block. +#[cfg_attr(any(feature = "testing", test), derive(serde::Deserialize, PartialEq))] #[derive(Debug, Default, Serialize)] pub struct FeeMarketInfo { /// Total gas consumed in the current block. diff --git a/crates/shared_execution_objects/Cargo.toml b/crates/shared_execution_objects/Cargo.toml index 0d8b5c3f378..7ec828d215d 100644 --- a/crates/shared_execution_objects/Cargo.toml +++ b/crates/shared_execution_objects/Cargo.toml @@ -8,6 +8,7 @@ description = "Python-compatible representation of execution objects of the Star [features] deserialize = ["blockifier/transaction_serde"] +testing = [] [dependencies] blockifier.workspace = true diff --git a/crates/shared_execution_objects/src/central_objects.rs b/crates/shared_execution_objects/src/central_objects.rs index 83dbc575fa3..c9891d259c2 100644 --- a/crates/shared_execution_objects/src/central_objects.rs +++ b/crates/shared_execution_objects/src/central_objects.rs @@ -40,6 +40,7 @@ impl From for ResourcesMapping { /// The TransactionExecutionInfo object as used by the Python code. #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] +#[cfg_attr(feature = "testing", derive(PartialEq))] #[derive(Debug, Serialize)] pub struct CentralTransactionExecutionInfo { pub validate_call_info: Option,