Skip to content

Commit

Permalink
refactor(starknet_mempool): small refactor to memppol_test
Browse files Browse the repository at this point in the history
  • Loading branch information
dafnamatsry committed Feb 9, 2025
1 parent cea0722 commit 149efdf
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 211 deletions.
23 changes: 21 additions & 2 deletions crates/starknet_mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ use starknet_mempool_types::mempool_types::{
use tracing::{debug, info, instrument};

use crate::transaction_pool::TransactionPool;
#[cfg(test)]
use crate::transaction_pool::TransactionPoolContent;
#[cfg(test)]
use crate::transaction_queue::transaction_queue_test_utils::TransactionQueueContent;
use crate::transaction_queue::TransactionQueue;
use crate::utils::try_increment_nonce;

#[cfg(test)]
#[path = "mempool_test.rs"]
pub mod mempool_test;

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct MempoolConfig {
enable_fee_escalation: bool,
// TODO(AlonH): consider adding validations; should be bounded?
Expand All @@ -41,7 +45,7 @@ type AddressToNonce = HashMap<ContractAddress, Nonce>;
/// Represents the state tracked by the mempool.
/// It is partitioned into categories, each serving a distinct role in the lifecycle of transaction
/// management.
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct MempoolState {
/// Finalized nonces committed in blocks.
committed: AddressToNonce,
Expand Down Expand Up @@ -382,6 +386,21 @@ impl Mempool {

incoming_value >= escalation_qualified_value
}

#[cfg(test)]
pub fn content(&self) -> MempoolContent {
MempoolContent {
tx_pool_content: self.tx_pool.content(),
tx_queue_content: self.tx_queue.content(),
}
}
}

#[cfg(test)]
#[derive(Debug, Default, PartialEq, Eq)]
pub struct MempoolContent {
pub tx_pool_content: TransactionPoolContent,
pub tx_queue_content: TransactionQueueContent,
}

/// Provides a lightweight representation of a transaction for mempool usage (e.g., excluding
Expand Down
Loading

0 comments on commit 149efdf

Please sign in to comment.