@@ -137,14 +137,14 @@ async fn insert_count(
137137 deployment : & DeploymentLocator ,
138138 block : u8 ,
139139 count : u8 ,
140- immutable : bool ,
140+ immutable_only : bool ,
141141) {
142142 let count_key_local = |counter_type : & EntityType , id : & str | counter_type. parse_key ( id) . unwrap ( ) ;
143143 let data = entity ! { TEST_SUBGRAPH_SCHEMA =>
144144 id: "1" ,
145145 count: count as i32
146146 } ;
147- let entity_op = if ( block != 3 && block != 5 && block != 7 ) || !immutable {
147+ let entity_op = if block != 3 && block != 5 && block != 7 {
148148 EntityOperation :: Set {
149149 key : count_key_local ( & COUNTER_TYPE , & data. get ( "id" ) . unwrap ( ) . to_string ( ) ) ,
150150 data,
@@ -154,8 +154,12 @@ async fn insert_count(
154154 key : count_key_local ( & COUNTER_TYPE , & data. get ( "id" ) . unwrap ( ) . to_string ( ) ) ,
155155 }
156156 } ;
157- let mut ops = vec ! [ entity_op] ;
158- if immutable && block < 6 {
157+ let mut ops = if immutable_only {
158+ vec ! [ ]
159+ } else {
160+ vec ! [ entity_op]
161+ } ;
162+ if block < 6 {
159163 let data = entity ! { TEST_SUBGRAPH_SCHEMA =>
160164 id: & block. to_string( ) ,
161165 count : count as i32 ,
@@ -349,7 +353,7 @@ fn read_range_test() {
349353 writable. deployment_synced ( ) . unwrap ( ) ;
350354
351355 for count in 1 ..=5 {
352- insert_count ( & subgraph_store, & deployment, count, 2 * count, true ) . await ;
356+ insert_count ( & subgraph_store, & deployment, count, 2 * count, false ) . await ;
353357 }
354358 writable. flush ( ) . await . unwrap ( ) ;
355359 writable. deployment_synced ( ) . unwrap ( ) ;
@@ -366,7 +370,7 @@ fn read_range_test() {
366370 assert_eq ! ( a, format!( "{:?}" , en) ) ;
367371 }
368372 for count in 6 ..=7 {
369- insert_count ( & subgraph_store, & deployment, count, 2 * count, true ) . await ;
373+ insert_count ( & subgraph_store, & deployment, count, 2 * count, false ) . await ;
370374 }
371375 writable. flush ( ) . await . unwrap ( ) ;
372376 writable. deployment_synced ( ) . unwrap ( ) ;
@@ -381,3 +385,23 @@ fn read_range_test() {
381385 }
382386 } )
383387}
388+
389+ #[ test]
390+ fn read_immutable_only_range_test ( ) {
391+ run_test ( |store, writable, sourceable, deployment| async move {
392+ let subgraph_store = store. subgraph_store ( ) ;
393+ writable. deployment_synced ( ) . unwrap ( ) ;
394+
395+ for count in 1 ..=4 {
396+ insert_count ( & subgraph_store, & deployment, count, 2 * count, true ) . await ;
397+ }
398+ writable. flush ( ) . await . unwrap ( ) ;
399+ writable. deployment_synced ( ) . unwrap ( ) ;
400+ let br: Range < BlockNumber > = 0 ..18 ;
401+ let entity_types = vec ! [ COUNTER2_TYPE . clone( ) ] ;
402+ let e: BTreeMap < i32 , Vec < EntityWithType > > = sourceable
403+ . get_range ( entity_types. clone ( ) , CausalityRegion :: ONCHAIN , br. clone ( ) )
404+ . unwrap ( ) ;
405+ assert_eq ! ( e. len( ) , 4 ) ;
406+ } )
407+ }
0 commit comments