1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package wallet
import (
"os"
"path/filepath"
"testing"
"github.com/NebulousLabs/Sia/build"
"github.com/NebulousLabs/Sia/modules"
"github.com/NebulousLabs/bolt"
)
// TestDBOpen tests the wallet.openDB method.
func TestDBOpen(t *testing.T) {
w := new(Wallet)
err := w.openDB("")
if err == nil {
t.Fatal("expected error, got nil")
}
testdir := build.TempDir(modules.WalletDir, "TestDBOpen")
os.MkdirAll(testdir, 0700)
err = w.openDB(filepath.Join(testdir, dbFile))
if err != nil {
t.Fatal(err)
}
w.db.View(func(tx *bolt.Tx) error {
for _, b := range dbBuckets {
if tx.Bucket(b) == nil {
t.Error("bucket", string(b), "does not exist")
}
}
return nil
})
w.db.Close()
}
|