Skip to content

Commit

Permalink
test(starknet_mempool): tx added to mempool are forwarded to propagat…
Browse files Browse the repository at this point in the history
…or client
  • Loading branch information
AlonLStarkWare committed Dec 2, 2024
1 parent ece1dab commit 9a2f5df
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions crates/starknet_mempool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion crates/starknet_mempool/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions crates/starknet_mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9a2f5df

Please sign in to comment.