@@ -31,7 +31,23 @@ describeSpec('Existence Filters:', [], () => {
3131 . userListens ( query1 )
3232 . watchAcksFull ( query1 , 1000 , doc1 )
3333 . expectEvents ( query1 , { added : [ doc1 ] } )
34- . watchFilters ( [ query1 ] , doc1 . key )
34+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
35+ . watchSnapshots ( 2000 ) ;
36+ } ) ;
37+
38+ // This test is only to make sure watchFilters can accept bloom filter.
39+ // TODO:(mila) update the tests when bloom filter logic is implemented.
40+ specTest ( 'Existence filter with bloom filter match' , [ ] , ( ) => {
41+ const query1 = query ( 'collection' ) ;
42+ const doc1 = doc ( 'collection/1' , 1000 , { v : 1 } ) ;
43+ return spec ( )
44+ . userListens ( query1 )
45+ . watchAcksFull ( query1 , 1000 , doc1 )
46+ . expectEvents ( query1 , { added : [ doc1 ] } )
47+ . watchFilters ( [ query1 ] , [ doc1 . key ] , {
48+ bits : { bitmap : 'a' , padding : 1 } ,
49+ hashCount : 1
50+ } )
3551 . watchSnapshots ( 2000 ) ;
3652 } ) ;
3753
@@ -45,7 +61,7 @@ describeSpec('Existence Filters:', [], () => {
4561 . watchSnapshots ( 2000 )
4662 . expectEvents ( query1 , { } )
4763 . watchSends ( { affects : [ query1 ] } , doc1 )
48- . watchFilters ( [ query1 ] , doc1 . key )
64+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
4965 . watchSnapshots ( 2000 )
5066 . expectEvents ( query1 , { added : [ doc1 ] } ) ;
5167 } ) ;
@@ -59,7 +75,7 @@ describeSpec('Existence Filters:', [], () => {
5975 . watchCurrents ( query1 , 'resume-token-1000' )
6076 . watchSnapshots ( 2000 )
6177 . expectEvents ( query1 , { } )
62- . watchFilters ( [ query1 ] , doc1 . key )
78+ . watchFilters ( [ query1 ] , [ doc1 . key ] )
6379 . watchSnapshots ( 2000 )
6480 . expectEvents ( query1 , { fromCache : true } ) ;
6581 } ) ;
@@ -96,7 +112,37 @@ describeSpec('Existence Filters:', [], () => {
96112 . userListens ( query1 )
97113 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
98114 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
99- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
115+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
116+ . watchSnapshots ( 2000 )
117+ // query is now marked as "inconsistent" because of filter mismatch
118+ . expectEvents ( query1 , { fromCache : true } )
119+ . expectActiveTargets ( { query : query1 , resumeToken : '' } )
120+ . watchRemoves ( query1 ) // Acks removal of query
121+ . watchAcksFull ( query1 , 2000 , doc1 )
122+ . expectLimboDocs ( doc2 . key ) // doc2 is now in limbo
123+ . ackLimbo ( 2000 , deletedDoc ( 'collection/2' , 2000 ) )
124+ . expectLimboDocs ( ) // doc2 is no longer in limbo
125+ . expectEvents ( query1 , {
126+ removed : [ doc2 ]
127+ } )
128+ ) ;
129+ } ) ;
130+
131+ // This test is only to make sure watchFilters can accept bloom filter.
132+ // TODO:(mila) update the tests when bloom filter logic is implemented.
133+ specTest ( 'Existence filter mismatch triggers bloom filter' , [ ] , ( ) => {
134+ const query1 = query ( 'collection' ) ;
135+ const doc1 = doc ( 'collection/1' , 1000 , { v : 1 } ) ;
136+ const doc2 = doc ( 'collection/2' , 1000 , { v : 2 } ) ;
137+ return (
138+ spec ( )
139+ . userListens ( query1 )
140+ . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
141+ . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
142+ . watchFilters ( [ query1 ] , [ doc1 . key ] , {
143+ bits : { bitmap : 'a' , padding : 1 } ,
144+ hashCount : 3
145+ } ) // in the next sync doc2 was deleted
100146 . watchSnapshots ( 2000 )
101147 // query is now marked as "inconsistent" because of filter mismatch
102148 . expectEvents ( query1 , { fromCache : true } )
@@ -130,7 +176,7 @@ describeSpec('Existence Filters:', [], () => {
130176 resumeToken : 'existence-filter-resume-token'
131177 } )
132178 . watchAcks ( query1 )
133- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
179+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
134180 . watchSnapshots ( 2000 )
135181 // query is now marked as "inconsistent" because of filter mismatch
136182 . expectEvents ( query1 , { fromCache : true } )
@@ -159,7 +205,7 @@ describeSpec('Existence Filters:', [], () => {
159205 // Send a mismatching existence filter with two documents, but don't
160206 // send a new global snapshot. We should not see an event until we
161207 // receive the snapshot.
162- . watchFilters ( [ query1 ] , doc1 . key , doc2 . key )
208+ . watchFilters ( [ query1 ] , [ doc1 . key , doc2 . key ] )
163209 . watchSends ( { affects : [ query1 ] } , doc3 )
164210 . watchSnapshots ( 2000 )
165211 // The query result includes doc3, but is marked as "inconsistent"
@@ -193,7 +239,7 @@ describeSpec('Existence Filters:', [], () => {
193239 . userListens ( query1 )
194240 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
195241 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
196- . watchFilters ( [ query1 ] , doc1 . key ) // in the next sync doc2 was deleted
242+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // in the next sync doc2 was deleted
197243 . watchSnapshots ( 2000 )
198244 // query is now marked as "inconsistent" because of filter mismatch
199245 . expectEvents ( query1 , { fromCache : true } )
@@ -229,7 +275,7 @@ describeSpec('Existence Filters:', [], () => {
229275 . userListens ( query1 )
230276 . watchAcksFull ( query1 , 1000 , doc1 , doc2 )
231277 . expectEvents ( query1 , { added : [ doc1 , doc2 ] } )
232- . watchFilters ( [ query1 ] , doc1 . key ) // doc2 was deleted
278+ . watchFilters ( [ query1 ] , [ doc1 . key ] ) // doc2 was deleted
233279 . watchSnapshots ( 2000 )
234280 . expectEvents ( query1 , { fromCache : true } )
235281 // The SDK is unable to re-run the query, and does not remove doc2
0 commit comments