walletdb: update tests to use db timeout param
This commit is contained in:
parent
28c804ccc8
commit
08308c81ed
2 changed files with 9 additions and 4 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcwallet/walletdb"
|
"github.com/btcsuite/btcwallet/walletdb"
|
||||||
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
|
||||||
|
@ -21,6 +22,10 @@ var (
|
||||||
// bogus drivers for testing purposes while still allowing other tests
|
// bogus drivers for testing purposes while still allowing other tests
|
||||||
// to easily iterate all supported drivers.
|
// to easily iterate all supported drivers.
|
||||||
ignoreDbTypes = map[string]bool{"createopenfail": true}
|
ignoreDbTypes = map[string]bool{"createopenfail": true}
|
||||||
|
|
||||||
|
// defaultDBTimeout specifies the timeout value when opening the wallet
|
||||||
|
// database.
|
||||||
|
defaultDBTimeout = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestAddDuplicateDriver ensures that adding a duplicate driver does not
|
// TestAddDuplicateDriver ensures that adding a duplicate driver does not
|
||||||
|
@ -64,7 +69,7 @@ func TestAddDuplicateDriver(t *testing.T) {
|
||||||
defer os.Remove(tempDir)
|
defer os.Remove(tempDir)
|
||||||
|
|
||||||
dbPath := filepath.Join(tempDir, "db")
|
dbPath := filepath.Join(tempDir, "db")
|
||||||
db, err := walletdb.Create(dbType, dbPath, true)
|
db, err := walletdb.Create(dbType, dbPath, true, defaultDBTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to create database: %v", err)
|
t.Errorf("failed to create database: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -28,7 +28,7 @@ func ExampleCreate() {
|
||||||
// this, but it's done here in the example to ensure the example cleans
|
// this, but it's done here in the example to ensure the example cleans
|
||||||
// up after itself.
|
// up after itself.
|
||||||
dbPath := filepath.Join(os.TempDir(), "examplecreate.db")
|
dbPath := filepath.Join(os.TempDir(), "examplecreate.db")
|
||||||
db, err := walletdb.Create("bdb", dbPath, true)
|
db, err := walletdb.Create("bdb", dbPath, true, defaultDBTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
@ -47,7 +47,7 @@ var exampleNum = 0
|
||||||
func exampleLoadDB() (walletdb.DB, func(), error) {
|
func exampleLoadDB() (walletdb.DB, func(), error) {
|
||||||
dbName := fmt.Sprintf("exampleload%d.db", exampleNum)
|
dbName := fmt.Sprintf("exampleload%d.db", exampleNum)
|
||||||
dbPath := filepath.Join(os.TempDir(), dbName)
|
dbPath := filepath.Join(os.TempDir(), dbName)
|
||||||
db, err := walletdb.Create("bdb", dbPath, true)
|
db, err := walletdb.Create("bdb", dbPath, true, defaultDBTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ func Example_basicUsage() {
|
||||||
// this, but it's done here in the example to ensure the example cleans
|
// this, but it's done here in the example to ensure the example cleans
|
||||||
// up after itself.
|
// up after itself.
|
||||||
dbPath := filepath.Join(os.TempDir(), "exampleusage.db")
|
dbPath := filepath.Join(os.TempDir(), "exampleusage.db")
|
||||||
db, err := walletdb.Create("bdb", dbPath, true)
|
db, err := walletdb.Create("bdb", dbPath, true, defaultDBTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue