Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
18510f6
WIP tests for units-for-slot route
elpiel Apr 11, 2022
837b512
test_harness - multichain tests for CAMPAIGN_3
elpiel Apr 26, 2022
9bd511d
primitives - UnifiedNum:
elpiel May 12, 2022
ce7d506
primitives - UnifiedNum - try to fix div_floor
elpiel May 12, 2022
12c12f9
primitives - UnifiedNum - fix bugs with:
elpiel May 16, 2022
2115a0a
UnifiedNum - fix div_floor and add more tests
elpiel May 16, 2022
1fb5c4d
primitives - UnifiedNum - use from_whole when mul with u64
elpiel May 16, 2022
9235ec2
sentry - fix tests related to UnifiedNum & fees
elpiel May 16, 2022
f425a3e
worker - fix get_health calculation
elpiel May 16, 2022
02c778c
Merge branch 'bugfix-unified-num-math-operations' into test_harness-a…
elpiel May 17, 2022
f5c2ddc
primitives - clean up UnifiedNum & fix warnings
elpiel May 17, 2022
eeed4ea
Merge branch 'aip-61-adex-v5' into bugfix-unified-num-math-operations
elpiel May 17, 2022
4011455
test_harness - update tests and calculations
elpiel May 17, 2022
0669928
Merge branch 'bugfix-unified-num-math-operations' into test_harness-a…
elpiel May 17, 2022
1bc3d84
Merge branch 'bugfix-unified-num-math-operations' into test_harness-a…
elpiel May 20, 2022
2feeb3a
test_harness - test more states on CAMPAIGN_2:
elpiel May 20, 2022
b3ad0af
test_harness - fix assertions with timestamp for Validator Messages
elpiel May 25, 2022
e204050
sentry - fix drop of Object holding the Pools
elpiel May 25, 2022
df3f61c
Merge branch 'aip-61-adex-v5' into test_harness-additional-multichain…
elpiel May 25, 2022
30fc79c
remove WIP units-for-slot tests
elpiel May 25, 2022
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
4 changes: 3 additions & 1 deletion docs/config/ganache.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ propagation_timeout = 2000

fetch_timeout = 5000
all_campaigns_timeout = 5000
channel_tick_timeout = 5000
# for test_harness make it larger
# Default: 5000
channel_tick_timeout = 8000
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still get timeouts in test_harness sometimes, we have to check why this is - performance issue or something wrong with the services


ip_rate_limit = { type = 'ip', timeframe = 1200000 }
sid_rate_limit = { type = 'sid', timeframe = 0 }
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub static DUMMY_AD_UNITS: Lazy<[AdUnit; 4]> = Lazy::new(|| {
min_targeting_score: None,
modified: None,
owner: IDS[&PUBLISHER],
title: Some("Dummy AdUnit 3".to_string()),
title: Some("Dummy AdUnit 1".to_string()),
},
AdUnit {
ipfs: IPFS::try_from("QmVhRDGXoM3Fg3HZD5xwMuxtb9ZErwC8wHt8CjsfxaiUbZ")
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/db/campaign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ mod campaign_remaining {
Ok(campaigns_remaining)
}

/// This method will get the remaining of the provided [`Campaign`]s
/// This method will get the remaining of the provided [`Campaign`](primitives::Campaign)s
/// and it will also match the returned values to the [`CampaignId`]s
/// `MGET` should always return results in the same order!
pub async fn get_multiple_with_ids(
Expand Down
47 changes: 36 additions & 11 deletions sentry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,15 @@ pub struct Auth {

#[cfg(test)]
pub mod test_util {
use std::ops;

use adapter::{
dummy::{Dummy, Options},
Adapter,
};
use primitives::{
config::GANACHE_CONFIG,
test_util::{discard_logger, CREATOR, FOLLOWER, IDS, LEADER},
test_util::{discard_logger, DUMMY_AUTH, IDS, LEADER},
};

use crate::{
Expand All @@ -510,19 +512,38 @@ pub mod test_util {
Application,
};

/// This guard holds the Redis and Postgres pools taken from their respective Pool of pools.
///
/// This ensures that they will not be dropped which will cause tests to fail randomly.
pub struct ApplicationGuard {
pub app: Application<Dummy>,
#[allow(dead_code)]
redis_pool: deadpool::managed::Object<crate::db::redis_pool::Manager>,
#[allow(dead_code)]
db_pool: deadpool::managed::Object<crate::db::tests_postgres::Manager>,
Comment on lines +521 to +523
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the Object was getting dropped tests failed randomly.
Object hold the Pool of Pools, so we must hold these values until the Application struct get drop itself

}

impl ops::Deref for ApplicationGuard {
type Target = Application<Dummy>;

fn deref(&self) -> &Self::Target {
&self.app
}
}
impl ops::DerefMut for ApplicationGuard {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.app
}
}

/// Uses development and therefore the goerli testnet addresses of the tokens
/// It still uses DummyAdapter.
pub async fn setup_dummy_app() -> Application<Dummy> {
/// but still uses the `DummyAdapter`.
pub async fn setup_dummy_app() -> ApplicationGuard {
let config = GANACHE_CONFIG.clone();

let adapter = Adapter::new(Dummy::init(Options {
dummy_identity: IDS[&LEADER],
dummy_auth_tokens: vec![
(*CREATOR, "AUTH_Creator".into()),
(*LEADER, "AUTH_Leader".into()),
(*FOLLOWER, "AUTH_Follower".into()),
]
.into_iter()
.collect(),
dummy_auth_tokens: DUMMY_AUTH.clone(),
}));

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

app
ApplicationGuard {
app,
redis_pool: redis,
db_pool: database,
}
}
}
Loading