Skip to content

Commit 0732192

Browse files
committed
round out rekey tests for WAL
1 parent c2f7cd7 commit 0732192

1 file changed

Lines changed: 65 additions & 3 deletions

File tree

test/crypto.test

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,9 @@ do_test rekey-delete-and-query-1 {
302302
SELECT (count(*) > 0) FROM t1;
303303
}
304304
} {1}
305-
306305
db close
307-
file copy -force test.db test-rekey.db
308306

309-
do_test rekey-delete-and-query-1 {
307+
do_test rekey-delete-and-query-2 {
310308
sqlite_orig db test.db
311309
execsql {
312310
PRAGMA key = 'test123';
@@ -315,6 +313,70 @@ do_test rekey-delete-and-query-1 {
315313
}
316314
} {1}
317315
db close
316+
317+
do_test rekey-delete-and-query-3 {
318+
sqlite_orig db test.db
319+
execsql {
320+
PRAGMA key = 'test321';
321+
SELECT count(*) > 1 FROM t1;
322+
}
323+
} {1}
324+
db close
325+
file delete -force test.db
326+
327+
328+
# same as previous test, but use WAL
329+
do_test rekey-delete-and-query-wal-1 {
330+
sqlite_orig db test.db
331+
332+
execsql {
333+
PRAGMA key = 'test123';
334+
PRAGMA journal_mode = WAL;
335+
CREATE TABLE t1(a,b);
336+
CREATE INDEX ta_a ON t1(a);
337+
BEGIN;
338+
}
339+
340+
for {set i 1} {$i<1000} {incr i} {
341+
set r [expr {int(rand()*32767)}]
342+
set r1 [expr {int(rand()*32767)}]
343+
execsql "INSERT INTO t1 VALUES($r,$r1);"
344+
}
345+
set r [expr {int(rand()*32767)}]
346+
set r1 [expr {int(rand()*32767)}]
347+
execsql "UPDATE t1 SET b = $r WHERE a < $r1;"
348+
349+
set r [expr {int(rand()*32767)}]
350+
351+
execsql "DELETE FROM t1 WHERE a < $r;"
352+
353+
execsql {
354+
COMMIT;
355+
SELECT (count(*) > 0) FROM t1;
356+
}
357+
} {1}
358+
db close
359+
360+
do_test rekey-delete-and-query-wal-2 {
361+
sqlite_orig db test.db
362+
execsql {
363+
PRAGMA key = 'test123';
364+
PRAGMA journal_mode = WAL;
365+
PRAGMA rekey = 'test321';
366+
SELECT count(*) > 1 FROM t1;
367+
}
368+
} {wal 1}
369+
db close
370+
371+
do_test rekey-delete-and-query-wal-3 {
372+
sqlite_orig db test.db
373+
execsql {
374+
PRAGMA key = 'test321';
375+
PRAGMA journal_mode = WAL;
376+
SELECT count(*) > 1 FROM t1;
377+
}
378+
} {wal 1}
379+
db close
318380
file delete -force test.db
319381

320382
# attach an encrypted database

0 commit comments

Comments
 (0)