@@ -9,12 +9,11 @@ import (
9
9
"time"
10
10
11
11
"github.com/lightninglabs/lightning-terminal/accounts"
12
- "github.com/lightninglabs/lightning-terminal/db"
13
12
"github.com/lightninglabs/lightning-terminal/db/sqlc"
14
13
"github.com/lightninglabs/lightning-terminal/session"
15
14
"github.com/lightningnetwork/lnd/clock"
16
15
"github.com/lightningnetwork/lnd/fn"
17
- "github.com/lightningnetwork/lnd/sqldb"
16
+ "github.com/lightningnetwork/lnd/sqldb/v2 "
18
17
"github.com/stretchr/testify/require"
19
18
"golang.org/x/exp/rand"
20
19
)
@@ -54,7 +53,7 @@ func TestFirewallDBMigration(t *testing.T) {
54
53
}
55
54
56
55
makeSQLDB := func (t * testing.T , sessionsStore session.Store ) (* SQLDB ,
57
- * db. TransactionExecutor [SQLQueries ]) {
56
+ * SQLQueriesExecutor [SQLQueries ]) {
58
57
59
58
testDBStore := NewTestDBWithSessions (t , sessionsStore , clock )
60
59
@@ -63,13 +62,9 @@ func TestFirewallDBMigration(t *testing.T) {
63
62
64
63
baseDB := store .BaseDB
65
64
66
- genericExecutor := db .NewTransactionExecutor (
67
- baseDB , func (tx * sql.Tx ) SQLQueries {
68
- return baseDB .WithTx (tx )
69
- },
70
- )
65
+ queries := sqlc .NewForType (baseDB , baseDB .BackendType )
71
66
72
- return store , genericExecutor
67
+ return store , NewSQLQueriesExecutor ( baseDB , queries )
73
68
}
74
69
75
70
// The assertMigrationResults function will currently assert that
@@ -88,7 +83,9 @@ func TestFirewallDBMigration(t *testing.T) {
88
83
getRuleID := func (ruleName string ) int64 {
89
84
ruleID , ok := ruleIDs [ruleName ]
90
85
if ! ok {
91
- ruleID , err = store .GetRuleID (ctx , ruleName )
86
+ ruleID , err = store .db .GetRuleID (
87
+ ctx , ruleName ,
88
+ )
92
89
require .NoError (t , err )
93
90
94
91
ruleIDs [ruleName ] = ruleID
@@ -100,7 +97,7 @@ func TestFirewallDBMigration(t *testing.T) {
100
97
getGroupID := func (groupAlias []byte ) int64 {
101
98
groupID , ok := groupIDs [string (groupAlias )]
102
99
if ! ok {
103
- groupID , err = store .GetSessionIDByAlias (
100
+ groupID , err = store .db . GetSessionIDByAlias (
104
101
ctx , groupAlias ,
105
102
)
106
103
require .NoError (t , err )
@@ -114,7 +111,7 @@ func TestFirewallDBMigration(t *testing.T) {
114
111
getFeatureID := func (featureName string ) int64 {
115
112
featureID , ok := featureIDs [featureName ]
116
113
if ! ok {
117
- featureID , err = store .GetFeatureID (
114
+ featureID , err = store .db . GetFeatureID (
118
115
ctx , featureName ,
119
116
)
120
117
require .NoError (t , err )
@@ -128,7 +125,7 @@ func TestFirewallDBMigration(t *testing.T) {
128
125
// First we extract all migrated kv entries from the SQLDB,
129
126
// in order to be able to compare them to the original kv
130
127
// entries, to ensure that the migration was successful.
131
- sqlKvEntries , err := store .ListAllKVStoresRecords (ctx )
128
+ sqlKvEntries , err := store .db . ListAllKVStoresRecords (ctx )
132
129
require .NoError (t , err )
133
130
require .Equal (t , len (kvEntries ), len (sqlKvEntries ))
134
131
@@ -144,7 +141,7 @@ func TestFirewallDBMigration(t *testing.T) {
144
141
ruleID := getRuleID (entry .ruleName )
145
142
146
143
if entry .groupAlias .IsNone () {
147
- sqlVal , err := store .GetGlobalKVStoreRecord (
144
+ sqlVal , err := store .db . GetGlobalKVStoreRecord (
148
145
ctx ,
149
146
sqlc.GetGlobalKVStoreRecordParams {
150
147
Key : entry .key ,
@@ -162,7 +159,7 @@ func TestFirewallDBMigration(t *testing.T) {
162
159
groupAlias := entry .groupAlias .UnwrapOrFail (t )
163
160
groupID := getGroupID (groupAlias [:])
164
161
165
- v , err := store .GetGroupKVStoreRecord (
162
+ v , err := store .db . GetGroupKVStoreRecord (
166
163
ctx ,
167
164
sqlc.GetGroupKVStoreRecordParams {
168
165
Key : entry .key ,
@@ -187,7 +184,7 @@ func TestFirewallDBMigration(t *testing.T) {
187
184
entry .featureName .UnwrapOrFail (t ),
188
185
)
189
186
190
- sqlVal , err := store .GetFeatureKVStoreRecord (
187
+ sqlVal , err := store .db . GetFeatureKVStoreRecord (
191
188
ctx ,
192
189
sqlc.GetFeatureKVStoreRecordParams {
193
190
Key : entry .key ,
@@ -302,7 +299,7 @@ func TestFirewallDBMigration(t *testing.T) {
302
299
return MigrateFirewallDBToSQL (
303
300
ctx , firewallStore .DB , tx ,
304
301
)
305
- },
302
+ }, sqldb . NoOpReset ,
306
303
)
307
304
require .NoError (t , err )
308
305
0 commit comments