Skip to content

Commit

Permalink
fixup! feat(offchain): implement the broker-listener for the authorit…
Browse files Browse the repository at this point in the history
…y-claimer
  • Loading branch information
marcelstanley committed Sep 26, 2023
1 parent ec200ef commit 9ecb93b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 85 deletions.
2 changes: 1 addition & 1 deletion offchain/authority-claimer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod metrics;
pub mod sender;

#[cfg(test)]
mod mock;
mod broker_mock;

use config::Config;
use rollups_events::DAppMetadata;
Expand Down
18 changes: 9 additions & 9 deletions offchain/authority-claimer/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ mod tests {
use test_fixtures::BrokerFixture;

use crate::{
broker_mock,
listener::{BrokerListener, DefaultBrokerListener},
mock,
};

async fn setup(docker: &Cli) -> (BrokerFixture, DefaultBrokerListener) {
mock::setup_broker(docker, false).await.unwrap()
broker_mock::setup_broker(docker, false).await.unwrap()
}

#[tokio::test]
Expand All @@ -93,7 +93,7 @@ mod tests {
#[tokio::test]
async fn instantiate_new_broker_listener_error() {
let docker = Cli::default();
let result = mock::setup_broker(&docker, true).await;
let result = broker_mock::setup_broker(&docker, true).await;
assert!(result.is_err(), "setup_broker didn't fail as it should");
let error = result.err().unwrap().to_string();
assert_eq!(error, "error connecting to Redis");
Expand All @@ -104,8 +104,8 @@ mod tests {
let docker = Cli::default();
let (fixture, mut broker_listener) = setup(&docker).await;
let n = 5;
mock::produce_rollups_claims(&fixture, n, 0).await;
mock::produce_last_claim(&fixture, n).await;
broker_mock::produce_rollups_claims(&fixture, n, 0).await;
broker_mock::produce_last_claim(&fixture, n).await;
let result = broker_listener.listen().await;
assert!(result.is_ok());
}
Expand All @@ -114,7 +114,7 @@ mod tests {
async fn start_broker_listener_with_claims_enqueued() {
let docker = Cli::default();
let (fixture, mut broker_listener) = setup(&docker).await;
mock::produce_last_claim(&fixture, 0).await;
broker_mock::produce_last_claim(&fixture, 0).await;
let claim = broker_listener.listen().await;
assert!(claim.is_ok());
}
Expand All @@ -136,17 +136,17 @@ mod tests {

let x = 2;
println!("Creating {} claims.", x);
mock::produce_rollups_claims(&fixture, x, 0).await;
broker_mock::produce_rollups_claims(&fixture, x, 0).await;

println!("Going to sleep for 2 seconds.");
tokio::time::sleep(Duration::from_secs(2)).await;

let y = 5;
println!("Creating {} claims.", y);
mock::produce_rollups_claims(&fixture, y, x).await;
broker_mock::produce_rollups_claims(&fixture, y, x).await;

assert_eq!(x + y, n);
mock::produce_last_claim(&fixture, n).await;
broker_mock::produce_last_claim(&fixture, n).await;

broker_listener_thread.await.unwrap();
}
Expand Down
75 changes: 0 additions & 75 deletions offchain/authority-claimer/src/mock.rs

This file was deleted.

0 comments on commit 9ecb93b

Please sign in to comment.