From f87a869f2320798ed73ee813a7a293eae2e234e3 Mon Sep 17 00:00:00 2001 From: Ayelet Zilber Date: Mon, 11 Nov 2024 12:03:00 +0200 Subject: [PATCH] refactor(starknet_api): use general invoke rpc transaction test util --- .../starknet_api/src/rpc_transaction_test.rs | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/crates/starknet_api/src/rpc_transaction_test.rs b/crates/starknet_api/src/rpc_transaction_test.rs index cedc4f2fa0..d76f9ef1bc 100644 --- a/crates/starknet_api/src/rpc_transaction_test.rs +++ b/crates/starknet_api/src/rpc_transaction_test.rs @@ -13,10 +13,9 @@ use crate::rpc_transaction::{ RpcDeclareTransactionV3, RpcDeployAccountTransaction, RpcDeployAccountTransactionV3, - RpcInvokeTransaction, - RpcInvokeTransactionV3, RpcTransaction, }; +use crate::test_utils::invoke::{rpc_invoke_tx, InvokeTxArgs}; use crate::transaction::fields::{ AccountDeploymentData, AllResourceBounds, @@ -26,6 +25,7 @@ use crate::transaction::fields::{ ResourceBounds, Tip, TransactionSignature, + ValidResourceBounds, }; use crate::{class_hash, contract_address, felt, nonce}; @@ -68,26 +68,19 @@ fn create_deploy_account_v3() -> RpcDeployAccountTransaction { }) } -fn create_invoke_v3() -> RpcInvokeTransaction { - RpcInvokeTransaction::V3(RpcInvokeTransactionV3 { - resource_bounds: create_resource_bounds_for_testing(), - tip: Tip(50), - calldata: Calldata(Arc::new(vec![felt!("0x2000"), felt!("0x1000")])), - sender_address: contract_address!("0x53"), - nonce: nonce!(32), - signature: TransactionSignature::default(), - nonce_data_availability_mode: DataAvailabilityMode::L1, - fee_data_availability_mode: DataAvailabilityMode::L1, - paymaster_data: PaymasterData(vec![Felt::TWO, Felt::ZERO]), - account_deployment_data: AccountDeploymentData(vec![felt!("0x87")]), - }) -} - // We are testing the `RpcTransaction` serialization. Passing non-default values. #[rstest] #[case(RpcTransaction::Declare(create_declare_v3()))] #[case(RpcTransaction::DeployAccount(create_deploy_account_v3()))] -#[case(RpcTransaction::Invoke(create_invoke_v3()))] +#[case(rpc_invoke_tx(InvokeTxArgs { + resource_bounds: ValidResourceBounds::AllResources(create_resource_bounds_for_testing()), + tip: Tip(50), + calldata: Calldata(Arc::new(vec![felt!("0x2000"), felt!("0x1000")])), + sender_address: contract_address!("0x53"), + nonce: nonce!(32), + paymaster_data: PaymasterData(vec![Felt::TWO, Felt::ZERO]), + account_deployment_data: AccountDeploymentData(vec![felt!("0x87")]), + ..Default::default()}))] fn test_rpc_transactions(#[case] tx: RpcTransaction) { let serialized = serde_json::to_string(&tx).unwrap(); let deserialized: RpcTransaction = serde_json::from_str(&serialized).unwrap();