@@ -20,7 +20,8 @@ use graph::env::ENV_VARS;
20
20
use graph:: prelude:: web3:: types:: H256 ;
21
21
use graph:: prelude:: {
22
22
anyhow, async_trait, serde_yaml, tokio, BigDecimal , BigInt , DeploymentHash , Link , Logger ,
23
- SubgraphManifest , SubgraphManifestValidationError , SubgraphStore , UnvalidatedSubgraphManifest ,
23
+ SubgraphManifest , SubgraphManifestResolveError , SubgraphManifestValidationError , SubgraphStore ,
24
+ UnvalidatedSubgraphManifest ,
24
25
} ;
25
26
use graph:: {
26
27
blockchain:: NodeCapabilities as _,
@@ -1818,3 +1819,95 @@ specVersion: 1.3.0
1818
1819
. to_string( )
1819
1820
. contains( "Subgraph datasources cannot be used alongside onchain datasources" ) ) ;
1820
1821
}
1822
+
1823
+ #[ test]
1824
+ fn nested_subgraph_ds_manifest_should_fail ( ) {
1825
+ let yaml = r#"
1826
+ schema:
1827
+ file:
1828
+ /: /ipfs/Qmschema
1829
+ dataSources:
1830
+ - name: SubgraphSource
1831
+ kind: subgraph
1832
+ entities:
1833
+ - User
1834
+ network: mainnet
1835
+ source:
1836
+ address: 'QmNestedSource'
1837
+ startBlock: 9562480
1838
+ mapping:
1839
+ apiVersion: 0.0.6
1840
+ language: wasm/assemblyscript
1841
+ entities:
1842
+ - TestEntity
1843
+ file:
1844
+ /: /ipfs/Qmmapping
1845
+ handlers:
1846
+ - handler: handleEntity
1847
+ entity: User
1848
+ specVersion: 1.3.0
1849
+ "# ;
1850
+
1851
+ // First modify SOURCE_SUBGRAPH_MANIFEST to include a subgraph datasource
1852
+ const NESTED_SOURCE_MANIFEST : & str = r#"
1853
+ schema:
1854
+ file:
1855
+ /: /ipfs/QmSourceSchema
1856
+ dataSources:
1857
+ - kind: subgraph
1858
+ name: NestedSource
1859
+ network: mainnet
1860
+ entities:
1861
+ - User
1862
+ source:
1863
+ address: 'QmSource'
1864
+ startBlock: 1
1865
+ mapping:
1866
+ apiVersion: 0.0.6
1867
+ language: wasm/assemblyscript
1868
+ entities:
1869
+ - User
1870
+ file:
1871
+ /: /ipfs/Qmmapping
1872
+ handlers:
1873
+ - handler: handleNested
1874
+ entity: User
1875
+ specVersion: 1.3.0
1876
+ "# ;
1877
+
1878
+ let mut resolver = TextResolver :: default ( ) ;
1879
+ let id = DeploymentHash :: new ( "Qmmanifest" ) . unwrap ( ) ;
1880
+
1881
+ resolver. add ( id. as_str ( ) , & yaml) ;
1882
+ resolver. add ( "/ipfs/Qmabi" , & ABI ) ;
1883
+ resolver. add ( "/ipfs/Qmschema" , & GQL_SCHEMA ) ;
1884
+ resolver. add ( "/ipfs/Qmmapping" , & MAPPING_WITH_IPFS_FUNC_WASM ) ;
1885
+ resolver. add ( "/ipfs/QmNestedSource" , & NESTED_SOURCE_MANIFEST ) ;
1886
+ resolver. add ( "/ipfs/QmSource" , & SOURCE_SUBGRAPH_MANIFEST ) ;
1887
+ resolver. add ( "/ipfs/QmSourceSchema" , & SOURCE_SUBGRAPH_SCHEMA ) ;
1888
+
1889
+ let resolver: Arc < dyn LinkResolverTrait > = Arc :: new ( resolver) ;
1890
+
1891
+ let raw = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
1892
+ test_store:: run_test_sequentially ( |_| async move {
1893
+ let result: Result < UnvalidatedSubgraphManifest < Chain > , _ > =
1894
+ UnvalidatedSubgraphManifest :: resolve (
1895
+ id,
1896
+ raw,
1897
+ & resolver,
1898
+ & LOGGER ,
1899
+ SPEC_VERSION_1_3_0 . clone ( ) ,
1900
+ )
1901
+ . await ;
1902
+
1903
+ match result {
1904
+ Ok ( _) => panic ! ( "Expected resolution to fail" ) ,
1905
+ Err ( e) => {
1906
+ assert ! ( matches!( e, SubgraphManifestResolveError :: ResolveError ( _) ) ) ;
1907
+ let error_msg = e. to_string ( ) ;
1908
+ println ! ( "{}" , error_msg) ;
1909
+ assert ! ( error_msg. contains( "Nested subgraph data sources are not supported." ) ) ;
1910
+ }
1911
+ }
1912
+ } )
1913
+ }
0 commit comments