Skip to content

Commit 5bdc671

Browse files
committed
add integrity check test for a newly created database using current version
1 parent b0dcc5c commit 5bdc671

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/sqlcipher-integrity.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,38 @@ do_test hmac-tamper-resistence {
155155
db close
156156
file delete -force test.db
157157

158+
# test that integrity checks work on a pristine
159+
# newly created database
160+
do_test integrity-check-clean-database {
161+
sqlite_orig db test.db
162+
163+
execsql {
164+
PRAGMA key = 'testkey';
165+
CREATE table t1(a,b);
166+
BEGIN;
167+
}
168+
169+
for {set i 1} {$i<=10000} {incr i} {
170+
execsql "INSERT INTO t1 VALUES($i,'value $i');"
171+
}
172+
173+
execsql {
174+
COMMIT;
175+
}
176+
177+
db close
178+
179+
sqlite_orig db test.db
180+
execsql {
181+
PRAGMA key = 'testkey';
182+
PRAGMA integrity_check;
183+
PRAGMA cipher_integrity_check;
184+
}
185+
186+
} {ok {} {}}
187+
db close
188+
file delete -force test.db
189+
158190
# try cipher_integrity_check on an in-memory database
159191
# which should fail because the file doesn't exist
160192
do_test memory-integrity-check-should-fail {

0 commit comments

Comments
 (0)