@@ -5,6 +5,7 @@ use graph::components::store::*;
55use graph:: data:: store:: { scalar, Id , IdType } ;
66use graph:: data:: subgraph:: * ;
77use graph:: data:: value:: Word ;
8+ use graph:: futures03:: future:: BoxFuture ;
89use graph:: ipfs:: test_utils:: add_files_to_local_ipfs_node_for_testing;
910use graph:: prelude:: alloy:: primitives:: U256 ;
1011use graph:: runtime:: gas:: GasCounter ;
@@ -52,70 +53,74 @@ async fn test_module_and_deployment(
5253 test_module_and_deployment_with_timeout ( subgraph_id, data_source, api_version, None ) . await
5354}
5455
55- async fn test_module_and_deployment_with_timeout (
56- subgraph_id : & str ,
56+ fn test_module_and_deployment_with_timeout < ' a > (
57+ subgraph_id : & ' a str ,
5758 data_source : DataSource ,
5859 api_version : Version ,
5960 timeout : Option < Duration > ,
60- ) -> ( WasmInstance , DeploymentLocator ) {
61- let logger = Logger :: root ( slog:: Discard , o ! ( ) ) ;
62- let subgraph_id_with_api_version =
63- subgraph_id_with_api_version ( subgraph_id, api_version. clone ( ) ) ;
64-
65- let store = STORE . clone ( ) ;
66- let metrics_registry = Arc :: new ( MetricsRegistry :: mock ( ) ) ;
67- let deployment_id = DeploymentHash :: new ( & subgraph_id_with_api_version) . unwrap ( ) ;
68- let deployment = test_store:: create_test_subgraph (
69- & deployment_id,
70- "type User @entity {
71- id: ID!,
72- name: String,
73- count: BigInt,
74- }
61+ ) -> BoxFuture < ' a , ( WasmInstance , DeploymentLocator ) > {
62+ Box :: pin ( async move {
63+ let logger = Logger :: root ( slog:: Discard , o ! ( ) ) ;
64+ let subgraph_id_with_api_version =
65+ subgraph_id_with_api_version ( subgraph_id, api_version. clone ( ) ) ;
7566
76- type Thing @entity {
77- id: ID!,
78- value: String,
79- extra: String
80- }" ,
81- )
82- . await ;
83- let stopwatch = StopwatchMetrics :: new (
84- logger. clone ( ) ,
85- deployment_id. clone ( ) ,
86- "test" ,
87- metrics_registry. clone ( ) ,
88- "test_shard" . to_string ( ) ,
89- ) ;
67+ let store = STORE . clone ( ) ;
68+ let metrics_registry = Arc :: new ( MetricsRegistry :: mock ( ) ) ;
69+ let deployment_id = DeploymentHash :: new ( & subgraph_id_with_api_version) . unwrap ( ) ;
70+ let deployment = test_store:: create_test_subgraph (
71+ & deployment_id,
72+ "type User @entity {
73+ id: ID!,
74+ name: String,
75+ count: BigInt,
76+ }
77+
78+ type Thing @entity {
79+ id: ID!,
80+ value: String,
81+ extra: String
82+ }" ,
83+ )
84+ . await ;
85+ let stopwatch = StopwatchMetrics :: new (
86+ logger. clone ( ) ,
87+ deployment_id. clone ( ) ,
88+ "test" ,
89+ metrics_registry. clone ( ) ,
90+ "test_shard" . to_string ( ) ,
91+ ) ;
9092
91- let gas_metrics = GasMetrics :: new ( deployment_id. clone ( ) , metrics_registry. clone ( ) ) ;
93+ let gas_metrics = GasMetrics :: new ( deployment_id. clone ( ) , metrics_registry. clone ( ) ) ;
9294
93- let host_metrics = Arc :: new ( HostMetrics :: new (
94- metrics_registry,
95- deployment_id. as_str ( ) ,
96- stopwatch. cheap_clone ( ) ,
97- gas_metrics,
98- ) ) ;
95+ let host_metrics = Arc :: new ( HostMetrics :: new (
96+ metrics_registry,
97+ deployment_id. as_str ( ) ,
98+ stopwatch. cheap_clone ( ) ,
99+ gas_metrics,
100+ ) ) ;
99101
100- let experimental_features = ExperimentalFeatures {
101- allow_non_deterministic_ipfs : true ,
102- } ;
102+ let experimental_features = ExperimentalFeatures {
103+ allow_non_deterministic_ipfs : true ,
104+ } ;
103105
104- let module = WasmInstance :: from_valid_module_with_ctx (
105- Arc :: new ( ValidModule :: new ( & logger, data_source. mapping . runtime . as_ref ( ) , timeout) . unwrap ( ) ) ,
106- mock_context (
107- deployment. clone ( ) ,
108- data_source,
109- store. subgraph_store ( ) ,
110- api_version,
111- ) ,
112- host_metrics,
113- experimental_features,
114- )
115- . await
116- . unwrap ( ) ;
106+ let module = WasmInstance :: from_valid_module_with_ctx (
107+ Arc :: new (
108+ ValidModule :: new ( & logger, data_source. mapping . runtime . as_ref ( ) , timeout) . unwrap ( ) ,
109+ ) ,
110+ mock_context (
111+ deployment. clone ( ) ,
112+ data_source,
113+ store. subgraph_store ( ) ,
114+ api_version,
115+ ) ,
116+ host_metrics,
117+ experimental_features,
118+ )
119+ . await
120+ . unwrap ( ) ;
117121
118- ( module, deployment)
122+ ( module, deployment)
123+ } )
119124}
120125
121126pub async fn test_module (
0 commit comments