@@ -395,57 +395,45 @@ impl TestState {
395395 ) ;
396396 finished_steps. got_scraping_information = true ;
397397 tx. send ( Ok ( 0 ) ) . unwrap ( ) ;
398-
399- // If the activated block number is > 1 the scraper will ask for block ancestors. Handle this case.
400- if block_number > 1 {
401- assert_matches ! (
402- overseer_recv( virtual_overseer) . await ,
403- AllMessages :: ChainApi ( ChainApiMessage :: Ancestors {
404- hash,
405- k,
406- response_channel,
407- } ) => {
408- assert_eq!( hash, block_hash) ; // A bit restrictive, remove if it causes problems.
409- let target_header = self . headers. get( & hash) . expect( "The function is called for this block so it should exist" ) ;
410- let mut response = Vec :: new( ) ;
411- for i in target_header. number. saturating_sub( k as u32 ) ..target_header. number {
412- response. push( self . block_num_to_header. get( & i) . expect( "headers and block_num_to_header should always be in sync" ) . clone( ) ) ;
413- }
414- let _ = response_channel. send( Ok ( response) ) ;
415- }
416- ) ;
417- }
418-
419- assert_matches ! (
420- overseer_recv( virtual_overseer) . await ,
421- AllMessages :: RuntimeApi ( RuntimeApiMessage :: Request (
422- _new_leaf,
423- RuntimeApiRequest :: CandidateEvents ( tx) ,
424- ) ) => {
425- tx. send( Ok ( candidate_events. clone( ) ) ) . unwrap( ) ;
426- }
427- ) ;
428- gum:: trace!( "After answering runtime api request" ) ;
429- assert_matches ! (
430- overseer_recv( virtual_overseer) . await ,
431- AllMessages :: RuntimeApi ( RuntimeApiMessage :: Request (
432- _new_leaf,
433- RuntimeApiRequest :: FetchOnChainVotes ( tx) ,
434- ) ) => {
435- //add some `BackedCandidates` or resolved disputes here as needed
436- tx. send( Ok ( Some ( ScrapedOnChainVotes {
437- session,
438- backing_validators_per_candidate: Vec :: default ( ) ,
439- disputes: MultiDisputeStatementSet :: default ( ) ,
440- } ) ) ) . unwrap( ) ;
441- }
442- ) ;
443- gum:: trace!( "After answering runtime API request (votes)" ) ;
444398 } ,
445399 AllMessages :: ChainApi ( ChainApiMessage :: BlockNumber ( hash, tx) ) => {
446400 let block_num = self . headers . get ( & hash) . map ( |header| header. number ) ;
447401 tx. send ( Ok ( block_num) ) . unwrap ( ) ;
448402 } ,
403+ AllMessages :: RuntimeApi ( RuntimeApiMessage :: Request (
404+ _new_leaf,
405+ RuntimeApiRequest :: CandidateEvents ( tx) ,
406+ ) ) => {
407+ tx. send ( Ok ( candidate_events. clone ( ) ) ) . unwrap ( ) ;
408+ } ,
409+ AllMessages :: RuntimeApi ( RuntimeApiMessage :: Request (
410+ _new_leaf,
411+ RuntimeApiRequest :: FetchOnChainVotes ( tx) ,
412+ ) ) => {
413+ //add some `BackedCandidates` or resolved disputes here as needed
414+ tx. send ( Ok ( Some ( ScrapedOnChainVotes {
415+ session,
416+ backing_validators_per_candidate : Vec :: default ( ) ,
417+ disputes : MultiDisputeStatementSet :: default ( ) ,
418+ } ) ) )
419+ . unwrap ( ) ;
420+ } ,
421+ AllMessages :: ChainApi ( ChainApiMessage :: Ancestors { hash, k, response_channel } ) => {
422+ let target_header = self
423+ . headers
424+ . get ( & hash)
425+ . expect ( "The function is called for this block so it should exist" ) ;
426+ let mut response = Vec :: new ( ) ;
427+ for i in target_header. number . saturating_sub ( k as u32 ) ..target_header. number {
428+ response. push (
429+ self . block_num_to_header
430+ . get ( & i)
431+ . expect ( "headers and block_num_to_header should always be in sync" )
432+ . clone ( ) ,
433+ ) ;
434+ }
435+ let _ = response_channel. send ( Ok ( response) ) ;
436+ } ,
449437 msg => {
450438 panic ! ( "Received unexpected message in `handle_sync_queries`: {:?}" , msg) ;
451439 } ,
0 commit comments