mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-23 09:18:11 +00:00
round out rekey tests for WAL
This commit is contained in:
parent
c2f7cd7926
commit
07321926ba
@ -302,11 +302,9 @@ do_test rekey-delete-and-query-1 {
|
|||||||
SELECT (count(*) > 0) FROM t1;
|
SELECT (count(*) > 0) FROM t1;
|
||||||
}
|
}
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
db close
|
db close
|
||||||
file copy -force test.db test-rekey.db
|
|
||||||
|
|
||||||
do_test rekey-delete-and-query-1 {
|
do_test rekey-delete-and-query-2 {
|
||||||
sqlite_orig db test.db
|
sqlite_orig db test.db
|
||||||
execsql {
|
execsql {
|
||||||
PRAGMA key = 'test123';
|
PRAGMA key = 'test123';
|
||||||
@ -315,6 +313,70 @@ do_test rekey-delete-and-query-1 {
|
|||||||
}
|
}
|
||||||
} {1}
|
} {1}
|
||||||
db close
|
db close
|
||||||
|
|
||||||
|
do_test rekey-delete-and-query-3 {
|
||||||
|
sqlite_orig db test.db
|
||||||
|
execsql {
|
||||||
|
PRAGMA key = 'test321';
|
||||||
|
SELECT count(*) > 1 FROM t1;
|
||||||
|
}
|
||||||
|
} {1}
|
||||||
|
db close
|
||||||
|
file delete -force test.db
|
||||||
|
|
||||||
|
|
||||||
|
# same as previous test, but use WAL
|
||||||
|
do_test rekey-delete-and-query-wal-1 {
|
||||||
|
sqlite_orig db test.db
|
||||||
|
|
||||||
|
execsql {
|
||||||
|
PRAGMA key = 'test123';
|
||||||
|
PRAGMA journal_mode = WAL;
|
||||||
|
CREATE TABLE t1(a,b);
|
||||||
|
CREATE INDEX ta_a ON t1(a);
|
||||||
|
BEGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
for {set i 1} {$i<1000} {incr i} {
|
||||||
|
set r [expr {int(rand()*32767)}]
|
||||||
|
set r1 [expr {int(rand()*32767)}]
|
||||||
|
execsql "INSERT INTO t1 VALUES($r,$r1);"
|
||||||
|
}
|
||||||
|
set r [expr {int(rand()*32767)}]
|
||||||
|
set r1 [expr {int(rand()*32767)}]
|
||||||
|
execsql "UPDATE t1 SET b = $r WHERE a < $r1;"
|
||||||
|
|
||||||
|
set r [expr {int(rand()*32767)}]
|
||||||
|
|
||||||
|
execsql "DELETE FROM t1 WHERE a < $r;"
|
||||||
|
|
||||||
|
execsql {
|
||||||
|
COMMIT;
|
||||||
|
SELECT (count(*) > 0) FROM t1;
|
||||||
|
}
|
||||||
|
} {1}
|
||||||
|
db close
|
||||||
|
|
||||||
|
do_test rekey-delete-and-query-wal-2 {
|
||||||
|
sqlite_orig db test.db
|
||||||
|
execsql {
|
||||||
|
PRAGMA key = 'test123';
|
||||||
|
PRAGMA journal_mode = WAL;
|
||||||
|
PRAGMA rekey = 'test321';
|
||||||
|
SELECT count(*) > 1 FROM t1;
|
||||||
|
}
|
||||||
|
} {wal 1}
|
||||||
|
db close
|
||||||
|
|
||||||
|
do_test rekey-delete-and-query-wal-3 {
|
||||||
|
sqlite_orig db test.db
|
||||||
|
execsql {
|
||||||
|
PRAGMA key = 'test321';
|
||||||
|
PRAGMA journal_mode = WAL;
|
||||||
|
SELECT count(*) > 1 FROM t1;
|
||||||
|
}
|
||||||
|
} {wal 1}
|
||||||
|
db close
|
||||||
file delete -force test.db
|
file delete -force test.db
|
||||||
|
|
||||||
# attach an encrypted database
|
# attach an encrypted database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user