htlcswitch/hodl: add flag BogusSettle
This commit adds a new hodl flag "BogusSettle" which will be used to emulate a node trying to settle back an incoming HTLC with a fake preimage.
This commit is contained in:
parent
88670175c7
commit
71a1aae417
@ -21,6 +21,8 @@ type Config struct {
|
||||
FailOutgoing bool `long:"fail-outgoing" description:"Instructs the node to drop outgoing FAILs before applying them to the channel state"`
|
||||
|
||||
Commit bool `long:"commit" description:"Instructs the node to add HTLCs to its local commitment state and to open circuits for any ADDs, but abort before committing the changes"`
|
||||
|
||||
BogusSettle bool `long:"bogus-settle" description:"Instructs the node to settle back any incoming HTLC with a bogus preimage"`
|
||||
}
|
||||
|
||||
// Mask extracts the flags specified in the configuration, composing a Mask from
|
||||
@ -52,6 +54,9 @@ func (c *Config) Mask() Mask {
|
||||
if c.Commit {
|
||||
flags = append(flags, Commit)
|
||||
}
|
||||
if c.BogusSettle {
|
||||
flags = append(flags, BogusSettle)
|
||||
}
|
||||
|
||||
// NOTE: The value returned here will only honor the configuration if
|
||||
// the debug build flag is present. In production, this method always
|
||||
|
@ -51,6 +51,10 @@ const (
|
||||
// Commit drops all HTLC after any outgoing circuits have been
|
||||
// opened, but before the in-memory commitment state is persisted.
|
||||
Commit
|
||||
|
||||
// BogusSettle attempts to settle back any incoming HTLC for which we
|
||||
// are the exit node with a bogus preimage.
|
||||
BogusSettle
|
||||
)
|
||||
|
||||
// String returns a human-readable identifier for a given Flag.
|
||||
@ -72,6 +76,8 @@ func (f Flag) String() string {
|
||||
return "FailOutgoing"
|
||||
case Commit:
|
||||
return "Commit"
|
||||
case BogusSettle:
|
||||
return "BogusSettle"
|
||||
default:
|
||||
return "UnknownHodlFlag"
|
||||
}
|
||||
@ -98,6 +104,8 @@ func (f Flag) Warning() string {
|
||||
msg = "will not update channel state with downstream FAIL"
|
||||
case Commit:
|
||||
msg = "will not commit pending channel updates"
|
||||
case BogusSettle:
|
||||
msg = "will settle HTLC with bogus preimage"
|
||||
default:
|
||||
msg = "incorrect hodl flag usage"
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ var hodlMaskTests = []struct {
|
||||
hodl.SettleOutgoing,
|
||||
hodl.FailOutgoing,
|
||||
hodl.Commit,
|
||||
hodl.BogusSettle,
|
||||
),
|
||||
flags: map[hodl.Flag]struct{}{
|
||||
hodl.ExitSettle: {},
|
||||
@ -77,6 +78,7 @@ var hodlMaskTests = []struct {
|
||||
hodl.SettleOutgoing: {},
|
||||
hodl.FailOutgoing: {},
|
||||
hodl.Commit: {},
|
||||
hodl.BogusSettle: {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user