From f6ea9d4d7b184845f7a8fe68c49f8dbc6270c409 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 12 Aug 2020 03:51:32 +0800 Subject: [PATCH] waddrmgr: update tests to use db timeout param --- waddrmgr/common_test.go | 8 ++++++-- waddrmgr/manager_test.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/waddrmgr/common_test.go b/waddrmgr/common_test.go index 20493fe..d14301e 100644 --- a/waddrmgr/common_test.go +++ b/waddrmgr/common_test.go @@ -200,6 +200,10 @@ var ( // expectedInternalAddrs is the list of expected internal addresses // generated from the seed expectedInternalAddrs = expectedAddrs[5:] + + // defaultDBTimeout specifies the timeout value when opening the wallet + // database. + defaultDBTimeout = 10 * time.Second ) // checkManagerError ensures the passed error is a ManagerError with an error @@ -238,7 +242,7 @@ func emptyDB(t *testing.T) (tearDownFunc func(), db walletdb.DB) { t.Fatalf("Failed to create db temp dir: %v", err) } dbPath := filepath.Join(dirName, "mgrtest.db") - db, err = walletdb.Create("bdb", dbPath, true) + db, err = walletdb.Create("bdb", dbPath, true, defaultDBTimeout) if err != nil { _ = os.RemoveAll(dirName) t.Fatalf("createDbNamespace: unexpected error: %v", err) @@ -259,7 +263,7 @@ func setupManager(t *testing.T) (tearDownFunc func(), db walletdb.DB, mgr *Manag t.Fatalf("Failed to create db temp dir: %v", err) } dbPath := filepath.Join(dirName, "mgrtest.db") - db, err = walletdb.Create("bdb", dbPath, true) + db, err = walletdb.Create("bdb", dbPath, true, defaultDBTimeout) if err != nil { _ = os.RemoveAll(dirName) t.Fatalf("createDbNamespace: unexpected error: %v", err) diff --git a/waddrmgr/manager_test.go b/waddrmgr/manager_test.go index 0db0a88..c4667ad 100644 --- a/waddrmgr/manager_test.go +++ b/waddrmgr/manager_test.go @@ -1683,7 +1683,7 @@ func testConvertWatchingOnly(tc *testContext) bool { defer os.Remove(woMgrName) // Open the new database copy and get the address manager namespace. - db, err := walletdb.Open("bdb", woMgrName, true) + db, err := walletdb.Open("bdb", woMgrName, true, defaultDBTimeout) if err != nil { tc.t.Errorf("openDbNamespace: unexpected error: %v", err) return false