@@ -133,7 +133,6 @@ apiDescribe.only(
133
133
} ) ;
134
134
} ) ;
135
135
136
-
137
136
it ( 'should fail transaction (maxAttempts: default) when reading a doc twice with different versions' , async ( ) => {
138
137
await withTestDb ( persistence , async db => {
139
138
asyncQueue ( db ) . skipDelaysForTimerId ( TimerId . TransactionRetry ) ;
@@ -147,13 +146,13 @@ apiDescribe.only(
147
146
await transaction . get ( docRef ) ;
148
147
// Do a write outside of the transaction. Because the transaction
149
148
// will retry, set the document to a different value each time.
150
- await setDoc ( docRef , { count : 1234 + counter } ) ;
149
+ await setDoc ( docRef , { count : 1234 + counter } ) ;
151
150
// Get the docRef again in the transaction with the new
152
151
// version.
153
152
await transaction . get ( docRef ) ;
154
153
// Now try to update the docRef from within the transaction.
155
154
// This should fail, because we read 15 earlier.
156
- await transaction . set ( docRef , { count : 16 } ) ;
155
+ await transaction . set ( docRef , { count : 16 } ) ;
157
156
} ) ;
158
157
expect . fail ( 'transaction should fail' ) ;
159
158
} catch ( err ) {
@@ -176,20 +175,24 @@ apiDescribe.only(
176
175
let counter = 0 ;
177
176
await setDoc ( docRef , { count : 15 } ) ;
178
177
try {
179
- await runTransaction ( db , async transaction => {
180
- counter ++ ;
181
- // Get the docRef once.
182
- await transaction . get ( docRef ) ;
183
- // Do a write outside of the transaction. Because the transaction
184
- // will retry, set the document to a different value each time.
185
- await setDoc ( docRef , { count : 1234 + counter } ) ;
186
- // Get the docRef again in the transaction with the new
187
- // version.
188
- await transaction . get ( docRef ) ;
189
- // Now try to update the docRef from within the transaction.
190
- // This should fail, because we read 15 earlier.
191
- await transaction . set ( docRef , { count : 16 } ) ;
192
- } , options ) ;
178
+ await runTransaction (
179
+ db ,
180
+ async transaction => {
181
+ counter ++ ;
182
+ // Get the docRef once.
183
+ await transaction . get ( docRef ) ;
184
+ // Do a write outside of the transaction. Because the transaction
185
+ // will retry, set the document to a different value each time.
186
+ await setDoc ( docRef , { count : 1234 + counter } ) ;
187
+ // Get the docRef again in the transaction with the new
188
+ // version.
189
+ await transaction . get ( docRef ) ;
190
+ // Now try to update the docRef from within the transaction.
191
+ // This should fail, because we read 15 earlier.
192
+ await transaction . set ( docRef , { count : 16 } ) ;
193
+ } ,
194
+ options
195
+ ) ;
193
196
expect . fail ( 'transaction should fail' ) ;
194
197
} catch ( err ) {
195
198
expect ( err ) . to . exist ;
0 commit comments