@@ -163,7 +163,7 @@ pub fn get_unit_html_with_events(
163
163
. iter ( )
164
164
. map ( |validator| {
165
165
let fetch_url = format ! (
166
- "{}/campaign/{}/events?pubAddr={}" ,
166
+ "{}/v5/ campaign/{}/events?pubAddr={}" ,
167
167
validator. url, campaign_id, options. publisher_addr
168
168
) ;
169
169
@@ -201,12 +201,13 @@ pub fn get_unit_html_with_events(
201
201
#[ cfg( test) ]
202
202
mod test {
203
203
use super :: * ;
204
- use crate :: manager:: DEFAULT_TOKENS ;
205
204
use adex_primitives:: {
205
+ config:: GANACHE_CONFIG ,
206
206
test_util:: { DUMMY_CAMPAIGN , DUMMY_IPFS , PUBLISHER } ,
207
207
util:: ApiUrl ,
208
208
} ;
209
209
use scraper:: { Html , Selector } ;
210
+ use std:: collections:: HashSet ;
210
211
211
212
fn get_ad_unit ( media_mime : & str ) -> AdUnit {
212
213
AdUnit {
@@ -354,7 +355,11 @@ mod test {
354
355
355
356
#[ test]
356
357
fn getting_unit_html_with_events ( ) {
357
- let whitelisted_tokens = DEFAULT_TOKENS . clone ( ) ;
358
+ let whitelisted_tokens = GANACHE_CONFIG
359
+ . chains
360
+ . values ( )
361
+ . flat_map ( |chain| chain. tokens . values ( ) . map ( |token| token. address ) )
362
+ . collect :: < HashSet < _ > > ( ) ;
358
363
359
364
let market_url = ApiUrl :: parse ( "https://market.adex.network" ) . expect ( "should parse" ) ;
360
365
let validator_1_url = ApiUrl :: parse ( "https://tom.adex.network" ) . expect ( "should parse" ) ;
@@ -403,11 +408,10 @@ mod test {
403
408
. next ( )
404
409
. expect ( "There should be a video" ) ;
405
410
406
- // TODO: If campaign.validators doesn't guarantee order this might fail and become untestable
407
- let expected_onclick: & str = & format ! ( "var fetchOpts = {{ method: 'POST', headers: {{ 'content-type': 'application/json' }}, body: {{'events':[{{'type':'CLICK','publisher':'{}','adUnit':'{}','adSlot':'{}','referrer':'document.referrer'}}]}} }}; fetch('{}/campaign/{}/events?pubAddr={}', fetchOpts); fetch('{}/campaign/{}/events?pubAddr={}', fetchOpts)" , options. publisher_addr, ad_unit. ipfs, options. market_slot, validators. iter( ) . nth( 0 ) . unwrap( ) . url, campaign_id, options. publisher_addr, validators. iter( ) . nth( 1 ) . unwrap( ) . url, campaign_id, options. publisher_addr) ;
411
+ let expected_onclick: & str = & format ! ( "var fetchOpts = {{ method: 'POST', headers: {{ 'content-type': 'application/json' }}, body: {{'events':[{{'type':'CLICK','publisher':'{}','adUnit':'{}','adSlot':'{}','referrer':'document.referrer'}}]}} }}; fetch('{}/v5/campaign/{}/events?pubAddr={}', fetchOpts); fetch('{}/v5/campaign/{}/events?pubAddr={}', fetchOpts)" , options. publisher_addr, ad_unit. ipfs, options. market_slot, validators[ 0 ] . url, campaign_id, options. publisher_addr, validators[ 1 ] . url, campaign_id, options. publisher_addr) ;
408
412
assert_eq ! ( Some ( expected_onclick) , anchor. value( ) . attr( "onclick" ) ) ;
409
413
410
- let expected_onloadeddata: & str = & format ! ( "setTimeout(function() {{ var fetchOpts = {{ method: 'POST', headers: {{ 'content-type': 'application/json' }}, body: {{'events':[{{'type':'IMPRESSION','publisher':'{}','adUnit':'{}','adSlot':'{}','referrer':'document.referrer'}}]}} }}; fetch('{}/campaign/{}/events?pubAddr={}', fetchOpts); fetch('{}/campaign/{}/events?pubAddr={}', fetchOpts) }}, 8000)" , options. publisher_addr, ad_unit. ipfs, options. market_slot, validators. iter ( ) . nth ( 0 ) . unwrap ( ) . url, campaign_id, options. publisher_addr, validators. iter ( ) . nth ( 1 ) . unwrap ( ) . url, campaign_id, options. publisher_addr) ;
414
+ let expected_onloadeddata: & str = & format ! ( "setTimeout(function() {{ var fetchOpts = {{ method: 'POST', headers: {{ 'content-type': 'application/json' }}, body: {{'events':[{{'type':'IMPRESSION','publisher':'{}','adUnit':'{}','adSlot':'{}','referrer':'document.referrer'}}]}} }}; fetch('{}/v5/ campaign/{}/events?pubAddr={}', fetchOpts); fetch('{}/v5/ campaign/{}/events?pubAddr={}', fetchOpts) }}, 8000)" , options. publisher_addr, ad_unit. ipfs, options. market_slot, validators[ 0 ] . url, campaign_id, options. publisher_addr, validators[ 1 ] . url, campaign_id, options. publisher_addr) ;
411
415
assert_eq ! (
412
416
Some ( expected_onloadeddata) ,
413
417
video. value( ) . attr( "onloadeddata" )
0 commit comments