@@ -14,8 +14,8 @@ import (
1414)
1515
1616var  (
17- 	testTime1  =  time .Unix (32100 , 0 )
18- 	testTime2  =  time .Unix (12300 , 0 )
17+ 	testTime1  =  time .Unix (12300 , 0 )
18+ 	testTime2  =  time .Unix (32100 , 0 )
1919)
2020
2121// TestActionStorage tests that the ActionsListDB CRUD logic. 
@@ -67,7 +67,7 @@ func TestActionStorage(t *testing.T) {
6767	action1Req  :=  & AddActionReq {
6868		SessionID :          fn .Some (sess1 .ID ),
6969		AccountID :          fn .Some (acct1 .ID ),
70- 		MacaroonIdentifier : sess1 .ID ,
70+ 		MacaroonIdentifier : fn . Some ([ 4 ] byte ( sess1 .ID )) ,
7171		ActorName :          "Autopilot" ,
7272		FeatureName :        "auto-fees" ,
7373		Trigger :            "fee too low" ,
@@ -85,7 +85,7 @@ func TestActionStorage(t *testing.T) {
8585
8686	action2Req  :=  & AddActionReq {
8787		SessionID :          fn .Some (sess2 .ID ),
88- 		MacaroonIdentifier : sess2 .ID ,
88+ 		MacaroonIdentifier : fn . Some ([ 4 ] byte ( sess2 .ID )) ,
8989		ActorName :          "Autopilot" ,
9090		FeatureName :        "rebalancer" ,
9191		Trigger :            "channels not balanced" ,
@@ -161,7 +161,7 @@ func TestActionStorage(t *testing.T) {
161161
162162	// Check that providing no session id and no filter function returns 
163163	// all the actions. 
164- 	actions , _ , _ , err  =  db .ListActions (nil , & ListActionsQuery {
164+ 	actions , _ , _ , err  =  db .ListActions (ctx , & ListActionsQuery {
165165		IndexOffset : 0 ,
166166		MaxNum :      100 ,
167167		Reversed :    false ,
@@ -223,7 +223,7 @@ func TestListActions(t *testing.T) {
223223		actionIds ++ 
224224
225225		actionReq  :=  & AddActionReq {
226- 			MacaroonIdentifier : sessionID ,
226+ 			MacaroonIdentifier : fn . Some ( sessionID ) ,
227227			ActorName :          "Autopilot" ,
228228			FeatureName :        fmt .Sprintf ("%d" , actionIds ),
229229			Trigger :            "fee too low" ,
@@ -245,9 +245,11 @@ func TestListActions(t *testing.T) {
245245	assertActions  :=  func (dbActions  []* Action , al  []* action ) {
246246		require .Len (t , dbActions , len (al ))
247247		for  i , a  :=  range  al  {
248- 			require . EqualValues (
249- 				t ,  a . sessionID ,  dbActions [ i ]. MacaroonIdentifier ,
248+ 			mID ,  err   :=   dbActions [ i ]. MacaroonIdentifier . UnwrapOrErr (
249+ 				fmt . Errorf ( "macaroon identifier is none" ) ,
250250			)
251+ 			require .NoError (t , err )
252+ 			require .EqualValues (t , a .sessionID , mID )
251253			require .Equal (t , a .actionID , dbActions [i ].FeatureName )
252254		}
253255	}
@@ -433,7 +435,7 @@ func TestListGroupActions(t *testing.T) {
433435
434436	action1Req  :=  & AddActionReq {
435437		SessionID :          fn .Some (sess1 .ID ),
436- 		MacaroonIdentifier : sess1 .ID ,
438+ 		MacaroonIdentifier : fn . Some ([ 4 ] byte ( sess1 .ID )) ,
437439		ActorName :          "Autopilot" ,
438440		FeatureName :        "auto-fees" ,
439441		Trigger :            "fee too low" ,
@@ -451,7 +453,7 @@ func TestListGroupActions(t *testing.T) {
451453
452454	action2Req  :=  & AddActionReq {
453455		SessionID :          fn .Some (sess2 .ID ),
454- 		MacaroonIdentifier : sess2 .ID ,
456+ 		MacaroonIdentifier : fn . Some ([ 4 ] byte ( sess2 .ID )) ,
455457		ActorName :          "Autopilot" ,
456458		FeatureName :        "rebalancer" ,
457459		Trigger :            "channels not balanced" ,
@@ -495,12 +497,22 @@ func TestListGroupActions(t *testing.T) {
495497	_ , err  =  db .AddAction (ctx , action2Req )
496498	require .NoError (t , err )
497499
498- 	// There should now be actions in the group. 
500+ 	// There should now be two  actions in the group. 
499501	al , _ , _ , err  =  db .ListActions (ctx , nil , WithActionGroupID (group1 ))
500502	require .NoError (t , err )
501503	require .Len (t , al , 2 )
502504	assertEqualActions (t , action1 , al [0 ])
503505	assertEqualActions (t , action2 , al [1 ])
506+ 
507+ 	// Try the reversed query too. 
508+ 	al , _ , _ , err  =  db .ListActions (
509+ 		ctx , & ListActionsQuery {Reversed : true },
510+ 		WithActionGroupID (group1 ),
511+ 	)
512+ 	require .NoError (t , err )
513+ 	require .Len (t , al , 2 )
514+ 	assertEqualActions (t , action2 , al [0 ])
515+ 	assertEqualActions (t , action1 , al [1 ])
504516}
505517
506518func  assertEqualActions (t  * testing.T , expected , got  * Action ) {
0 commit comments