Skip to content

Commit

Permalink
Merge pull request #690 from wpaulino/walletdb-revert-bolt-v1.3.4
Browse files Browse the repository at this point in the history
walletdb: revert bolt v1.3.4
  • Loading branch information
Roasbeef committed Apr 3, 2020
2 parents 237a3ee + 57be08f commit 2fed914
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion walletdb/bdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 18 additions & 4 deletions walletdb/bdb/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package bdb_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion walletdb/bdb/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@
package bdb_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/btcsuite/btcwallet/walletdb/walletdbtest"
)

// 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)
}
12 changes: 10 additions & 2 deletions walletdb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package walletdb_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/btcsuite/btcwallet/walletdb"
Expand Down Expand Up @@ -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)

}

Expand Down
5 changes: 4 additions & 1 deletion walletdb/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
12 changes: 8 additions & 4 deletions walletdb/go.sum
Original file line number Diff line number Diff line change
@@ -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=

0 comments on commit 2fed914

Please sign in to comment.