@@ -23,18 +23,32 @@ import { describeSpec, specTest } from './describe_spec';
2323import { spec } from './spec_builder' ;
2424import { RpcError } from './spec_rpc_error' ;
2525
26- describeSpec ( 'Existence Filters:' , [ ] , ( ) => {
26+ describeSpec ( 'Existence Filters:' , [ 'exclusive' ] , ( ) => {
2727 specTest ( 'Existence filter match' , [ ] , ( ) => {
2828 const query1 = query ( 'collection' ) ;
2929 const doc1 = doc ( 'collection/1' , 1000 , { v : 1 } ) ;
3030 return spec ( )
3131 . userListens ( query1 )
3232 . watchAcksFull ( query1 , 1000 , doc1 )
3333 . expectEvents ( query1 , { added : [ doc1 ] } )
34- . watchFilters ( [ query1 ] , doc1 . key )
34+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
3535 . watchSnapshots ( 2000 ) ;
3636 } ) ;
3737
38+ // TODO:(mila) update the tests when bloom filter is
39+ specTest ( 'Existence filter with bloom filter match' , [ 'exclusive' ] , ( ) => {
40+ const query1 = query ( 'collection' ) ;
41+ const doc1 = doc ( 'collection/1' , 1000 , { v : 1 } ) ;
42+ return spec ( )
43+ . userListens ( query1 )
44+ . watchAcksFull ( query1 , 1000 , doc1 )
45+ . expectEvents ( query1 , { added : [ doc1 ] } )
46+ . watchFilters ( [ query1 ] , [ doc1 . key ] , { bits :{ bitmap :"a" , padding :1 } , hashCount :1 } )
47+ . watchSnapshots ( 2000 )
48+ . watchFilters ( [ query1 ] )
49+ . watchSnapshots ( 3000 ) ;
50+ } ) ;
51+
3852 specTest ( 'Existence filter match after pending update' , [ ] , ( ) => {
3953 const query1 = query ( 'collection' ) ;
4054 const doc1 = doc ( 'collection/1' , 2000 , { v : 2 } ) ;
@@ -45,7 +59,7 @@ describeSpec('Existence Filters:', [], () => {
4559 . watchSnapshots ( 2000 )
4660 . expectEvents ( query1 , { } )
4761 . watchSends ( { affects : [ query1 ] } , doc1 )
48- . watchFilters ( [ query1 ] , doc1 . key )
62+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
4963 . watchSnapshots ( 2000 )
5064 . expectEvents ( query1 , { added : [ doc1 ] } ) ;
5165 } ) ;
@@ -59,7 +73,7 @@ describeSpec('Existence Filters:', [], () => {
5973 . watchCurrents ( query1 , 'resume-token-1000' )
6074 . watchSnapshots ( 2000 )
6175 . expectEvents ( query1 , { } )
62- . watchFilters ( [ query1 ] , doc1 . key )
76+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
6377 . watchSnapshots ( 2000 )
6478 . expectEvents ( query1 , { fromCache : true } ) ;
6579 } ) ;
@@ -96,7 +110,33 @@ describeSpec('Existence Filters:', [], () => {
96110 . userListens ( query1 )
97111 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
98112 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
99- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
113+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
114+ . watchSnapshots ( 2000 )
115+ // query is now marked as "inconsistent" because of filter mismatch
116+ . expectEvents ( query1 , { fromCache : true } )
117+ . expectActiveTargets ( { query : query1 , resumeToken : '' } )
118+ . watchRemoves ( query1 ) // Acks removal of query
119+ . watchAcksFull ( query1 , 2000 , doc1 )
120+ . expectLimboDocs ( doc2 . key ) // doc2 is now in limbo
121+ . ackLimbo ( 2000 , deletedDoc ( 'collection/2' , 2000 ) )
122+ . expectLimboDocs ( ) // doc2 is no longer in limbo
123+ . expectEvents ( query1 , {
124+ removed : [ doc2 ]
125+ } )
126+ ) ;
127+ } ) ;
128+
129+ // todo
130+ specTest ( 'Existence filter mismatch triggers bloom filter' , [ 'exclusive' ] , ( ) => {
131+ const query1 = query ( 'collection' ) ;
132+ const doc1 = doc ( 'collection/1' , 1000 , { v : 1 } ) ;
133+ const doc2 = doc ( 'collection/2' , 1000 , { v : 2 } ) ;
134+ return (
135+ spec ( )
136+ . userListens ( query1 )
137+ . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
138+ . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
139+ . watchFilters ( [ query1 ] , [ doc1 . key ] , { bits :{ bitmap :"a" , padding :1 } , hashCount :3 } ) // in the next sync doc2 was deleted
100140 . watchSnapshots ( 2000 )
101141 // query is now marked as "inconsistent" because of filter mismatch
102142 . expectEvents ( query1 , { fromCache : true } )
@@ -130,7 +170,7 @@ describeSpec('Existence Filters:', [], () => {
130170 resumeToken : 'existence-filter-resume-token'
131171 } )
132172 . watchAcks ( query1 )
133- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
173+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
134174 . watchSnapshots ( 2000 )
135175 // query is now marked as "inconsistent" because of filter mismatch
136176 . expectEvents ( query1 , { fromCache : true } )
@@ -159,7 +199,7 @@ describeSpec('Existence Filters:', [], () => {
159199 // Send a mismatching existence filter with two documents, but don't
160200 // send a new global snapshot. We should not see an event until we
161201 // receive the snapshot.
162- . watchFilters ( [ query1 ] , doc1 . key , doc2 . key )
202+ . watchFilters ( [ query1 ] , [ doc1 . key , doc2 . key ] )
163203 . watchSends ( { affects : [ query1 ] } , doc3 )
164204 . watchSnapshots ( 2000 )
165205 // The query result includes doc3, but is marked as "inconsistent"
@@ -193,7 +233,7 @@ describeSpec('Existence Filters:', [], () => {
193233 . userListens ( query1 )
194234 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
195235 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
196- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
236+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
197237 . watchSnapshots ( 2000 )
198238 // query is now marked as "inconsistent" because of filter mismatch
199239 . expectEvents ( query1 , { fromCache : true } )
@@ -229,7 +269,7 @@ describeSpec('Existence Filters:', [], () => {
229269 . userListens ( query1 )
230270 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
231271 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
232- . watchFilters ( [ query1 ] , doc1 . key ) // doc2 was deleted
272+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // doc2 was deleted
233273 . watchSnapshots ( 2000 )
234274 . expectEvents ( query1 , { fromCache : true } )
235275 // The SDK is unable to re-run the query, and does not remove doc2
0 commit comments