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

mock txn stream step #65

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ use tracing::{error, info, warn};
// TransactionStreamStep is establishes a gRPC connection with Transaction Stream
// fetches transactions, and outputs them for processing. It also handles reconnections with retries.
// This is usually the initial step in a processor.
pub struct TransactionStreamStep
pub struct ProdTransactionStreamStep
where
Self: Sized + Send + 'static,
{
transaction_stream_config: TransactionStreamConfig,
pub transaction_stream: Mutex<TransactionStreamInternal>,
}

impl TransactionStreamStep
impl ProdTransactionStreamStep
where
Self: Sized + Send + 'static,
{
Expand All @@ -47,7 +47,7 @@ where
}

#[async_trait]
impl Processable for TransactionStreamStep
impl Processable for ProdTransactionStreamStep
where
Self: Sized + Send + 'static,
{
Expand All @@ -65,7 +65,7 @@ where
}

#[async_trait]
impl PollableAsyncStep for TransactionStreamStep
impl PollableAsyncStep for ProdTransactionStreamStep
where
Self: Sized + Send + Sync + 'static,
{
Expand Down Expand Up @@ -148,7 +148,7 @@ where
}
}

impl NamedStep for TransactionStreamStep {
impl NamedStep for ProdTransactionStreamStep {
fn name(&self) -> String {
"TransactionStreamStep".to_string()
}
Expand Down Expand Up @@ -199,6 +199,12 @@ mock! {
}
}

#[cfg(not(test))]
pub type TransactionStreamStep = ProdTransactionStreamStep;

#[cfg(test)]
pub type TransactionStreamStep = MockTransactionStreamStep;

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -214,7 +220,7 @@ mod tests {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[allow(clippy::needless_return)]
async fn test_transaction_stream() {
let mut mock_transaction_stream = MockTransactionStreamStep::new();
let mut mock_transaction_stream = TransactionStreamStep::new();
// Testing framework can provide mocked transactions here
mock_transaction_stream.expect_poll().returning(|| {
Ok(Some(vec![TransactionContext {
Expand Down
Loading