@@ -3,6 +3,7 @@ pub mod substreams;
3
3
4
4
use std:: collections:: { BTreeSet , HashMap } ;
5
5
use std:: marker:: PhantomData ;
6
+ use std:: path:: PathBuf ;
6
7
use std:: sync:: Mutex ;
7
8
use std:: time:: { Duration , Instant } ;
8
9
@@ -17,7 +18,9 @@ use graph::blockchain::{
17
18
TriggerFilterWrapper , TriggersAdapter , TriggersAdapterSelector ,
18
19
} ;
19
20
use graph:: cheap_clone:: CheapClone ;
20
- use graph:: components:: link_resolver:: { ArweaveClient , ArweaveResolver , FileSizeLimit } ;
21
+ use graph:: components:: link_resolver:: {
22
+ ArweaveClient , ArweaveResolver , FileLinkResolver , FileSizeLimit ,
23
+ } ;
21
24
use graph:: components:: metrics:: MetricsRegistry ;
22
25
use graph:: components:: network_provider:: ChainName ;
23
26
use graph:: components:: store:: { BlockStore , DeploymentLocator , EthereumCallCache , SourceableStore } ;
@@ -38,7 +41,7 @@ use graph::prelude::ethabi::ethereum_types::H256;
38
41
use graph:: prelude:: serde_json:: { self , json} ;
39
42
use graph:: prelude:: {
40
43
async_trait, lazy_static, q, r, ApiVersion , BigInt , BlockNumber , DeploymentHash ,
41
- GraphQlRunner as _, IpfsResolver , LoggerFactory , NodeId , QueryError ,
44
+ GraphQlRunner as _, IpfsResolver , LinkResolver , LoggerFactory , NodeId , QueryError ,
42
45
SubgraphAssignmentProvider , SubgraphCountMetric , SubgraphName , SubgraphRegistrar ,
43
46
SubgraphStore as _, SubgraphVersionSwitchingMode , TriggerProcessor ,
44
47
} ;
@@ -455,6 +458,38 @@ pub async fn setup<C: Blockchain>(
455
458
chain : & impl TestChainTrait < C > ,
456
459
graft_block : Option < BlockPtr > ,
457
460
env_vars : Option < EnvVars > ,
461
+ ) -> TestContext {
462
+ setup_inner ( test_info, stores, chain, graft_block, env_vars, None ) . await
463
+ }
464
+
465
+ pub async fn setup_with_file_link_resolver < C : Blockchain > (
466
+ test_info : & TestInfo ,
467
+ stores : & Stores ,
468
+ chain : & impl TestChainTrait < C > ,
469
+ graft_block : Option < BlockPtr > ,
470
+ env_vars : Option < EnvVars > ,
471
+ ) -> TestContext {
472
+ let mut base_dir = PathBuf :: from ( test_info. test_dir . clone ( ) ) ;
473
+ base_dir. push ( "build" ) ;
474
+ let link_resolver = Arc :: new ( FileLinkResolver :: with_base_dir ( base_dir) ) ;
475
+ setup_inner (
476
+ test_info,
477
+ stores,
478
+ chain,
479
+ graft_block,
480
+ env_vars,
481
+ Some ( link_resolver) ,
482
+ )
483
+ . await
484
+ }
485
+
486
+ pub async fn setup_inner < C : Blockchain > (
487
+ test_info : & TestInfo ,
488
+ stores : & Stores ,
489
+ chain : & impl TestChainTrait < C > ,
490
+ graft_block : Option < BlockPtr > ,
491
+ env_vars : Option < EnvVars > ,
492
+ link_resolver : Option < Arc < dyn LinkResolver > > ,
458
493
) -> TestContext {
459
494
let env_vars = Arc :: new ( match env_vars {
460
495
Some ( ev) => ev,
@@ -483,10 +518,13 @@ pub async fn setup<C: Blockchain>(
483
518
. unwrap ( ) ,
484
519
) ;
485
520
486
- let link_resolver = Arc :: new ( IpfsResolver :: new (
487
- ipfs_client. cheap_clone ( ) ,
488
- Default :: default ( ) ,
489
- ) ) ;
521
+ let link_resolver = match link_resolver {
522
+ Some ( link_resolver) => link_resolver,
523
+ None => Arc :: new ( IpfsResolver :: new (
524
+ ipfs_client. cheap_clone ( ) ,
525
+ Default :: default ( ) ,
526
+ ) ) ,
527
+ } ;
490
528
491
529
let ipfs_service = ipfs_service (
492
530
ipfs_client. cheap_clone ( ) ,
0 commit comments