@@ -20,7 +20,7 @@ use graph_runtime_wasm::{
2020use semver:: Version ;
2121use std:: collections:: { BTreeMap , HashMap } ;
2222use std:: str:: FromStr ;
23- use test_store:: { LOGGER , STORE } ;
23+ use test_store:: { LOGGER , STOPWATCH , STORE , SUBGRAPH_STORE } ;
2424use wasmtime:: { AsContext , AsContextMut } ;
2525
2626use crate :: common:: { mock_context, mock_data_source} ;
@@ -44,20 +44,20 @@ fn subgraph_id_with_api_version(subgraph_id: &str, api_version: Version) -> Stri
4444 )
4545}
4646
47- async fn test_valid_module_and_store (
47+ async fn test_module_and_deployment (
4848 subgraph_id : & str ,
4949 data_source : DataSource ,
5050 api_version : Version ,
51- ) -> ( WasmInstance , Arc < impl SubgraphStore > , DeploymentLocator ) {
52- test_valid_module_and_store_with_timeout ( subgraph_id, data_source, api_version, None ) . await
51+ ) -> ( WasmInstance , DeploymentLocator ) {
52+ test_module_and_deployment_with_timeout ( subgraph_id, data_source, api_version, None ) . await
5353}
5454
55- async fn test_valid_module_and_store_with_timeout (
55+ async fn test_module_and_deployment_with_timeout (
5656 subgraph_id : & str ,
5757 data_source : DataSource ,
5858 api_version : Version ,
5959 timeout : Option < Duration > ,
60- ) -> ( WasmInstance , Arc < impl SubgraphStore > , DeploymentLocator ) {
60+ ) -> ( WasmInstance , DeploymentLocator ) {
6161 let logger = Logger :: root ( slog:: Discard , o ! ( ) ) ;
6262 let subgraph_id_with_api_version =
6363 subgraph_id_with_api_version ( subgraph_id, api_version. clone ( ) ) ;
@@ -80,7 +80,7 @@ async fn test_valid_module_and_store_with_timeout(
8080 }" ,
8181 )
8282 . await ;
83- let stopwatch_metrics = StopwatchMetrics :: new (
83+ let stopwatch = StopwatchMetrics :: new (
8484 logger. clone ( ) ,
8585 deployment_id. clone ( ) ,
8686 "test" ,
@@ -93,7 +93,7 @@ async fn test_valid_module_and_store_with_timeout(
9393 let host_metrics = Arc :: new ( HostMetrics :: new (
9494 metrics_registry,
9595 deployment_id. as_str ( ) ,
96- stopwatch_metrics ,
96+ stopwatch . cheap_clone ( ) ,
9797 gas_metrics,
9898 ) ) ;
9999
@@ -115,15 +115,15 @@ async fn test_valid_module_and_store_with_timeout(
115115 . await
116116 . unwrap ( ) ;
117117
118- ( module, store . subgraph_store ( ) , deployment)
118+ ( module, deployment)
119119}
120120
121121pub async fn test_module (
122122 subgraph_id : & str ,
123123 data_source : DataSource ,
124124 api_version : Version ,
125125) -> WasmInstance {
126- test_valid_module_and_store ( subgraph_id, data_source, api_version)
126+ test_module_and_deployment ( subgraph_id, data_source, api_version)
127127 . await
128128 . 0
129129}
@@ -135,9 +135,7 @@ pub async fn test_module_latest(subgraph_id: &str, wasm_file: &str) -> WasmInsta
135135 & wasm_file_path ( wasm_file, API_VERSION_0_0_5 ) ,
136136 version. clone ( ) ,
137137 ) ;
138- test_valid_module_and_store ( subgraph_id, ds, version)
139- . await
140- . 0
138+ test_module_and_deployment ( subgraph_id, ds, version) . await . 0
141139}
142140
143141pub trait SyncWasmTy : wasmtime:: WasmTy + Sync { }
@@ -529,7 +527,7 @@ async fn run_ipfs_map(
529527 . to_owned ( )
530528 } ;
531529
532- let ( mut instance, _ , _ ) = test_valid_module_and_store (
530+ let mut instance = test_module (
533531 subgraph_id,
534532 mock_data_source (
535533 & wasm_file_path ( "ipfs_map.wasm" , api_version. clone ( ) ) ,
@@ -557,7 +555,7 @@ async fn run_ipfs_map(
557555 . take_ctx ( )
558556 . take_state ( )
559557 . entity_cache
560- . as_modifications ( 0 )
558+ . as_modifications ( 0 , & STOPWATCH )
561559 . await ?
562560 . modifications ;
563561
@@ -1008,7 +1006,8 @@ async fn ens_name_by_hash_v0_0_5() {
10081006}
10091007
10101008async fn test_entity_store ( api_version : Version ) {
1011- let ( mut instance, store, deployment) = test_valid_module_and_store (
1009+ let store = SUBGRAPH_STORE . clone ( ) ;
1010+ let ( mut instance, deployment) = test_module_and_deployment (
10121011 "entityStore" ,
10131012 mock_data_source (
10141013 & wasm_file_path ( "store.wasm" , api_version. clone ( ) ) ,
@@ -1073,7 +1072,11 @@ async fn test_entity_store(api_version: Version) {
10731072 & mut ctx. ctx . state . entity_cache ,
10741073 EntityCache :: new ( Arc :: new ( writable. clone ( ) ) ) ,
10751074 ) ;
1076- let mut mods = cache. as_modifications ( 0 ) . await . unwrap ( ) . modifications ;
1075+ let mut mods = cache
1076+ . as_modifications ( 0 , & STOPWATCH )
1077+ . await
1078+ . unwrap ( )
1079+ . modifications ;
10771080 assert_eq ! ( 1 , mods. len( ) ) ;
10781081 match mods. pop ( ) . unwrap ( ) {
10791082 EntityModification :: Overwrite { data, .. } => {
@@ -1093,7 +1096,7 @@ async fn test_entity_store(api_version: Version) {
10931096 . take_ctx ( )
10941097 . take_state ( )
10951098 . entity_cache
1096- . as_modifications ( 0 )
1099+ . as_modifications ( 0 , & STOPWATCH )
10971100 . await
10981101 . unwrap ( )
10991102 . modifications ;
@@ -1626,7 +1629,7 @@ async fn generate_id() {
16261629
16271630 let entity_cache = host. ctx . state . entity_cache ;
16281631 let mods = entity_cache
1629- . as_modifications ( 12 )
1632+ . as_modifications ( 12 , & STOPWATCH )
16301633 . await
16311634 . unwrap ( )
16321635 . modifications ;
0 commit comments