Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests for serde wrapper #2463

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

1 change: 1 addition & 0 deletions crates/starknet_sequencer_infra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ papyrus_config.workspace = true
rstest.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
starknet_api.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing.workspace = true
Expand Down
68 changes: 68 additions & 0 deletions crates/starknet_sequencer_infra/src/serde_utils_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
use std::fmt::Debug;

use serde::{Deserialize, Serialize};
use starknet_api::data_availability::DataAvailabilityMode;
use starknet_api::rpc_transaction::{
RpcDeclareTransaction,
RpcDeclareTransactionV3,
RpcDeployAccountTransaction,
RpcDeployAccountTransactionV3,
RpcInvokeTransaction,
RpcInvokeTransactionV3,
RpcTransaction,
};
use starknet_types_core::felt::Felt;

use crate::serde_utils::SerdeWrapper;
Expand Down Expand Up @@ -40,3 +50,61 @@ fn test_serde_felt() {
let data: Felt = Felt::ONE;
test_generic_data_serde(data);
}

#[test]
fn test_serde_rpc_invoke_tx() {
let invoke_tx = RpcInvokeTransactionV3 {
sender_address: Default::default(),
calldata: Default::default(),
signature: Default::default(),
nonce: Default::default(),
resource_bounds: Default::default(),
tip: Default::default(),
paymaster_data: Default::default(),
account_deployment_data: Default::default(),
nonce_data_availability_mode: DataAvailabilityMode::L1,
fee_data_availability_mode: DataAvailabilityMode::L1,
};
let rpc_invoke_tx = RpcInvokeTransaction::V3(invoke_tx);

test_generic_data_serde(RpcTransaction::Invoke(rpc_invoke_tx));
}

#[test]
fn test_serde_rpc_deploy_account_tx() {
let deploy_account_tx = RpcDeployAccountTransactionV3 {
signature: Default::default(),
nonce: Default::default(),
class_hash: Default::default(),
resource_bounds: Default::default(),
contract_address_salt: Default::default(),
constructor_calldata: Default::default(),
tip: Default::default(),
paymaster_data: Default::default(),
nonce_data_availability_mode: DataAvailabilityMode::L1,
fee_data_availability_mode: DataAvailabilityMode::L1,
};
let rpc_deploy_account_tx = RpcDeployAccountTransaction::V3(deploy_account_tx);

test_generic_data_serde(RpcTransaction::DeployAccount(rpc_deploy_account_tx));
}

#[test]
fn test_serde_rpc_declare_tx() {
let declare_tx = RpcDeclareTransactionV3 {
sender_address: Default::default(),
compiled_class_hash: Default::default(),
signature: Default::default(),
nonce: Default::default(),
contract_class: Default::default(),
resource_bounds: Default::default(),
tip: Default::default(),
paymaster_data: Default::default(),
account_deployment_data: Default::default(),
nonce_data_availability_mode: DataAvailabilityMode::L1,
fee_data_availability_mode: DataAvailabilityMode::L1,
};
let rpc_declare_tx = RpcDeclareTransaction::V3(declare_tx);

test_generic_data_serde(RpcTransaction::Declare(rpc_declare_tx));
}
Loading