@@ -14,11 +14,23 @@ import (
14
14
var (
15
15
testTime1 = time .Unix (32100 , 0 )
16
16
testTime2 = time .Unix (12300 , 0 )
17
+ )
18
+
19
+ // TestActionStorage tests that the ActionsListDB CRUD logic.
20
+ func TestActionStorage (t * testing.T ) {
21
+ t .Parallel ()
17
22
18
- sessionID1 = intToSessionID ( 1 )
19
- sessionID2 = intToSessionID ( 2 )
23
+ ctx := context . Background ( )
24
+ clock := clock . NewTestClock ( testTime1 )
20
25
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 {
22
34
SessionID : fn .Some (sessionID1 ),
23
35
MacaroonIdentifier : sessionID1 ,
24
36
ActorName : "Autopilot" ,
@@ -30,13 +42,14 @@ var (
30
42
RPCParamsJson : []byte ("new fee" ),
31
43
}
32
44
33
- action1 = & Action {
45
+ action1 : = & Action {
34
46
AddActionReq : * action1Req ,
35
47
AttemptedAt : testTime1 ,
36
48
State : ActionStateDone ,
37
49
}
38
50
39
- action2Req = & AddActionReq {
51
+ sessionID2 := intToSessionID (2 )
52
+ action2Req := & AddActionReq {
40
53
SessionID : fn .Some (sessionID2 ),
41
54
MacaroonIdentifier : sessionID2 ,
42
55
ActorName : "Autopilot" ,
@@ -47,23 +60,11 @@ var (
47
60
RPCParamsJson : []byte ("hops, amount" ),
48
61
}
49
62
50
- action2 = & Action {
63
+ action2 : = & Action {
51
64
AddActionReq : * action2Req ,
52
65
AttemptedAt : testTime2 ,
53
66
State : ActionStateInit ,
54
67
}
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
- })
67
68
68
69
actions , _ , _ , err := db .ListActions (
69
70
ctx , nil ,
@@ -157,6 +158,8 @@ func TestActionStorage(t *testing.T) {
157
158
// TestListActions tests some ListAction options.
158
159
// TODO(elle): cover more test cases here.
159
160
func TestListActions (t * testing.T ) {
161
+ t .Parallel ()
162
+
160
163
tmpDir := t .TempDir ()
161
164
ctx := context .Background ()
162
165
@@ -357,6 +360,43 @@ func TestListGroupActions(t *testing.T) {
357
360
358
361
group1 := intToSessionID (0 )
359
362
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
+
360
400
// Link session 1 and session 2 to group 1.
361
401
index := NewMockSessionDB ()
362
402
index .AddPair (sessionID1 , group1 )
0 commit comments