@@ -2262,7 +2262,7 @@ mod tests {
2262
2262
let analytics = get_analytics (
2263
2263
& api_client,
2264
2264
& 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 ] ) ,
2266
2266
None ,
2267
2267
)
2268
2268
. await
@@ -2278,7 +2278,7 @@ mod tests {
2278
2278
let analytics = get_analytics (
2279
2279
& api_client,
2280
2280
& 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 ] ) ,
2282
2282
None ,
2283
2283
)
2284
2284
. await
@@ -2287,14 +2287,14 @@ mod tests {
2287
2287
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2288
2288
assert_eq ! (
2289
2289
analytics[ 0 ] . value,
2290
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 3_000_000 ) ) ,
2290
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.03 ) ) ,
2291
2291
"Channel Leader has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
2292
2292
) ;
2293
2293
2294
2294
let analytics = get_analytics (
2295
2295
& api_client,
2296
2296
& 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 ] ) ,
2298
2298
None ,
2299
2299
)
2300
2300
. await
@@ -2310,7 +2310,7 @@ mod tests {
2310
2310
let analytics = get_analytics (
2311
2311
& api_client,
2312
2312
& 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 ] ) ,
2314
2314
None ,
2315
2315
)
2316
2316
. await
@@ -2319,15 +2319,15 @@ mod tests {
2319
2319
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2320
2320
assert_eq ! (
2321
2321
analytics[ 0 ] . value,
2322
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 7_000_000 ) ) ,
2322
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.07 ) ) ,
2323
2323
"Channel Leader has 2 x CLICK (0.035) = 0.07 TOKENs"
2324
2324
) ;
2325
2325
2326
2326
// Follower
2327
2327
let analytics = get_analytics (
2328
2328
& api_client,
2329
2329
& 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 ] ) ,
2331
2331
None ,
2332
2332
)
2333
2333
. await
@@ -2343,7 +2343,7 @@ mod tests {
2343
2343
let analytics = get_analytics (
2344
2344
& api_client,
2345
2345
& 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 ] ) ,
2347
2347
None ,
2348
2348
)
2349
2349
. await
@@ -2352,14 +2352,14 @@ mod tests {
2352
2352
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2353
2353
assert_eq ! (
2354
2354
analytics[ 0 ] . value,
2355
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 3_000_000 ) ) ,
2355
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.03 ) ) ,
2356
2356
"Channel Follower has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
2357
2357
) ;
2358
2358
2359
2359
let analytics = get_analytics (
2360
2360
& api_client,
2361
2361
& 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 ] ) ,
2363
2363
None ,
2364
2364
)
2365
2365
. await
@@ -2375,7 +2375,7 @@ mod tests {
2375
2375
let analytics = get_analytics (
2376
2376
& api_client,
2377
2377
& 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 ] ) ,
2379
2379
None ,
2380
2380
)
2381
2381
. await
@@ -2384,7 +2384,7 @@ mod tests {
2384
2384
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2385
2385
assert_eq ! (
2386
2386
analytics[ 0 ] . value,
2387
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 7_000_000 ) ) ,
2387
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.07 ) ) ,
2388
2388
"Channel Follower has 2 x CLICK (0.035) = 0.07 TOKENs"
2389
2389
) ;
2390
2390
}
@@ -2397,7 +2397,7 @@ mod tests {
2397
2397
& get_analytics_query (
2398
2398
Metric :: Count ,
2399
2399
IMPRESSION ,
2400
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2400
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2401
2401
) ,
2402
2402
None ,
2403
2403
)
@@ -2417,7 +2417,7 @@ mod tests {
2417
2417
& get_analytics_query (
2418
2418
Metric :: Paid ,
2419
2419
IMPRESSION ,
2420
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2420
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2421
2421
) ,
2422
2422
None ,
2423
2423
)
@@ -2427,7 +2427,7 @@ mod tests {
2427
2427
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2428
2428
assert_eq ! (
2429
2429
analytics[ 0 ] . value,
2430
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 5_07_000_000 ) ) ,
2430
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 5.07 ) ) ,
2431
2431
"Channel Leader has 2 x IMPRESSION (0.015) + 1 x IMPRESSION (0.04) + 5 x IMPRESSION (1) = 5.07 TOKENs"
2432
2432
) ;
2433
2433
@@ -2437,7 +2437,7 @@ mod tests {
2437
2437
& get_analytics_query (
2438
2438
Metric :: Count ,
2439
2439
CLICK ,
2440
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2440
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2441
2441
) ,
2442
2442
None ,
2443
2443
)
@@ -2457,7 +2457,7 @@ mod tests {
2457
2457
& get_analytics_query (
2458
2458
Metric :: Paid ,
2459
2459
CLICK ,
2460
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2460
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2461
2461
) ,
2462
2462
None ,
2463
2463
)
@@ -2467,7 +2467,7 @@ mod tests {
2467
2467
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2468
2468
assert_eq ! (
2469
2469
analytics[ 0 ] . value,
2470
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 9_13_000_000 ) ) ,
2470
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 9.13 ) ) ,
2471
2471
"Channel Leader has 2 x CLICK (0.035) + 1 x CLICK (0.06) + 3 x CLICK (3) = 9.13 TOKENs"
2472
2472
) ;
2473
2473
@@ -2478,7 +2478,7 @@ mod tests {
2478
2478
& get_analytics_query (
2479
2479
Metric :: Count ,
2480
2480
IMPRESSION ,
2481
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2481
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2482
2482
) ,
2483
2483
None ,
2484
2484
)
@@ -2498,7 +2498,7 @@ mod tests {
2498
2498
& get_analytics_query (
2499
2499
Metric :: Paid ,
2500
2500
IMPRESSION ,
2501
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2501
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2502
2502
) ,
2503
2503
None ,
2504
2504
)
@@ -2508,7 +2508,7 @@ mod tests {
2508
2508
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2509
2509
assert_eq ! (
2510
2510
analytics[ 0 ] . value,
2511
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 5_07_000_000 ) ) ,
2511
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 5.07 ) ) ,
2512
2512
"Channel Follower has 2 x IMPRESSION (0.015) + 1 x IMPRESSION (0.04) + 5 x IMPRESSION (1) = 5.07 TOKENs"
2513
2513
) ;
2514
2514
@@ -2518,7 +2518,7 @@ mod tests {
2518
2518
& get_analytics_query (
2519
2519
Metric :: Count ,
2520
2520
CLICK ,
2521
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2521
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2522
2522
) ,
2523
2523
None ,
2524
2524
)
@@ -2538,7 +2538,7 @@ mod tests {
2538
2538
& get_analytics_query (
2539
2539
Metric :: Paid ,
2540
2540
CLICK ,
2541
- vec ! [ ChainId :: new ( 1 ) , ChainId :: new ( 1337 ) ] ,
2541
+ vec ! [ GANACHE_1 . chain_id , GANACHE_1337 . chain_id ] ,
2542
2542
) ,
2543
2543
None ,
2544
2544
)
@@ -2548,7 +2548,7 @@ mod tests {
2548
2548
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2549
2549
assert_eq ! (
2550
2550
analytics[ 0 ] . value,
2551
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 9_13_000_000 ) ) ,
2551
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 9.13 ) ) ,
2552
2552
"Channel Follower has 2 x CLICK (0.035) + 1 x CLICK (0.06) + 3 x CLICK (3) = 9.13 TOKENs"
2553
2553
) ;
2554
2554
}
@@ -2591,7 +2591,7 @@ mod tests {
2591
2591
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2592
2592
assert_eq ! (
2593
2593
analytics[ 0 ] . value,
2594
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 3_000_000 ) ) ,
2594
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.03 ) ) ,
2595
2595
"Channel Leader has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
2596
2596
) ;
2597
2597
@@ -2623,7 +2623,7 @@ mod tests {
2623
2623
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2624
2624
assert_eq ! (
2625
2625
analytics[ 0 ] . value,
2626
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 7_000_000 ) ) ,
2626
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.07 ) ) ,
2627
2627
"Channel Leader has 2 x CLICK (0.035) = 0.07 TOKENs"
2628
2628
) ;
2629
2629
@@ -2656,7 +2656,7 @@ mod tests {
2656
2656
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2657
2657
assert_eq ! (
2658
2658
analytics[ 0 ] . value,
2659
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 3_000_000 ) ) ,
2659
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.03 ) ) ,
2660
2660
"Channel Follower has 2 x IMPRESSION (0.015) = 0.03 TOKENs"
2661
2661
) ;
2662
2662
@@ -2688,7 +2688,7 @@ mod tests {
2688
2688
assert_eq ! ( analytics. len( ) , 1 , "There should be only one timeframe" ) ;
2689
2689
assert_eq ! (
2690
2690
analytics[ 0 ] . value,
2691
- FetchedMetric :: Paid ( UnifiedNum :: from_u64 ( 7_000_000 ) ) ,
2691
+ FetchedMetric :: Paid ( UnifiedNum :: from_whole ( 0.07 ) ) ,
2692
2692
"Channel Follower has 2 x CLICK (0.035) = 0.07 TOKENs"
2693
2693
) ;
2694
2694
}
@@ -2783,37 +2783,27 @@ mod tests {
2783
2783
token : Option < String > ,
2784
2784
) -> anyhow:: Result < Vec < FetchedAnalytics > > {
2785
2785
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" ) ;
2787
2789
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" ) ,
2817
2807
} ;
2818
2808
2819
2809
Ok ( analytics)
0 commit comments