@@ -91,32 +91,35 @@ func TestSessionsStoreMigration(t *testing.T) {
9191		populateDB  func (
9292			t  * testing.T , kvStore  * BoltStore ,
9393			accountStore  accounts.Store ,
94- 		)
94+ 		) [] * Session 
9595	}{
9696		{
9797			name : "empty" ,
9898			populateDB : func (t  * testing.T , store  * BoltStore ,
99- 				_  accounts.Store ) {
99+ 				_  accounts.Store ) [] * Session   {
100100
101101				// Don't populate the DB. 
102+ 				return  []* Session {}
102103			},
103104		},
104105		{
105106			name : "one session no options" ,
106107			populateDB : func (t  * testing.T , store  * BoltStore ,
107- 				_  accounts.Store ) {
108+ 				_  accounts.Store ) [] * Session   {
108109
109- 				_ , err  :=  store .NewSession (
110+ 				sess , err  :=  store .NewSession (
110111					ctx , "test" , TypeMacaroonAdmin ,
111112					time .Unix (1000 , 0 ), "" ,
112113				)
113114				require .NoError (t , err )
115+ 
116+ 				return  []* Session {sess }
114117			},
115118		},
116119		{
117120			name : "multiple sessions no options" ,
118121			populateDB : func (t  * testing.T , store  * BoltStore ,
119- 				_  accounts.Store ) {
122+ 				_  accounts.Store ) [] * Session   {
120123
121124				_ , err  :=  store .NewSession (
122125					ctx , "session1" , TypeMacaroonAdmin ,
@@ -135,27 +138,34 @@ func TestSessionsStoreMigration(t *testing.T) {
135138					time .Unix (1000 , 0 ), "" ,
136139				)
137140				require .NoError (t , err )
141+ 
142+ 				kvSessions , err  :=  store .ListAllSessions (ctx )
143+ 				require .NoError (t , err )
144+ 
145+ 				return  kvSessions 
138146			},
139147		},
140148		{
141149			name : "one session with one privacy flag" ,
142150			populateDB : func (t  * testing.T , store  * BoltStore ,
143- 				_  accounts.Store ) {
151+ 				_  accounts.Store ) [] * Session   {
144152
145- 				_ , err  :=  store .NewSession (
153+ 				sess , err  :=  store .NewSession (
146154					ctx , "test" , TypeMacaroonAdmin ,
147155					time .Unix (1000 , 0 ), "" ,
148156					WithPrivacy (PrivacyFlags {ClearPubkeys }),
149157				)
150158				require .NoError (t , err )
159+ 
160+ 				return  []* Session {sess }
151161			},
152162		},
153163		{
154164			name : "one session with multiple privacy flags" ,
155165			populateDB : func (t  * testing.T , store  * BoltStore ,
156- 				_  accounts.Store ) {
166+ 				_  accounts.Store ) [] * Session   {
157167
158- 				_ , err  :=  store .NewSession (
168+ 				sess , err  :=  store .NewSession (
159169					ctx , "test" , TypeMacaroonAdmin ,
160170					time .Unix (1000 , 0 ), "" ,
161171					WithPrivacy (PrivacyFlags {
@@ -164,99 +174,113 @@ func TestSessionsStoreMigration(t *testing.T) {
164174					}),
165175				)
166176				require .NoError (t , err )
177+ 
178+ 				return  []* Session {sess }
167179			},
168180		},
169181		{
170182			name : "one session with a feature config" ,
171183			populateDB : func (t  * testing.T , store  * BoltStore ,
172- 				_  accounts.Store ) {
184+ 				_  accounts.Store ) [] * Session   {
173185
174186				featureConfig  :=  map [string ][]byte {
175187					"AutoFees" :      {1 , 2 , 3 , 4 },
176188					"AutoSomething" : {4 , 3 , 4 , 5 , 6 , 6 },
177189				}
178190
179- 				_ , err  :=  store .NewSession (
191+ 				sess , err  :=  store .NewSession (
180192					ctx , "test" , TypeMacaroonAdmin ,
181193					time .Unix (1000 , 0 ), "" ,
182194					WithFeatureConfig (featureConfig ),
183195				)
184196				require .NoError (t , err )
197+ 
198+ 				return  []* Session {sess }
185199			},
186200		},
187201		{
188202			name : "one session with dev server" ,
189203			populateDB : func (t  * testing.T , store  * BoltStore ,
190- 				_  accounts.Store ) {
204+ 				_  accounts.Store ) [] * Session   {
191205
192- 				_ , err  :=  store .NewSession (
206+ 				sess , err  :=  store .NewSession (
193207					ctx , "test" , TypeMacaroonAdmin ,
194208					time .Unix (1000 , 0 ), "" ,
195209					WithDevServer (),
196210				)
197211				require .NoError (t , err )
212+ 
213+ 				return  []* Session {sess }
198214			},
199215		},
200216		{
201217			name : "one session with macaroon recipe" ,
202218			populateDB : func (t  * testing.T , store  * BoltStore ,
203- 				_  accounts.Store ) {
219+ 				_  accounts.Store ) [] * Session   {
204220
205221				// this test uses caveats & perms from the 
206222				// tlv_test.go 
207- 				_ , err  :=  store .NewSession (
223+ 				sess , err  :=  store .NewSession (
208224					ctx , "test" , TypeMacaroonAdmin ,
209225					time .Unix (1000 , 0 ), "foo.bar.baz:1234" ,
210226					WithMacaroonRecipe (caveats , perms ),
211227				)
212228				require .NoError (t , err )
229+ 
230+ 				return  []* Session {sess }
213231			},
214232		},
215233		{
216234			name : "one session with macaroon recipe nil caveats" ,
217235			populateDB : func (t  * testing.T , store  * BoltStore ,
218- 				_  accounts.Store ) {
236+ 				_  accounts.Store ) [] * Session   {
219237
220238				// this test uses perms from the tlv_test.go 
221- 				_ , err  :=  store .NewSession (
239+ 				sess , err  :=  store .NewSession (
222240					ctx , "test" , TypeMacaroonAdmin ,
223241					time .Unix (1000 , 0 ), "foo.bar.baz:1234" ,
224242					WithMacaroonRecipe (nil , perms ),
225243				)
226244				require .NoError (t , err )
245+ 
246+ 				return  []* Session {sess }
227247			},
228248		},
229249		{
230250			name : "one session with macaroon recipe nil perms" ,
231251			populateDB : func (t  * testing.T , store  * BoltStore ,
232- 				_  accounts.Store ) {
252+ 				_  accounts.Store ) [] * Session   {
233253
234254				// this test uses caveats from the tlv_test.go 
235- 				_ , err  :=  store .NewSession (
255+ 				sess , err  :=  store .NewSession (
236256					ctx , "test" , TypeMacaroonAdmin ,
237257					time .Unix (1000 , 0 ), "foo.bar.baz:1234" ,
238258					WithMacaroonRecipe (caveats , nil ),
239259				)
240260				require .NoError (t , err )
261+ 
262+ 				return  []* Session {sess }
241263			},
242264		},
243265		{
244266			name : "macaroon recipe with nil perms and caveats" ,
245267			populateDB : func (t  * testing.T , store  * BoltStore ,
246- 				_  accounts.Store ) {
268+ 				_  accounts.Store ) [] * Session   {
247269
248- 				_ , err  :=  store .NewSession (
270+ 				sess , err  :=  store .NewSession (
249271					ctx , "test" , TypeMacaroonAdmin ,
250272					time .Unix (1000 , 0 ), "foo.bar.baz:1234" ,
251273					WithMacaroonRecipe (nil , nil ),
252274				)
253275				require .NoError (t , err )
276+ 
277+ 				return  []* Session {sess }
254278			},
255279		},
256280		{
257281			name : "one session with a linked account" ,
258282			populateDB : func (t  * testing.T , store  * BoltStore ,
259- 				acctStore  accounts.Store ) {
283+ 				acctStore  accounts.Store ) [] * Session   {
260284
261285				// Create an account with balance 
262286				acct , err  :=  acctStore .NewAccount (
@@ -289,12 +313,17 @@ func TestSessionsStoreMigration(t *testing.T) {
289313					WithMacaroonRecipe (sessCaveats , nil ),
290314				)
291315				require .NoError (t , err )
316+ 
317+ 				kvSessions , err  :=  store .ListAllSessions (ctx )
318+ 				require .NoError (t , err )
319+ 
320+ 				return  kvSessions 
292321			},
293322		},
294323		{
295324			name : "linked session" ,
296325			populateDB : func (t  * testing.T , store  * BoltStore ,
297- 				_  accounts.Store ) {
326+ 				_  accounts.Store ) [] * Session   {
298327
299328				// First create the initial session for the 
300329				// group. 
@@ -325,6 +354,11 @@ func TestSessionsStoreMigration(t *testing.T) {
325354					WithLinkedGroupID (& sess1 .ID ),
326355				)
327356				require .NoError (t , err )
357+ 
358+ 				kvSessions , err  :=  store .ListAllSessions (ctx )
359+ 				require .NoError (t , err )
360+ 
361+ 				return  kvSessions 
328362			},
329363		},
330364		{
@@ -355,15 +389,7 @@ func TestSessionsStoreMigration(t *testing.T) {
355389
356390			// populate the kvStore with the test data, in 
357391			// preparation for the test. 
358- 			test .populateDB (t , kvStore , accountStore )
359- 
360- 			// Before we migrate the sessions, we fetch all sessions 
361- 			// from the kv store, to ensure that the migration 
362- 			// function doesn't mutate the bbolt store sessions. 
363- 			// We can then compare them to the sql sessions after 
364- 			// the migration has been executed. 
365- 			kvSessions , err  :=  kvStore .ListAllSessions (ctx )
366- 			require .NoError (t , err )
392+ 			kvSessions  :=  test .populateDB (t , kvStore , accountStore )
367393
368394			// Proceed to create the sql store and execute the 
369395			// migration. 
@@ -392,7 +418,7 @@ func TestSessionsStoreMigration(t *testing.T) {
392418// them will contain up to 10 linked sessions. The rest of the session will have 
393419// the rest of the session options randomized. 
394420func  randomizedSessions (t  * testing.T , kvStore  * BoltStore ,
395- 	accountsStore  accounts.Store ) {
421+ 	accountsStore  accounts.Store ) [] * Session   {
396422
397423	ctx  :=  context .Background ()
398424
@@ -547,6 +573,11 @@ func randomizedSessions(t *testing.T, kvStore *BoltStore,
547573		err  =  shiftStateUnsafe (kvStore , activeSess .ID , lastState (i ))
548574		require .NoError (t , err )
549575	}
576+ 
577+ 	kvSessions , err  :=  kvStore .ListAllSessions (ctx )
578+ 	require .NoError (t , err )
579+ 
580+ 	return  kvSessions 
550581}
551582
552583// macaroonType returns a macaroon type based on the given index by taking the 
0 commit comments