Adiantum encrypting VFS. (#77)

This commit is contained in:
Nuno Cruces
2024-04-18 01:39:47 +01:00
committed by GitHub
parent e86789b285
commit ec1ed22149
20 changed files with 479 additions and 21 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/ncruces/go-sqlite3"
_ "github.com/ncruces/go-sqlite3/embed"
_ "github.com/ncruces/go-sqlite3/tests/testcfg"
_ "github.com/ncruces/go-sqlite3/vfs/adiantum"
_ "github.com/ncruces/go-sqlite3/vfs/memdb"
)
@@ -56,10 +57,18 @@ func TestDB_utf16(t *testing.T) {
testDB(t, tmp)
}
func TestDB_vfs(t *testing.T) {
func TestDB_memdb(t *testing.T) {
t.Parallel()
testDB(t, "file:test.db?vfs=memdb")
}
func TestDB_adiantum(t *testing.T) {
t.Parallel()
testDB(t, "file:"+
filepath.ToSlash(filepath.Join(t.TempDir(), "test.db"))+
"?vfs=adiantum&textkey=correct+horse+battery+staple")
}
func testDB(t testing.TB, name string) {
db, err := sqlite3.Open(name)
if err != nil {

View File

@@ -14,10 +14,11 @@ import (
_ "github.com/ncruces/go-sqlite3/embed"
_ "github.com/ncruces/go-sqlite3/tests/testcfg"
"github.com/ncruces/go-sqlite3/vfs"
_ "github.com/ncruces/go-sqlite3/vfs/adiantum"
"github.com/ncruces/go-sqlite3/vfs/memdb"
)
func TestParallel(t *testing.T) {
func Test_parallel(t *testing.T) {
var iter int
if testing.Short() {
iter = 1000
@@ -34,7 +35,7 @@ func TestParallel(t *testing.T) {
testIntegrity(t, name)
}
func TestWAL(t *testing.T) {
func Test_wal(t *testing.T) {
if !vfs.SupportsSharedMemory {
t.Skip("skipping without shared memory")
}
@@ -48,7 +49,7 @@ func TestWAL(t *testing.T) {
testIntegrity(t, name)
}
func TestMemory(t *testing.T) {
func Test_memdb(t *testing.T) {
var iter int
if testing.Short() {
iter = 1000
@@ -61,6 +62,21 @@ func TestMemory(t *testing.T) {
testIntegrity(t, name)
}
func Test_adiantum(t *testing.T) {
var iter int
if testing.Short() {
iter = 1000
} else {
iter = 5000
}
name := "file:" +
filepath.ToSlash(filepath.Join(t.TempDir(), "test.db")) +
"?vfs=adiantum&textkey=correct+horse+battery+staple"
testParallel(t, name, iter)
testIntegrity(t, name)
}
func TestMultiProcess(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
@@ -112,7 +128,7 @@ func TestChildProcess(t *testing.T) {
testParallel(t, name, 1000)
}
func BenchmarkMemory(b *testing.B) {
func Benchmark_memdb(b *testing.B) {
memdb.Delete("test.db")
name := "file:/test.db?vfs=memdb"
testParallel(b, name, b.N)