@@ -14,11 +14,23 @@ import (
1414var (
1515 testTime1 = time .Unix (32100 , 0 )
1616 testTime2 = time .Unix (12300 , 0 )
17+ )
18+
19+ // TestActionStorage tests that the ActionsListDB CRUD logic.
20+ func TestActionStorage (t * testing.T ) {
21+ t .Parallel ()
1722
18- sessionID1 = intToSessionID ( 1 )
19- sessionID2 = intToSessionID ( 2 )
23+ ctx := context . Background ( )
24+ clock := clock . NewTestClock ( testTime1 )
2025
21- action1Req = & AddActionReq {
26+ db , err := NewBoltDB (t .TempDir (), "test.db" , nil , clock )
27+ require .NoError (t , err )
28+ t .Cleanup (func () {
29+ _ = db .Close ()
30+ })
31+
32+ sessionID1 := intToSessionID (1 )
33+ action1Req := & AddActionReq {
2234 SessionID : fn .Some (sessionID1 ),
2335 MacaroonIdentifier : sessionID1 ,
2436 ActorName : "Autopilot" ,
@@ -30,13 +42,14 @@ var (
3042 RPCParamsJson : []byte ("new fee" ),
3143 }
3244
33- action1 = & Action {
45+ action1 : = & Action {
3446 AddActionReq : * action1Req ,
3547 AttemptedAt : testTime1 ,
3648 State : ActionStateDone ,
3749 }
3850
39- action2Req = & AddActionReq {
51+ sessionID2 := intToSessionID (2 )
52+ action2Req := & AddActionReq {
4053 SessionID : fn .Some (sessionID2 ),
4154 MacaroonIdentifier : sessionID2 ,
4255 ActorName : "Autopilot" ,
@@ -47,23 +60,11 @@ var (
4760 RPCParamsJson : []byte ("hops, amount" ),
4861 }
4962
50- action2 = & Action {
63+ action2 : = & Action {
5164 AddActionReq : * action2Req ,
5265 AttemptedAt : testTime2 ,
5366 State : ActionStateInit ,
5467 }
55- )
56-
57- // TestActionStorage tests that the ActionsListDB CRUD logic.
58- func TestActionStorage (t * testing.T ) {
59- ctx := context .Background ()
60- clock := clock .NewTestClock (testTime1 )
61-
62- db , err := NewBoltDB (t .TempDir (), "test.db" , nil , clock )
63- require .NoError (t , err )
64- t .Cleanup (func () {
65- _ = db .Close ()
66- })
6768
6869 actions , _ , _ , err := db .ListActions (
6970 ctx , nil ,
@@ -157,6 +158,8 @@ func TestActionStorage(t *testing.T) {
157158// TestListActions tests some ListAction options.
158159// TODO(elle): cover more test cases here.
159160func TestListActions (t * testing.T ) {
161+ t .Parallel ()
162+
160163 tmpDir := t .TempDir ()
161164 ctx := context .Background ()
162165
@@ -357,6 +360,43 @@ func TestListGroupActions(t *testing.T) {
357360
358361 group1 := intToSessionID (0 )
359362
363+ sessionID1 := intToSessionID (1 )
364+ action1Req := & AddActionReq {
365+ SessionID : fn .Some (sessionID1 ),
366+ MacaroonIdentifier : sessionID1 ,
367+ ActorName : "Autopilot" ,
368+ FeatureName : "auto-fees" ,
369+ Trigger : "fee too low" ,
370+ Intent : "increase fee" ,
371+ StructuredJsonData : "{\" something\" :\" nothing\" }" ,
372+ RPCMethod : "UpdateChanPolicy" ,
373+ RPCParamsJson : []byte ("new fee" ),
374+ }
375+
376+ action1 := & Action {
377+ AddActionReq : * action1Req ,
378+ AttemptedAt : testTime1 ,
379+ State : ActionStateDone ,
380+ }
381+
382+ sessionID2 := intToSessionID (2 )
383+ action2Req := & AddActionReq {
384+ SessionID : fn .Some (sessionID2 ),
385+ MacaroonIdentifier : sessionID2 ,
386+ ActorName : "Autopilot" ,
387+ FeatureName : "rebalancer" ,
388+ Trigger : "channels not balanced" ,
389+ Intent : "balance" ,
390+ RPCMethod : "SendToRoute" ,
391+ RPCParamsJson : []byte ("hops, amount" ),
392+ }
393+
394+ action2 := & Action {
395+ AddActionReq : * action2Req ,
396+ AttemptedAt : testTime2 ,
397+ State : ActionStateInit ,
398+ }
399+
360400 // Link session 1 and session 2 to group 1.
361401 index := NewMockSessionDB ()
362402 index .AddPair (sessionID1 , group1 )
0 commit comments