@@ -225,6 +225,53 @@ test("can use groupInfo enums", async () => {
225
225
await ctx . close ( ) ;
226
226
} ) ;
227
227
228
+ test ( "Setting data persists to DB" , async ( ) => {
229
+ const [ ctx , page ] = await initBrowser ( ) ;
230
+
231
+ const [ firstResult , expectedSecondResult , secondResult ] =
232
+ await page . evaluate ( async ( ) => {
233
+ const { CoreCrypto, Ciphersuite } = await import ( "./corecrypto.js" ) ;
234
+ const ciphersuite =
235
+ Ciphersuite . MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 ;
236
+
237
+ const client2Config = {
238
+ databaseName : "test" ,
239
+ key : "test" ,
240
+ ciphersuites : [ ciphersuite ] ,
241
+ clientId : "test" ,
242
+ } ;
243
+
244
+ const cc = await CoreCrypto . init ( client2Config ) ;
245
+
246
+ const expectedSecondResult = new Uint8Array ( 32 ) ;
247
+ console . log ( expectedSecondResult . toString ( ) ) ;
248
+
249
+ let firstResult ;
250
+ await cc . transaction ( async ( ctx ) => {
251
+ firstResult = await ctx . getData ( ) ;
252
+ await ctx . setData ( expectedSecondResult ) ;
253
+ } ) ;
254
+
255
+ let secondResult ;
256
+ await cc . transaction ( async ( ctx ) => {
257
+ secondResult = await ctx . getData ( ) ;
258
+ } ) ;
259
+
260
+ // To be sure we're not obscuring the case in which firstResult would be null, as when it gets
261
+ // passed out of this closure, undefined becomes null.
262
+ firstResult = firstResult === null ? "null" : firstResult ;
263
+
264
+ return [ firstResult , expectedSecondResult , secondResult ] ;
265
+ } ) ;
266
+
267
+ // Undefined becomes null.
268
+ expect ( firstResult ) . toBe ( null ) ;
269
+ expect ( secondResult ) . toEqual ( expectedSecondResult ) ;
270
+
271
+ await page . close ( ) ;
272
+ await ctx . close ( ) ;
273
+ } ) ;
274
+
228
275
test ( "Using invalid context throws error" , async ( ) => {
229
276
const [ ctx , page ] = await initBrowser ( ) ;
230
277
0 commit comments