Skip to content

Commit 852e864

Browse files
authored
Merge pull request #491 from AmbireTech/test_harness-additional-multichain-tests
test_harness - additional multichain tests
2 parents 6a908af + 30fc79c commit 852e864

File tree

5 files changed

+973
-37
lines changed

5 files changed

+973
-37
lines changed

docs/config/ganache.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ propagation_timeout = 2000
2020

2121
fetch_timeout = 5000
2222
all_campaigns_timeout = 5000
23-
channel_tick_timeout = 5000
23+
# for test_harness make it larger
24+
# Default: 5000
25+
channel_tick_timeout = 8000
2426

2527
ip_rate_limit = { type = 'ip', timeframe = 1200000 }
2628
sid_rate_limit = { type = 'sid', timeframe = 0 }

primitives/src/test_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub static DUMMY_AD_UNITS: Lazy<[AdUnit; 4]> = Lazy::new(|| {
231231
min_targeting_score: None,
232232
modified: None,
233233
owner: IDS[&PUBLISHER],
234-
title: Some("Dummy AdUnit 3".to_string()),
234+
title: Some("Dummy AdUnit 1".to_string()),
235235
},
236236
AdUnit {
237237
ipfs: IPFS::try_from("QmVhRDGXoM3Fg3HZD5xwMuxtb9ZErwC8wHt8CjsfxaiUbZ")

sentry/src/db/campaign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ mod campaign_remaining {
328328
Ok(campaigns_remaining)
329329
}
330330

331-
/// This method will get the remaining of the provided [`Campaign`]s
331+
/// This method will get the remaining of the provided [`Campaign`](primitives::Campaign)s
332332
/// and it will also match the returned values to the [`CampaignId`]s
333333
/// `MGET` should always return results in the same order!
334334
pub async fn get_multiple_with_ids(

sentry/src/lib.rs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,15 @@ pub struct Auth {
491491

492492
#[cfg(test)]
493493
pub mod test_util {
494+
use std::ops;
495+
494496
use adapter::{
495497
dummy::{Dummy, Options},
496498
Adapter,
497499
};
498500
use primitives::{
499501
config::GANACHE_CONFIG,
500-
test_util::{discard_logger, CREATOR, FOLLOWER, IDS, LEADER},
502+
test_util::{discard_logger, DUMMY_AUTH, IDS, LEADER},
501503
};
502504

503505
use crate::{
@@ -510,19 +512,38 @@ pub mod test_util {
510512
Application,
511513
};
512514

515+
/// This guard holds the Redis and Postgres pools taken from their respective Pool of pools.
516+
///
517+
/// This ensures that they will not be dropped which will cause tests to fail randomly.
518+
pub struct ApplicationGuard {
519+
pub app: Application<Dummy>,
520+
#[allow(dead_code)]
521+
redis_pool: deadpool::managed::Object<crate::db::redis_pool::Manager>,
522+
#[allow(dead_code)]
523+
db_pool: deadpool::managed::Object<crate::db::tests_postgres::Manager>,
524+
}
525+
526+
impl ops::Deref for ApplicationGuard {
527+
type Target = Application<Dummy>;
528+
529+
fn deref(&self) -> &Self::Target {
530+
&self.app
531+
}
532+
}
533+
impl ops::DerefMut for ApplicationGuard {
534+
fn deref_mut(&mut self) -> &mut Self::Target {
535+
&mut self.app
536+
}
537+
}
538+
513539
/// Uses development and therefore the goerli testnet addresses of the tokens
514-
/// It still uses DummyAdapter.
515-
pub async fn setup_dummy_app() -> Application<Dummy> {
540+
/// but still uses the `DummyAdapter`.
541+
pub async fn setup_dummy_app() -> ApplicationGuard {
516542
let config = GANACHE_CONFIG.clone();
543+
517544
let adapter = Adapter::new(Dummy::init(Options {
518545
dummy_identity: IDS[&LEADER],
519-
dummy_auth_tokens: vec![
520-
(*CREATOR, "AUTH_Creator".into()),
521-
(*LEADER, "AUTH_Leader".into()),
522-
(*FOLLOWER, "AUTH_Follower".into()),
523-
]
524-
.into_iter()
525-
.collect(),
546+
dummy_auth_tokens: DUMMY_AUTH.clone(),
526547
}));
527548

528549
let redis = TESTS_POOL.get().await.expect("Should return Object");
@@ -550,6 +571,10 @@ pub mod test_util {
550571
platform_api,
551572
);
552573

553-
app
574+
ApplicationGuard {
575+
app,
576+
redis_pool: redis,
577+
db_pool: database,
578+
}
554579
}
555580
}

0 commit comments

Comments
 (0)