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};
28
28
use crate :: host_exports:: HostExports ;
29
29
use crate :: mapping:: { MappingContext , MappingRequest , MappingTrigger } ;
30
30
31
- pub ( crate ) const TIMEOUT_ENV_VAR : & str = "GRAPH_MAPPING_HANDLER_TIMEOUT" ;
32
-
33
31
lazy_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" )
35
33
. ok( )
36
34
. map( |s| u64 :: from_str( & s) . expect( "Invalid value for GRAPH_MAPPING_HANDLER_TIMEOUT" ) )
37
35
. map( Duration :: from_secs) ;
Original file line number Diff line number Diff line change @@ -27,6 +27,17 @@ fn test_valid_module_and_store(
27
27
) -> (
28
28
WasmInstance ,
29
29
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 > ,
30
41
) {
31
42
let store = STORE . clone ( ) ;
32
43
let metrics_registry = Arc :: new ( MockMetricsRegistry :: new ( ) ) ;
@@ -59,7 +70,7 @@ fn test_valid_module_and_store(
59
70
Arc :: new ( ValidModule :: new ( data_source. mapping . runtime . as_ref ( ) ) . unwrap ( ) ) ,
60
71
mock_context ( deployment_id, data_source, store. clone ( ) ) ,
61
72
host_metrics,
62
- * crate :: host :: TIMEOUT ,
73
+ timeout ,
63
74
true ,
64
75
)
65
76
. unwrap ( ) ;
Original file line number Diff line number Diff line change 1
1
use super :: * ;
2
- use std:: env;
3
2
4
3
#[ tokio:: test( threaded_scheduler) ]
5
4
async fn unbounded_loop ( ) {
6
5
// 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 (
9
7
"unboundedLoop" ,
10
8
mock_data_source ( "wasm_test/non_terminating.wasm" ) ,
11
- ) ;
9
+ Some ( Duration :: from_secs ( 3 ) ) ,
10
+ )
11
+ . 0 ;
12
12
let func = module. get_func ( "loop" ) . get0 ( ) . unwrap ( ) ;
13
13
let res: Result < ( ) , _ > = func ( ) ;
14
14
assert ! ( res. unwrap_err( ) . to_string( ) . contains( TRAP_TIMEOUT ) ) ;
You can’t perform that action at this time.
0 commit comments