Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akildemir committed Dec 13, 2023
1 parent bd0e8eb commit 3dfa7eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions processor/src/tests/literal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use dockertest::{

#[cfg(feature = "bitcoin")]
mod bitcoin {
use std::sync::Arc;

use super::*;
use crate::{
networks::{Network, Bitcoin, Output, OutputType, Block},
Expand Down Expand Up @@ -33,7 +35,10 @@ mod bitcoin {
primitives::insecure_pair_from_name,
};
use serai_db::MemDb;
use tokio::time::{timeout, Duration};
use tokio::{
time::{timeout, Duration},
sync::Mutex,
};

#[test]
fn test_dust_constant() {
Expand Down Expand Up @@ -75,7 +80,7 @@ mod bitcoin {

// create a scanner
let db = MemDb::new();
let mut scanner = new_scanner(&btc, &db, group_key).await;
let mut scanner = new_scanner(&btc, &db, group_key, &Arc::new(Mutex::new(true))).await;

// make a transfer instruction & hash it for script.
let serai_address = insecure_pair_from_name("dadadadada").public();
Expand Down
9 changes: 5 additions & 4 deletions processor/src/tests/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub async fn new_scanner<N: Network, D: Db>(
network: &N,
db: &D,
group_key: <N::Curve as Ciphersuite>::G,
first: &Arc<Mutex<bool>>,
) -> ScannerHandle<N, D> {
let first = Arc::new(Mutex::new(true));
let activation_number = network.get_latest_block_number().await.unwrap();
let mut db = db.clone();
let (mut scanner, current_keys) = Scanner::new(network.clone(), db.clone());
Expand Down Expand Up @@ -52,7 +52,8 @@ pub async fn test_scanner<N: Network>(network: N) {
}

let db = MemDb::new();
let scanner = new_scanner(&network, &db, group_key).await;
let first = Arc::new(Mutex::new(true));
let scanner = new_scanner(&network, &db, group_key, &first).await;

// Receive funds
let block = network.test_send(N::external_address(keys.group_key())).await;
Expand All @@ -79,7 +80,7 @@ pub async fn test_scanner<N: Network>(network: N) {
let (mut scanner, outputs) = verify_event(scanner).await;

// Create a new scanner off the current DB and verify it re-emits the above events
verify_event(new_scanner(&network, &db, group_key).await).await;
verify_event(new_scanner(&network, &db, group_key, &first).await).await;

// Acknowledge the block
let mut cloned_db = db.clone();
Expand All @@ -94,7 +95,7 @@ pub async fn test_scanner<N: Network>(network: N) {
// Create a new scanner off the current DB and make sure it also does nothing
assert!(timeout(
Duration::from_secs(30),
new_scanner(&network, &db, group_key).await.events.recv()
new_scanner(&network, &db, group_key, &first).await.events.recv()
)
.await
.is_err());
Expand Down

0 comments on commit 3dfa7eb

Please sign in to comment.