kvdb+etcd: enable channeldb testing with both bdb/etcd

This commit is contained in:
Andras Banki-Horvath committed 2020-05-22 11:26:25 +02:00
1 parent 3b7525659c
commit 248a00f211
7 files changed
+169 -40

No files matched your search

+19 -2
View File
@@ -3,6 +3,7 @@ package channeldb
import (
"bytes"
"io/ioutil"
"os"
"testing"
"github.com/go-errors/errors"
@@ -421,12 +422,21 @@ func TestMigrationReversion(t *testing.T) {
t.Parallel()
tempDirName, err := ioutil.TempDir("", "channeldb")
defer func() {
os.RemoveAll(tempDirName)
}()
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}
cdb, err := Open(tempDirName)
backend, cleanup, err := kvdb.GetTestBackend(tempDirName, "cdb")
if err != nil {
t.Fatalf("unable to get test db backend: %v", err)
}
cdb, err := CreateWithBackend(backend)
if err != nil {
cleanup()
t.Fatalf("unable to open channeldb: %v", err)
}
@@ -442,12 +452,19 @@ func TestMigrationReversion(t *testing.T) {
// Close the database. Even if we succeeded, our next step is to reopen.
cdb.Close()
cleanup()
if err != nil {
t.Fatalf("unable to increase db version: %v", err)
}
_, err = Open(tempDirName)
backend, cleanup, err = kvdb.GetTestBackend(tempDirName, "cdb")
if err != nil {
t.Fatalf("unable to get test db backend: %v", err)
}
defer cleanup()
_, err = CreateWithBackend(backend)
if err != ErrDBReversion {
t.Fatalf("unexpected error when opening channeldb, "+
"want: %v, got: %v", ErrDBReversion, err)