diff --git a/Cargo.lock b/Cargo.lock index cfdf3eef5fd..6f3b2258802 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10344,7 +10344,10 @@ dependencies = [ "derive_more 0.99.18", "itertools 0.12.1", "mempool_test_utils", + "mockall", + "papyrus_network", "papyrus_network_types", + "papyrus_test_utils", "pretty_assertions", "rstest", "starknet-types-core", @@ -10353,6 +10356,7 @@ dependencies = [ "starknet_mempool_p2p_types", "starknet_mempool_types", "starknet_sequencer_infra", + "tokio", "tracing", ] diff --git a/crates/starknet_mempool/Cargo.toml b/crates/starknet_mempool/Cargo.toml index 6c692229d96..7e1f90a524c 100644 --- a/crates/starknet_mempool/Cargo.toml +++ b/crates/starknet_mempool/Cargo.toml @@ -19,11 +19,16 @@ starknet_api.workspace = true starknet_sequencer_infra.workspace = true starknet_mempool_p2p_types.workspace = true starknet_mempool_types.workspace = true +tokio.workspace = true tracing.workspace = true [dev-dependencies] assert_matches.workspace = true itertools.workspace = true +mockall.workspace = true +papyrus_network = { workspace = true, features = ["testing"] } +papyrus_network_types = { workspace = true, features = ["testing"] } +papyrus_test_utils.workspace = true rstest.workspace = true starknet_api = { workspace = true, features = ["testing"] } # Enable test utils feature for integration tests. diff --git a/crates/starknet_mempool/src/communication.rs b/crates/starknet_mempool/src/communication.rs index 7acafea8669..6a00f5bbbf5 100644 --- a/crates/starknet_mempool/src/communication.rs +++ b/crates/starknet_mempool/src/communication.rs @@ -78,7 +78,10 @@ impl MempoolCommunicationWrapper { } } - async fn add_tx(&mut self, args_wrapper: AddTransactionArgsWrapper) -> MempoolResult<()> { + pub(crate) async fn add_tx( + &mut self, + args_wrapper: AddTransactionArgsWrapper, + ) -> MempoolResult<()> { self.mempool.add_tx(args_wrapper.args.clone())?; // TODO: Verify that only transactions that were added to the mempool are sent. // TODO: handle declare correctly and remove this match. diff --git a/crates/starknet_mempool/src/mempool_test.rs b/crates/starknet_mempool/src/mempool_test.rs index e9d41d3a236..290a97dd114 100644 --- a/crates/starknet_mempool/src/mempool_test.rs +++ b/crates/starknet_mempool/src/mempool_test.rs @@ -1,11 +1,24 @@ +use std::sync::Arc; + +use mockall::predicate; +use papyrus_network_types::network_types::BroadcastedMessageMetadata; +use papyrus_test_utils::{get_rng, GetTestInstance}; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::block::GasPrice; use starknet_api::executable_transaction::AccountTransaction; +use starknet_api::rpc_transaction::{ + RpcDeployAccountTransaction, + RpcInvokeTransaction, + RpcTransaction, +}; use starknet_api::{contract_address, nonce}; +use starknet_mempool_p2p_types::communication::MockMempoolP2pPropagatorClient; +use starknet_mempool_types::communication::AddTransactionArgsWrapper; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::AddTransactionArgs; +use crate::communication::MempoolCommunicationWrapper; use crate::mempool::{Mempool, MempoolConfig, TransactionReference}; use crate::test_utils::{add_tx, add_tx_expect_error, commit_block, get_txs_and_assert_expected}; use crate::transaction_pool::TransactionPool; diff --git a/crates/starknet_mempool_p2p_types/src/communication.rs b/crates/starknet_mempool_p2p_types/src/communication.rs index 42a9a190d66..f9e4d5cf713 100644 --- a/crates/starknet_mempool_p2p_types/src/communication.rs +++ b/crates/starknet_mempool_p2p_types/src/communication.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use async_trait::async_trait; +use mockall::automock; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize};