-
Notifications
You must be signed in to change notification settings - Fork 109
[sql-37] firewalldb: more preparations for SQL actions store #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
297313e
8f7312f
b60dc29
3e963c0
f6e66db
9018cd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/lightninglabs/lightning-terminal/session" | ||
| "github.com/lightningnetwork/lnd/fn" | ||
| ) | ||
|
|
||
| // ActionState represents the state of an action. | ||
|
|
@@ -32,10 +33,17 @@ const ( | |
| // It contains all the information that is needed to create a new Action in the | ||
| // ActionStateInit State. | ||
| type AddActionReq struct { | ||
| // SessionID is the ID of the session that this action belongs to. | ||
| // Note that this is not serialized on persistence since the action is | ||
| // already stored under a bucket identified by the session ID. | ||
| SessionID session.ID | ||
| // MacaroonIdentifier is a 4 byte identifier created from the last 4 | ||
| // bytes of the root key ID of the macaroon used to perform the action. | ||
| MacaroonIdentifier [4]byte | ||
|
|
||
| // SessionID holds the optional session ID of the session that this | ||
| // action was performed with. | ||
| // | ||
| // NOTE: for our BoltDB impl, this is not persisted in any way, and we | ||
| // populate it by casting the macaroon ID to a session.ID and so is not | ||
| // guaranteed to be linked to an existing session. | ||
| SessionID fn.Option[session.ID] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if there's a test anywhere for an intercepted action, where we don't set this (i.e. it's not related to a session request). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah i'll expand on the tests for SQL (where it actually will matter if it is set or not) once we've added the sql impl here 👍 |
||
|
|
||
| // ActorName is the name of the entity who performed the Action. | ||
| ActorName string | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/lightningnetwork/lnd/clock" | ||
| "github.com/lightningnetwork/lnd/fn" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
|
|
@@ -18,7 +19,8 @@ var ( | |
| sessionID2 = intToSessionID(2) | ||
|
|
||
| action1Req = &AddActionReq{ | ||
| SessionID: sessionID1, | ||
| SessionID: fn.Some(sessionID1), | ||
| MacaroonIdentifier: sessionID1, | ||
| ActorName: "Autopilot", | ||
| FeatureName: "auto-fees", | ||
| Trigger: "fee too low", | ||
|
|
@@ -35,13 +37,14 @@ var ( | |
| } | ||
|
|
||
| action2Req = &AddActionReq{ | ||
| SessionID: sessionID2, | ||
| ActorName: "Autopilot", | ||
| FeatureName: "rebalancer", | ||
| Trigger: "channels not balanced", | ||
| Intent: "balance", | ||
| RPCMethod: "SendToRoute", | ||
| RPCParamsJson: []byte("hops, amount"), | ||
| SessionID: fn.Some(sessionID2), | ||
| MacaroonIdentifier: sessionID2, | ||
| ActorName: "Autopilot", | ||
| FeatureName: "rebalancer", | ||
| Trigger: "channels not balanced", | ||
| Intent: "balance", | ||
| RPCMethod: "SendToRoute", | ||
| RPCParamsJson: []byte("hops, amount"), | ||
| } | ||
|
|
||
| action2 = &Action{ | ||
|
|
@@ -171,7 +174,7 @@ func TestListActions(t *testing.T) { | |
| actionIds++ | ||
|
|
||
| actionReq := &AddActionReq{ | ||
| SessionID: sessionID, | ||
| MacaroonIdentifier: sessionID, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. want to keep the tests as close to how they are today as possible - then will expand the tests to cover more cases once the SQL impl is added 👍 |
||
| ActorName: "Autopilot", | ||
| FeatureName: fmt.Sprintf("%d", actionIds), | ||
| Trigger: "fee too low", | ||
|
|
@@ -194,7 +197,7 @@ func TestListActions(t *testing.T) { | |
| require.Len(t, dbActions, len(al)) | ||
| for i, a := range al { | ||
| require.EqualValues( | ||
| t, a.sessionID, dbActions[i].SessionID, | ||
| t, a.sessionID, dbActions[i].MacaroonIdentifier, | ||
| ) | ||
| require.Equal(t, a.actionID, dbActions[i].FeatureName) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably not worth it to have another type alias for
[4]byte?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we dont use this in other places - so i think it's ok for now