@@ -2,6 +2,7 @@ use std::sync::Arc;
22
33use cid:: Cid ;
44use graph:: blockchain:: { Block , BlockPtr } ;
5+ use graph:: env:: EnvVars ;
56use graph:: object;
67use graph:: prelude:: ethabi:: ethereum_types:: H256 ;
78use graph:: prelude:: { SubgraphAssignmentProvider , SubgraphName } ;
@@ -33,7 +34,15 @@ async fn data_source_revert() -> anyhow::Result<()> {
3334 } ;
3435
3536 let chain = Arc :: new ( chain ( blocks. clone ( ) , & stores) . await ) ;
36- let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain. clone ( ) , None ) . await ;
37+ let ctx = fixture:: setup (
38+ subgraph_name. clone ( ) ,
39+ & hash,
40+ & stores,
41+ chain. clone ( ) ,
42+ None ,
43+ None ,
44+ )
45+ . await ;
3746
3847 let stop_block = test_ptr ( 2 ) ;
3948 ctx. start_and_sync_to ( stop_block) . await ;
@@ -51,7 +60,15 @@ async fn data_source_revert() -> anyhow::Result<()> {
5160 )
5261 . await ;
5362 let graft_block = Some ( test_ptr ( 3 ) ) ;
54- let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain, graft_block) . await ;
63+ let ctx = fixture:: setup (
64+ subgraph_name. clone ( ) ,
65+ & hash,
66+ & stores,
67+ chain,
68+ graft_block,
69+ None ,
70+ )
71+ . await ;
5572 let stop_block = test_ptr ( 4 ) ;
5673 ctx. start_and_sync_to ( stop_block) . await ;
5774
@@ -97,7 +114,7 @@ async fn typename() -> anyhow::Result<()> {
97114
98115 let stores = stores ( "./integration-tests/config.simple.toml" ) . await ;
99116 let chain = Arc :: new ( chain ( blocks, & stores) . await ) ;
100- let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain, None ) . await ;
117+ let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain, None , None ) . await ;
101118
102119 ctx. start_and_sync_to ( stop_block) . await ;
103120
@@ -122,7 +139,7 @@ async fn file_data_sources() {
122139 } ;
123140 let stop_block = test_ptr ( 1 ) ;
124141 let chain = Arc :: new ( chain ( blocks, & stores) . await ) ;
125- let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain, None ) . await ;
142+ let ctx = fixture:: setup ( subgraph_name. clone ( ) , & hash, & stores, chain, None , None ) . await ;
126143 ctx. start_and_sync_to ( stop_block) . await ;
127144
128145 // CID QmVkvoPGi9jvvuxsHDVJDgzPEzagBaWSZRYoRDzU244HjZ is the file
@@ -151,3 +168,56 @@ async fn file_data_sources() {
151168 let stop_block = test_ptr ( 2 ) ;
152169 ctx. start_and_sync_to ( stop_block) . await ;
153170}
171+
172+ #[ tokio:: test]
173+ async fn template_static_filters_false_positives ( ) {
174+ let stores = stores ( "./integration-tests/config.simple.toml" ) . await ;
175+
176+ let subgraph_name = SubgraphName :: new ( "dynamic-data-source" ) . unwrap ( ) ;
177+ let hash = {
178+ let test_dir = format ! ( "./integration-tests/{}" , subgraph_name) ;
179+ fixture:: build_subgraph ( & test_dir) . await
180+ } ;
181+
182+ let blocks = {
183+ let block_0 = genesis ( ) ;
184+ let block_1 = empty_block ( block_0. ptr ( ) , test_ptr ( 1 ) ) ;
185+ let block_2 = empty_block ( block_1. ptr ( ) , test_ptr ( 2 ) ) ;
186+ vec ! [ block_0, block_1, block_2]
187+ } ;
188+ let stop_block = test_ptr ( 1 ) ;
189+ let chain = Arc :: new ( chain ( blocks, & stores) . await ) ;
190+
191+ let mut env_vars = EnvVars :: default ( ) ;
192+ env_vars. experimental_static_filters = true ;
193+
194+ let ctx = fixture:: setup (
195+ subgraph_name. clone ( ) ,
196+ & hash,
197+ & stores,
198+ chain,
199+ None ,
200+ Some ( env_vars) ,
201+ )
202+ . await ;
203+ ctx. start_and_sync_to ( stop_block) . await ;
204+
205+ let poi = ctx
206+ . store
207+ . get_proof_of_indexing ( & ctx. deployment . hash , & None , test_ptr ( 1 ) )
208+ . await
209+ . unwrap ( ) ;
210+
211+ // This check exists to prevent regression of https://github.com/graphprotocol/graph-node/issues/3963
212+ // when false positives go through the block stream, they should be discarded by
213+ // `DataSource::match_and_decode`. The POI below is generated consistently from the empty
214+ // POI table. If this fails it's likely that either the bug was re-introduced or there is
215+ // a change in the POI infrastructure.
216+ assert_eq ! (
217+ poi. unwrap( ) ,
218+ [
219+ 196 , 173 , 167 , 52 , 226 , 19 , 154 , 61 , 189 , 94 , 19 , 229 , 18 , 7 , 0 , 252 , 234 , 49 , 110 ,
220+ 179 , 105 , 64 , 16 , 46 , 25 , 194 , 83 , 94 , 195 , 225 , 56 , 252
221+ ] ,
222+ ) ;
223+ }
0 commit comments