diff --git a/walletdb/bdb/db.go b/walletdb/bdb/db.go index 2408fad3f8..cf3fc2e2d4 100644 --- a/walletdb/bdb/db.go +++ b/walletdb/bdb/db.go @@ -9,7 +9,7 @@ import ( "os" "github.com/btcsuite/btcwallet/walletdb" - "go.etcd.io/bbolt" + "github.com/coreos/bbolt" ) // convertErr converts some bolt errors to the equivalent walletdb error. diff --git a/walletdb/bdb/driver_test.go b/walletdb/bdb/driver_test.go index 8fdcab17c8..aa4d87210f 100644 --- a/walletdb/bdb/driver_test.go +++ b/walletdb/bdb/driver_test.go @@ -6,7 +6,9 @@ package bdb_test import ( "fmt" + "io/ioutil" "os" + "path/filepath" "reflect" "testing" @@ -71,13 +73,19 @@ func TestCreateOpenFail(t *testing.T) { // Ensure operations against a closed database return the expected // error. - dbPath := "createfail.db" + tempDir, err := ioutil.TempDir("", "createfail") + if err != nil { + t.Errorf("unable to create temp dir: %v", err) + return + } + defer os.Remove(tempDir) + + dbPath := filepath.Join(tempDir, "db") db, err := walletdb.Create(dbType, dbPath, true) if err != nil { t.Errorf("Create: unexpected error: %v", err) return } - defer os.Remove(dbPath) db.Close() wantErr = walletdb.ErrDbNotOpen @@ -92,13 +100,19 @@ func TestCreateOpenFail(t *testing.T) { // reopening the database. func TestPersistence(t *testing.T) { // Create a new database to run tests against. - dbPath := "persistencetest.db" + tempDir, err := ioutil.TempDir("", "persistencetest") + if err != nil { + t.Errorf("unable to create temp dir: %v", err) + return + } + defer os.Remove(tempDir) + + dbPath := filepath.Join(tempDir, "db") db, err := walletdb.Create(dbType, dbPath, true) if err != nil { t.Errorf("Failed to create test database (%s) %v", dbType, err) return } - defer os.Remove(dbPath) defer db.Close() // Create a namespace and put some values into it so they can be tested diff --git a/walletdb/bdb/interface_test.go b/walletdb/bdb/interface_test.go index 1dcf605e01..3755b1d690 100644 --- a/walletdb/bdb/interface_test.go +++ b/walletdb/bdb/interface_test.go @@ -13,7 +13,9 @@ package bdb_test import ( + "io/ioutil" "os" + "path/filepath" "testing" "github.com/btcsuite/btcwallet/walletdb/walletdbtest" @@ -21,7 +23,14 @@ import ( // TestInterface performs all interfaces tests for this database driver. func TestInterface(t *testing.T) { - dbPath := "interfacetest.db" + tempDir, err := ioutil.TempDir("", "interfacetest") + if err != nil { + t.Errorf("unable to create temp dir: %v", err) + return + } + defer os.Remove(tempDir) + + dbPath := filepath.Join(tempDir, "db") defer os.RemoveAll(dbPath) walletdbtest.TestInterface(t, dbType, dbPath, true) } diff --git a/walletdb/db_test.go b/walletdb/db_test.go index 48b60c3111..30c4341bc8 100644 --- a/walletdb/db_test.go +++ b/walletdb/db_test.go @@ -6,7 +6,9 @@ package walletdb_test import ( "fmt" + "io/ioutil" "os" + "path/filepath" "testing" "github.com/btcsuite/btcwallet/walletdb" @@ -54,14 +56,20 @@ func TestAddDuplicateDriver(t *testing.T) { "got %v, want %v", err, walletdb.ErrDbTypeRegistered) } - dbPath := "dupdrivertest.db" + tempDir, err := ioutil.TempDir("", "dupdrivertest") + if err != nil { + t.Errorf("unable to create temp dir: %v", err) + return + } + defer os.Remove(tempDir) + + dbPath := filepath.Join(tempDir, "db") db, err := walletdb.Create(dbType, dbPath, true) if err != nil { t.Errorf("failed to create database: %v", err) return } db.Close() - _ = os.Remove(dbPath) } diff --git a/walletdb/go.mod b/walletdb/go.mod index a93460855a..59f6db3d65 100644 --- a/walletdb/go.mod +++ b/walletdb/go.mod @@ -4,6 +4,9 @@ go 1.12 require ( github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f + github.com/coreos/bbolt v1.3.3 github.com/davecgh/go-spew v1.1.1 - go.etcd.io/bbolt v1.3.4 + go.etcd.io/bbolt v1.3.3 // indirect + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/sys v0.0.0-20190904154756-749cb33beabd // indirect ) diff --git a/walletdb/go.sum b/walletdb/go.sum index baadeb0e77..ca356ac361 100644 --- a/walletdb/go.sum +++ b/walletdb/go.sum @@ -1,8 +1,12 @@ github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY= +github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= -go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=