multi: rename chan DB Open method to OpenForTesting
This commit is contained in:
24 files changed
+101
-331
No files matched your search
@@ -635,15 +635,6 @@ func TestMockRetributionStore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeTestChannelDB(t *testing.T) (*channeldb.DB, error) {
|
||||
db, err := channeldb.Open(t.TempDir())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// TestChannelDBRetributionStore instantiates a retributionStore backed by a
|
||||
// channeldb.DB, and tests its behavior using the general RetributionStore test
|
||||
// suite.
|
||||
@@ -654,25 +645,19 @@ func TestChannelDBRetributionStore(t *testing.T) {
|
||||
t.Run(
|
||||
"channeldbDBRetributionStore."+test.name,
|
||||
func(tt *testing.T) {
|
||||
db, err := makeTestChannelDB(t)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to open channeldb: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
db := channeldb.OpenForTesting(t, t.TempDir())
|
||||
|
||||
restartDb := func() RetributionStorer {
|
||||
// Close and reopen channeldb
|
||||
if err = db.Close(); err != nil {
|
||||
if err := db.Close(); err != nil {
|
||||
t.Fatalf("unable to close "+
|
||||
"channeldb during "+
|
||||
"restart: %v",
|
||||
err)
|
||||
}
|
||||
db, err = channeldb.Open(db.Path())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to open "+
|
||||
"channeldb: %v", err)
|
||||
}
|
||||
db = channeldb.OpenForTesting(
|
||||
t, db.Path(),
|
||||
)
|
||||
|
||||
return NewRetributionStore(db)
|
||||
}
|
||||
@@ -2279,21 +2264,8 @@ func createInitChannels(t *testing.T) (
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
dbAlice, err := channeldb.Open(t.TempDir())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, dbAlice.Close())
|
||||
})
|
||||
|
||||
dbBob, err := channeldb.Open(t.TempDir())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, dbBob.Close())
|
||||
})
|
||||
dbAlice := channeldb.OpenForTesting(t, t.TempDir())
|
||||
dbBob := channeldb.OpenForTesting(t, t.TempDir())
|
||||
|
||||
estimator := chainfee.NewStaticEstimator(12500, 0)
|
||||
feePerKw, err := estimator.EstimateFeePerKW(1)
|
||||
|
||||
@@ -22,13 +22,7 @@ import (
|
||||
func TestChainArbitratorRepublishCloses(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, err := channeldb.Open(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, db.Close())
|
||||
})
|
||||
db := channeldb.OpenForTesting(t, t.TempDir())
|
||||
|
||||
// Create 10 test channels and sync them to the database.
|
||||
const numChans = 10
|
||||
@@ -139,11 +133,7 @@ func TestChainArbitratorRepublishCloses(t *testing.T) {
|
||||
func TestResolveContract(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, err := channeldb.Open(t.TempDir())
|
||||
require.NoError(t, err, "unable to open db")
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, db.Close())
|
||||
})
|
||||
db := channeldb.OpenForTesting(t, t.TempDir())
|
||||
|
||||
// With the DB created, we'll make a new channel, and mark it as
|
||||
// pending open within the database.
|
||||
|
||||
@@ -65,12 +65,9 @@ func copyChannelState(t *testing.T, state *channeldb.OpenChannel) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
newDb, err := channeldb.Open(tempDbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newDB := channeldb.OpenForTesting(t, tempDbPath)
|
||||
|
||||
chans, err := newDb.ChannelStateDB().FetchAllChannels()
|
||||
chans, err := newDB.ChannelStateDB().FetchAllChannels()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user