1111
1212use std:: future:: Future ;
1313use std:: pin:: Pin ;
14- use std:: thread;
1514use std:: time:: { self , Duration , Instant } ;
1615
1716use anyhow:: { anyhow, bail, Context , Result } ;
@@ -807,7 +806,7 @@ async fn test_remove_then_update(ctx: TestContext) -> anyhow::Result<()> {
807806}
808807
809808async fn test_subgraph_grafting ( ctx : TestContext ) -> anyhow:: Result < ( ) > {
810- async fn get_bloock_hash ( block_number : i32 ) -> Option < String > {
809+ async fn get_block_hash ( block_number : i32 ) -> Option < String > {
811810 const FETCH_BLOCK_HASH : & str = r#"
812811 query blockHashFromNumber($network: String!, $blockNumber: Int!) {
813812 hash: blockHashFromNumber(
@@ -843,10 +842,10 @@ async fn test_subgraph_grafting(ctx: TestContext) -> anyhow::Result<()> {
843842 ] ;
844843
845844 for i in 1 ..4 {
846- let block_hash = get_bloock_hash ( i) . await . unwrap ( ) ;
845+ let block_hash = get_block_hash ( i) . await . unwrap ( ) ;
847846 // We need to make sure that the preconditions for POI are fulfiled
848- // namely that the anvil produces the proper block hashes for the
849- // blocks of which we will check the POI
847+ // namely that the blockchain produced the proper block hashes for the
848+ // blocks of which we will check the POI.
850849 assert_eq ! ( block_hash, block_hashes[ ( i - 1 ) as usize ] ) ;
851850
852851 const FETCH_POI : & str = r#"
@@ -1004,6 +1003,7 @@ async fn test_multiple_subgraph_datasources(ctx: TestContext) -> anyhow::Result<
10041003async fn wait_for_blockchain_block ( block_number : i32 ) -> bool {
10051004 // Wait up to 5 minutes for the expected block to appear
10061005 const STATUS_WAIT : Duration = Duration :: from_secs ( 300 ) ;
1006+ const REQUEST_REPEATING : Duration = time:: Duration :: from_secs ( 1 ) ;
10071007 let start = Instant :: now ( ) ;
10081008 while start. elapsed ( ) < STATUS_WAIT {
10091009 let latest_block = Contract :: latest_block ( ) . await ;
@@ -1014,8 +1014,7 @@ async fn wait_for_blockchain_block(block_number: i32) -> bool {
10141014 }
10151015 }
10161016 }
1017- let one_sec = time:: Duration :: from_secs ( 1 ) ;
1018- thread:: sleep ( one_sec) ;
1017+ tokio:: time:: sleep ( REQUEST_REPEATING ) . await ;
10191018 }
10201019 false
10211020}
0 commit comments