Skip to content

Commit b8c5396

Browse files
committed
changes requested from PR
1 parent 608fa3e commit b8c5396

File tree

1 file changed

+48
-58
lines changed

1 file changed

+48
-58
lines changed

test_harness/src/lib.rs

Lines changed: 48 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ mod tests {
22622262
let analytics = get_analytics(
22632263
&api_client,
22642264
&leader.sentry_url,
2265-
&get_analytics_query(Metric::Count, IMPRESSION, vec![ChainId::new(1)]),
2265+
&get_analytics_query(Metric::Count, IMPRESSION, vec![GANACHE_1.chain_id]),
22662266
None,
22672267
)
22682268
.await
@@ -2278,7 +2278,7 @@ mod tests {
22782278
let analytics = get_analytics(
22792279
&api_client,
22802280
&leader.sentry_url,
2281-
&get_analytics_query(Metric::Paid, IMPRESSION, vec![ChainId::new(1)]),
2281+
&get_analytics_query(Metric::Paid, IMPRESSION, vec![GANACHE_1.chain_id]),
22822282
None,
22832283
)
22842284
.await
@@ -2287,14 +2287,14 @@ mod tests {
22872287
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
22882288
assert_eq!(
22892289
analytics[0].value,
2290-
FetchedMetric::Paid(UnifiedNum::from_u64(3_000_000)),
2290+
FetchedMetric::Paid(UnifiedNum::from_whole(0.03)),
22912291
"Channel Leader has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
22922292
);
22932293

22942294
let analytics = get_analytics(
22952295
&api_client,
22962296
&leader.sentry_url,
2297-
&get_analytics_query(Metric::Count, CLICK, vec![ChainId::new(1)]),
2297+
&get_analytics_query(Metric::Count, CLICK, vec![GANACHE_1.chain_id]),
22982298
None,
22992299
)
23002300
.await
@@ -2310,7 +2310,7 @@ mod tests {
23102310
let analytics = get_analytics(
23112311
&api_client,
23122312
&leader.sentry_url,
2313-
&get_analytics_query(Metric::Paid, CLICK, vec![ChainId::new(1)]),
2313+
&get_analytics_query(Metric::Paid, CLICK, vec![GANACHE_1.chain_id]),
23142314
None,
23152315
)
23162316
.await
@@ -2319,15 +2319,15 @@ mod tests {
23192319
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
23202320
assert_eq!(
23212321
analytics[0].value,
2322-
FetchedMetric::Paid(UnifiedNum::from_u64(7_000_000)),
2322+
FetchedMetric::Paid(UnifiedNum::from_whole(0.07)),
23232323
"Channel Leader has 2 x CLICK (0.035) = 0.07 TOKENs"
23242324
);
23252325

23262326
// Follower
23272327
let analytics = get_analytics(
23282328
&api_client,
23292329
&follower.sentry_url,
2330-
&get_analytics_query(Metric::Count, IMPRESSION, vec![ChainId::new(1)]),
2330+
&get_analytics_query(Metric::Count, IMPRESSION, vec![GANACHE_1.chain_id]),
23312331
None,
23322332
)
23332333
.await
@@ -2343,7 +2343,7 @@ mod tests {
23432343
let analytics = get_analytics(
23442344
&api_client,
23452345
&follower.sentry_url,
2346-
&get_analytics_query(Metric::Paid, IMPRESSION, vec![ChainId::new(1)]),
2346+
&get_analytics_query(Metric::Paid, IMPRESSION, vec![GANACHE_1.chain_id]),
23472347
None,
23482348
)
23492349
.await
@@ -2352,14 +2352,14 @@ mod tests {
23522352
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
23532353
assert_eq!(
23542354
analytics[0].value,
2355-
FetchedMetric::Paid(UnifiedNum::from_u64(3_000_000)),
2355+
FetchedMetric::Paid(UnifiedNum::from_whole(0.03)),
23562356
"Channel Follower has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
23572357
);
23582358

23592359
let analytics = get_analytics(
23602360
&api_client,
23612361
&follower.sentry_url,
2362-
&get_analytics_query(Metric::Count, CLICK, vec![ChainId::new(1)]),
2362+
&get_analytics_query(Metric::Count, CLICK, vec![GANACHE_1.chain_id]),
23632363
None,
23642364
)
23652365
.await
@@ -2375,7 +2375,7 @@ mod tests {
23752375
let analytics = get_analytics(
23762376
&api_client,
23772377
&follower.sentry_url,
2378-
&get_analytics_query(Metric::Paid, CLICK, vec![ChainId::new(1)]),
2378+
&get_analytics_query(Metric::Paid, CLICK, vec![GANACHE_1.chain_id]),
23792379
None,
23802380
)
23812381
.await
@@ -2384,7 +2384,7 @@ mod tests {
23842384
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
23852385
assert_eq!(
23862386
analytics[0].value,
2387-
FetchedMetric::Paid(UnifiedNum::from_u64(7_000_000)),
2387+
FetchedMetric::Paid(UnifiedNum::from_whole(0.07)),
23882388
"Channel Follower has 2 x CLICK (0.035) = 0.07 TOKENs"
23892389
);
23902390
}
@@ -2397,7 +2397,7 @@ mod tests {
23972397
&get_analytics_query(
23982398
Metric::Count,
23992399
IMPRESSION,
2400-
vec![ChainId::new(1), ChainId::new(1337)],
2400+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
24012401
),
24022402
None,
24032403
)
@@ -2417,7 +2417,7 @@ mod tests {
24172417
&get_analytics_query(
24182418
Metric::Paid,
24192419
IMPRESSION,
2420-
vec![ChainId::new(1), ChainId::new(1337)],
2420+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
24212421
),
24222422
None,
24232423
)
@@ -2427,7 +2427,7 @@ mod tests {
24272427
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
24282428
assert_eq!(
24292429
analytics[0].value,
2430-
FetchedMetric::Paid(UnifiedNum::from_u64(5_07_000_000)),
2430+
FetchedMetric::Paid(UnifiedNum::from_whole(5.07)),
24312431
"Channel Leader has 2 x IMPRESSION (0.015) + 1 x IMPRESSION (0.04) + 5 x IMPRESSION (1) = 5.07 TOKENs"
24322432
);
24332433

@@ -2437,7 +2437,7 @@ mod tests {
24372437
&get_analytics_query(
24382438
Metric::Count,
24392439
CLICK,
2440-
vec![ChainId::new(1), ChainId::new(1337)],
2440+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
24412441
),
24422442
None,
24432443
)
@@ -2457,7 +2457,7 @@ mod tests {
24572457
&get_analytics_query(
24582458
Metric::Paid,
24592459
CLICK,
2460-
vec![ChainId::new(1), ChainId::new(1337)],
2460+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
24612461
),
24622462
None,
24632463
)
@@ -2467,7 +2467,7 @@ mod tests {
24672467
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
24682468
assert_eq!(
24692469
analytics[0].value,
2470-
FetchedMetric::Paid(UnifiedNum::from_u64(9_13_000_000)),
2470+
FetchedMetric::Paid(UnifiedNum::from_whole(9.13)),
24712471
"Channel Leader has 2 x CLICK (0.035) + 1 x CLICK (0.06) + 3 x CLICK (3) = 9.13 TOKENs"
24722472
);
24732473

@@ -2478,7 +2478,7 @@ mod tests {
24782478
&get_analytics_query(
24792479
Metric::Count,
24802480
IMPRESSION,
2481-
vec![ChainId::new(1), ChainId::new(1337)],
2481+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
24822482
),
24832483
None,
24842484
)
@@ -2498,7 +2498,7 @@ mod tests {
24982498
&get_analytics_query(
24992499
Metric::Paid,
25002500
IMPRESSION,
2501-
vec![ChainId::new(1), ChainId::new(1337)],
2501+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
25022502
),
25032503
None,
25042504
)
@@ -2508,7 +2508,7 @@ mod tests {
25082508
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
25092509
assert_eq!(
25102510
analytics[0].value,
2511-
FetchedMetric::Paid(UnifiedNum::from_u64(5_07_000_000)),
2511+
FetchedMetric::Paid(UnifiedNum::from_whole(5.07)),
25122512
"Channel Follower has 2 x IMPRESSION (0.015) + 1 x IMPRESSION (0.04) + 5 x IMPRESSION (1) = 5.07 TOKENs"
25132513
);
25142514

@@ -2518,7 +2518,7 @@ mod tests {
25182518
&get_analytics_query(
25192519
Metric::Count,
25202520
CLICK,
2521-
vec![ChainId::new(1), ChainId::new(1337)],
2521+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
25222522
),
25232523
None,
25242524
)
@@ -2538,7 +2538,7 @@ mod tests {
25382538
&get_analytics_query(
25392539
Metric::Paid,
25402540
CLICK,
2541-
vec![ChainId::new(1), ChainId::new(1337)],
2541+
vec![GANACHE_1.chain_id, GANACHE_1337.chain_id],
25422542
),
25432543
None,
25442544
)
@@ -2548,7 +2548,7 @@ mod tests {
25482548
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
25492549
assert_eq!(
25502550
analytics[0].value,
2551-
FetchedMetric::Paid(UnifiedNum::from_u64(9_13_000_000)),
2551+
FetchedMetric::Paid(UnifiedNum::from_whole(9.13)),
25522552
"Channel Follower has 2 x CLICK (0.035) + 1 x CLICK (0.06) + 3 x CLICK (3) = 9.13 TOKENs"
25532553
);
25542554
}
@@ -2591,7 +2591,7 @@ mod tests {
25912591
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
25922592
assert_eq!(
25932593
analytics[0].value,
2594-
FetchedMetric::Paid(UnifiedNum::from_u64(3_000_000)),
2594+
FetchedMetric::Paid(UnifiedNum::from_whole(0.03)),
25952595
"Channel Leader has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
25962596
);
25972597

@@ -2623,7 +2623,7 @@ mod tests {
26232623
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
26242624
assert_eq!(
26252625
analytics[0].value,
2626-
FetchedMetric::Paid(UnifiedNum::from_u64(7_000_000)),
2626+
FetchedMetric::Paid(UnifiedNum::from_whole(0.07)),
26272627
"Channel Leader has 2 x CLICK (0.035) = 0.07 TOKENs"
26282628
);
26292629

@@ -2656,7 +2656,7 @@ mod tests {
26562656
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
26572657
assert_eq!(
26582658
analytics[0].value,
2659-
FetchedMetric::Paid(UnifiedNum::from_u64(3_000_000)),
2659+
FetchedMetric::Paid(UnifiedNum::from_whole(0.03)),
26602660
"Channel Follower has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
26612661
);
26622662

@@ -2688,7 +2688,7 @@ mod tests {
26882688
assert_eq!(analytics.len(), 1, "There should be only one timeframe");
26892689
assert_eq!(
26902690
analytics[0].value,
2691-
FetchedMetric::Paid(UnifiedNum::from_u64(7_000_000)),
2691+
FetchedMetric::Paid(UnifiedNum::from_whole(0.07)),
26922692
"Channel Follower has 2 x CLICK (0.035) = 0.07 TOKENs"
26932693
);
26942694
}
@@ -2783,37 +2783,27 @@ mod tests {
27832783
token: Option<String>,
27842784
) -> anyhow::Result<Vec<FetchedAnalytics>> {
27852785
let query = serde_qs::to_string(query).expect("should parse query");
2786-
2786+
let endpoint_url = url
2787+
.join(&format!("v5/analytics?{}", query))
2788+
.expect("valid endpoint");
27872789
let analytics = match token {
2788-
Some(token) => {
2789-
let endpoint_url = url
2790-
.join(&format!("v5/analytics/for-advertiser?{}", query))
2791-
.expect("valid endpoint");
2792-
2793-
api_client
2794-
.get(endpoint_url)
2795-
.bearer_auth(&token)
2796-
.send()
2797-
.await
2798-
.expect("failed to get analytics")
2799-
.json::<Vec<FetchedAnalytics>>()
2800-
.await
2801-
.expect("failed to get json")
2802-
}
2803-
None => {
2804-
let endpoint_url = url
2805-
.join(&format!("v5/analytics?{}", query))
2806-
.expect("valid endpoint");
2807-
2808-
api_client
2809-
.get(endpoint_url)
2810-
.send()
2811-
.await
2812-
.expect("failed to get analytics")
2813-
.json::<Vec<FetchedAnalytics>>()
2814-
.await
2815-
.expect("failed to get json")
2816-
}
2790+
Some(token) => api_client
2791+
.get(endpoint_url)
2792+
.bearer_auth(&token)
2793+
.send()
2794+
.await
2795+
.expect("failed to get analytics")
2796+
.json::<Vec<FetchedAnalytics>>()
2797+
.await
2798+
.expect("failed to get json"),
2799+
None => api_client
2800+
.get(endpoint_url)
2801+
.send()
2802+
.await
2803+
.expect("failed to get analytics")
2804+
.json::<Vec<FetchedAnalytics>>()
2805+
.await
2806+
.expect("failed to get json"),
28172807
};
28182808

28192809
Ok(analytics)

0 commit comments

Comments
 (0)