Skip to content

Commit 92c2ccb

Browse files
firewalldb: update NewTestDB funcs to return FirewallDBs
1 parent b197b45 commit 92c2ccb

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

firewalldb/test_kvdb.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,46 @@ import (
66
"testing"
77

88
"github.com/lightninglabs/lightning-terminal/accounts"
9+
"github.com/lightninglabs/lightning-terminal/session"
910
"github.com/lightningnetwork/lnd/clock"
1011
"github.com/lightningnetwork/lnd/fn"
1112
"github.com/stretchr/testify/require"
1213
)
1314

1415
// NewTestDB is a helper function that creates an BBolt database for testing.
15-
func NewTestDB(t *testing.T, clock clock.Clock) *BoltDB {
16+
func NewTestDB(t *testing.T, clock clock.Clock) FirewallDBs {
1617
return NewTestDBFromPath(t, t.TempDir(), clock)
1718
}
1819

1920
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
2021
// connection to an existing BBolt database for testing.
21-
func NewTestDBFromPath(t *testing.T, dbPath string, clock clock.Clock) *BoltDB {
22+
func NewTestDBFromPath(t *testing.T, dbPath string,
23+
clock clock.Clock) FirewallDBs {
24+
2225
return newDBFromPathWithSessions(t, dbPath, nil, nil, clock)
2326
}
2427

2528
// NewTestDBWithSessions creates a new test BoltDB Store with access to an
2629
// existing sessions DB.
27-
func NewTestDBWithSessions(t *testing.T, sessStore SessionDB,
28-
clock clock.Clock) *BoltDB {
30+
func NewTestDBWithSessions(t *testing.T, sessStore session.Store,
31+
clock clock.Clock) FirewallDBs {
2932

3033
return newDBFromPathWithSessions(t, t.TempDir(), sessStore, nil, clock)
3134
}
3235

3336
// NewTestDBWithSessionsAndAccounts creates a new test BoltDB Store with access
3437
// to an existing sessions DB and accounts DB.
35-
func NewTestDBWithSessionsAndAccounts(t *testing.T, sessStore SessionDB,
36-
acctStore AccountsDB, clock clock.Clock) *BoltDB {
38+
func NewTestDBWithSessionsAndAccounts(t *testing.T, sessStore session.Store,
39+
acctStore AccountsDB, clock clock.Clock) FirewallDBs {
3740

3841
return newDBFromPathWithSessions(
3942
t, t.TempDir(), sessStore, acctStore, clock,
4043
)
4144
}
4245

4346
func newDBFromPathWithSessions(t *testing.T, dbPath string,
44-
sessStore SessionDB, acctStore AccountsDB, clock clock.Clock) *BoltDB {
47+
sessStore session.Store, acctStore AccountsDB,
48+
clock clock.Clock) FirewallDBs {
4549

4650
store, err := NewBoltDB(dbPath, DBFilename, sessStore, acctStore, clock)
4751
require.NoError(t, err)

firewalldb/test_postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
)
1111

1212
// NewTestDB is a helper function that creates an BBolt database for testing.
13-
func NewTestDB(t *testing.T, clock clock.Clock) *SQLDB {
13+
func NewTestDB(t *testing.T, clock clock.Clock) FirewallDBs {
1414
return NewSQLDB(db.NewTestPostgresDB(t).BaseDB, clock)
1515
}
1616

1717
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
1818
// connection to an existing BBolt database for testing.
19-
func NewTestDBFromPath(t *testing.T, _ string, clock clock.Clock) *SQLDB {
19+
func NewTestDBFromPath(t *testing.T, _ string, clock clock.Clock) FirewallDBs {
2020
return NewSQLDB(db.NewTestPostgresDB(t).BaseDB, clock)
2121
}

firewalldb/test_sql.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import (
1515
// NewTestDBWithSessions creates a new test SQLDB Store with access to an
1616
// existing sessions DB.
1717
func NewTestDBWithSessions(t *testing.T, sessionStore session.Store,
18-
clock clock.Clock) *SQLDB {
19-
18+
clock clock.Clock) FirewallDBs {
2019
sessions, ok := sessionStore.(*session.SQLStore)
2120
require.True(t, ok)
2221

@@ -26,7 +25,7 @@ func NewTestDBWithSessions(t *testing.T, sessionStore session.Store,
2625
// NewTestDBWithSessionsAndAccounts creates a new test SQLDB Store with access
2726
// to an existing sessions DB and accounts DB.
2827
func NewTestDBWithSessionsAndAccounts(t *testing.T, sessionStore SessionDB,
29-
acctStore AccountsDB, clock clock.Clock) *SQLDB {
28+
acctStore AccountsDB, clock clock.Clock) FirewallDBs {
3029

3130
sessions, ok := sessionStore.(*session.SQLStore)
3231
require.True(t, ok)

firewalldb/test_sqlite.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import (
1010
)
1111

1212
// NewTestDB is a helper function that creates an BBolt database for testing.
13-
func NewTestDB(t *testing.T, clock clock.Clock) *SQLDB {
13+
func NewTestDB(t *testing.T, clock clock.Clock) FirewallDBs {
1414
return NewSQLDB(db.NewTestSqliteDB(t).BaseDB, clock)
1515
}
1616

1717
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
1818
// connection to an existing BBolt database for testing.
19-
func NewTestDBFromPath(t *testing.T, dbPath string, clock clock.Clock) *SQLDB {
19+
func NewTestDBFromPath(t *testing.T, dbPath string,
20+
clock clock.Clock) FirewallDBs {
21+
2022
return NewSQLDB(
2123
db.NewTestSqliteDbHandleFromPath(t, dbPath).BaseDB, clock,
2224
)

0 commit comments

Comments
 (0)