File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,8 @@ use web3::types::{Log, Transaction};
2828use crate :: host_exports:: HostExports ;
2929use crate :: mapping:: { MappingContext , MappingRequest , MappingTrigger } ;
3030
31- pub ( crate ) const TIMEOUT_ENV_VAR : & str = "GRAPH_MAPPING_HANDLER_TIMEOUT" ;
32-
3331lazy_static ! {
34- pub static ref TIMEOUT : Option <Duration > = std:: env:: var( TIMEOUT_ENV_VAR )
32+ static ref TIMEOUT : Option <Duration > = std:: env:: var( "GRAPH_MAPPING_HANDLER_TIMEOUT" )
3533 . ok( )
3634 . map( |s| u64 :: from_str( & s) . expect( "Invalid value for GRAPH_MAPPING_HANDLER_TIMEOUT" ) )
3735 . map( Duration :: from_secs) ;
Original file line number Diff line number Diff line change @@ -27,6 +27,17 @@ fn test_valid_module_and_store(
2727) -> (
2828 WasmInstance ,
2929 Arc < impl Store + SubgraphDeploymentStore + EthereumCallCache > ,
30+ ) {
31+ test_valid_module_and_store_with_timeout ( subgraph_id, data_source, None )
32+ }
33+
34+ fn test_valid_module_and_store_with_timeout (
35+ subgraph_id : & str ,
36+ data_source : DataSource ,
37+ timeout : Option < Duration > ,
38+ ) -> (
39+ WasmInstance ,
40+ Arc < impl Store + SubgraphDeploymentStore + EthereumCallCache > ,
3041) {
3142 let store = STORE . clone ( ) ;
3243 let metrics_registry = Arc :: new ( MockMetricsRegistry :: new ( ) ) ;
@@ -59,7 +70,7 @@ fn test_valid_module_and_store(
5970 Arc :: new ( ValidModule :: new ( data_source. mapping . runtime . as_ref ( ) ) . unwrap ( ) ) ,
6071 mock_context ( deployment_id, data_source, store. clone ( ) ) ,
6172 host_metrics,
62- * crate :: host :: TIMEOUT ,
73+ timeout ,
6374 true ,
6475 )
6576 . unwrap ( ) ;
Original file line number Diff line number Diff line change 11use super :: * ;
2- use std:: env;
32
43#[ tokio:: test( threaded_scheduler) ]
54async fn unbounded_loop ( ) {
65 // Set handler timeout to 3 seconds.
7- env:: set_var ( crate :: host:: TIMEOUT_ENV_VAR , "3" ) ;
8- let module = test_module (
6+ let module = test_valid_module_and_store_with_timeout (
97 "unboundedLoop" ,
108 mock_data_source ( "wasm_test/non_terminating.wasm" ) ,
11- ) ;
9+ Some ( Duration :: from_secs ( 3 ) ) ,
10+ )
11+ . 0 ;
1212 let func = module. get_func ( "loop" ) . get0 ( ) . unwrap ( ) ;
1313 let res: Result < ( ) , _ > = func ( ) ;
1414 assert ! ( res. unwrap_err( ) . to_string( ) . contains( TRAP_TIMEOUT ) ) ;
You can’t perform that action at this time.
0 commit comments