11
11
12
12
use std:: future:: Future ;
13
13
use std:: pin:: Pin ;
14
- use std:: thread;
15
14
use std:: time:: { self , Duration , Instant } ;
16
15
17
16
use anyhow:: { anyhow, bail, Context , Result } ;
@@ -807,7 +806,7 @@ async fn test_remove_then_update(ctx: TestContext) -> anyhow::Result<()> {
807
806
}
808
807
809
808
async 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 > {
811
810
const FETCH_BLOCK_HASH : & str = r#"
812
811
query blockHashFromNumber($network: String!, $blockNumber: Int!) {
813
812
hash: blockHashFromNumber(
@@ -843,10 +842,10 @@ async fn test_subgraph_grafting(ctx: TestContext) -> anyhow::Result<()> {
843
842
] ;
844
843
845
844
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 ( ) ;
847
846
// 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.
850
849
assert_eq ! ( block_hash, block_hashes[ ( i - 1 ) as usize ] ) ;
851
850
852
851
const FETCH_POI : & str = r#"
@@ -1004,6 +1003,7 @@ async fn test_multiple_subgraph_datasources(ctx: TestContext) -> anyhow::Result<
1004
1003
async fn wait_for_blockchain_block ( block_number : i32 ) -> bool {
1005
1004
// Wait up to 5 minutes for the expected block to appear
1006
1005
const STATUS_WAIT : Duration = Duration :: from_secs ( 300 ) ;
1006
+ const REQUEST_REPEATING : Duration = time:: Duration :: from_secs ( 1 ) ;
1007
1007
let start = Instant :: now ( ) ;
1008
1008
while start. elapsed ( ) < STATUS_WAIT {
1009
1009
let latest_block = Contract :: latest_block ( ) . await ;
@@ -1014,8 +1014,7 @@ async fn wait_for_blockchain_block(block_number: i32) -> bool {
1014
1014
}
1015
1015
}
1016
1016
}
1017
- let one_sec = time:: Duration :: from_secs ( 1 ) ;
1018
- thread:: sleep ( one_sec) ;
1017
+ tokio:: time:: sleep ( REQUEST_REPEATING ) . await ;
1019
1018
}
1020
1019
false
1021
1020
}
0 commit comments