7
7
"time"
8
8
9
9
"github.com/lightninglabs/lightning-terminal/accounts"
10
+ litmac "github.com/lightninglabs/lightning-terminal/macaroons"
10
11
"github.com/lightninglabs/lightning-terminal/session"
11
12
"github.com/lightningnetwork/lnd/clock"
12
13
"github.com/lightningnetwork/lnd/fn"
@@ -60,10 +61,12 @@ func TestActionStorage(t *testing.T) {
60
61
acct1 , err := accountsDB .NewAccount (ctx , 0 , time.Time {}, "foo" )
61
62
require .NoError (t , err )
62
63
64
+ sess1RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess1 .ID )
65
+
63
66
action1Req := & AddActionReq {
64
67
SessionID : fn .Some (sess1 .ID ),
65
68
AccountID : fn .Some (acct1 .ID ),
66
- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess1 . ID ) ),
69
+ MacaroonRootKeyID : fn .Some (sess1RootKeyID ),
67
70
ActorName : "Autopilot" ,
68
71
FeatureName : "auto-fees" ,
69
72
Trigger : "fee too low" ,
@@ -79,15 +82,17 @@ func TestActionStorage(t *testing.T) {
79
82
State : ActionStateDone ,
80
83
}
81
84
85
+ sess2RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess2 .ID )
86
+
82
87
action2Req := & AddActionReq {
83
- SessionID : fn .Some (sess2 .ID ),
84
- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess2 . ID ) ),
85
- ActorName : "Autopilot" ,
86
- FeatureName : "rebalancer" ,
87
- Trigger : "channels not balanced" ,
88
- Intent : "balance" ,
89
- RPCMethod : "SendToRoute" ,
90
- RPCParamsJson : []byte ("hops, amount" ),
88
+ SessionID : fn .Some (sess2 .ID ),
89
+ MacaroonRootKeyID : fn .Some (sess2RootKeyID ),
90
+ ActorName : "Autopilot" ,
91
+ FeatureName : "rebalancer" ,
92
+ Trigger : "channels not balanced" ,
93
+ Intent : "balance" ,
94
+ RPCMethod : "SendToRoute" ,
95
+ RPCParamsJson : []byte ("hops, amount" ),
91
96
}
92
97
93
98
action2 := & Action {
@@ -213,8 +218,10 @@ func TestListActions(t *testing.T) {
213
218
addAction := func (sessionID [4 ]byte ) {
214
219
actionIds ++
215
220
221
+ sessRootKeyID := litmac .NewSuperMacaroonRootKeyID (sessionID )
222
+
216
223
actionReq := & AddActionReq {
217
- MacaroonIdentifier : fn .Some (sessionID ),
224
+ MacaroonRootKeyID : fn .Some (sessRootKeyID ),
218
225
ActorName : "Autopilot" ,
219
226
FeatureName : fmt .Sprintf ("%d" , actionIds ),
220
227
Trigger : "fee too low" ,
@@ -236,11 +243,9 @@ func TestListActions(t *testing.T) {
236
243
assertActions := func (dbActions []* Action , al []* action ) {
237
244
require .Len (t , dbActions , len (al ))
238
245
for i , a := range al {
239
- mID , err := dbActions [ i ]. MacaroonIdentifier . UnwrapOrErr (
240
- fmt . Errorf ( "macaroon identifier is none" ),
246
+ require . EqualValues (
247
+ t , a . sessionID , dbActions [ i ]. MacaroonId ( ),
241
248
)
242
- require .NoError (t , err )
243
- require .EqualValues (t , a .sessionID , mID )
244
249
require .Equal (t , a .actionID , dbActions [i ].FeatureName )
245
250
}
246
251
}
@@ -424,9 +429,11 @@ func TestListGroupActions(t *testing.T) {
424
429
)
425
430
require .NoError (t , err )
426
431
432
+ sess1RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess1 .ID )
433
+
427
434
action1Req := & AddActionReq {
428
435
SessionID : fn .Some (sess1 .ID ),
429
- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess1 . ID ) ),
436
+ MacaroonRootKeyID : fn .Some (sess1RootKeyID ),
430
437
ActorName : "Autopilot" ,
431
438
FeatureName : "auto-fees" ,
432
439
Trigger : "fee too low" ,
@@ -442,15 +449,17 @@ func TestListGroupActions(t *testing.T) {
442
449
State : ActionStateDone ,
443
450
}
444
451
452
+ sess2RootKeyID := litmac .NewSuperMacaroonRootKeyID (sess2 .ID )
453
+
445
454
action2Req := & AddActionReq {
446
- SessionID : fn .Some (sess2 .ID ),
447
- MacaroonIdentifier : fn .Some ([ 4 ] byte ( sess2 . ID ) ),
448
- ActorName : "Autopilot" ,
449
- FeatureName : "rebalancer" ,
450
- Trigger : "channels not balanced" ,
451
- Intent : "balance" ,
452
- RPCMethod : "SendToRoute" ,
453
- RPCParamsJson : []byte ("hops, amount" ),
455
+ SessionID : fn .Some (sess2 .ID ),
456
+ MacaroonRootKeyID : fn .Some (sess2RootKeyID ),
457
+ ActorName : "Autopilot" ,
458
+ FeatureName : "rebalancer" ,
459
+ Trigger : "channels not balanced" ,
460
+ Intent : "balance" ,
461
+ RPCMethod : "SendToRoute" ,
462
+ RPCParamsJson : []byte ("hops, amount" ),
454
463
}
455
464
456
465
action2 := & Action {
0 commit comments