invoices: add TestSpontaneousAmpPayment

Adds a set of test cases that exercise the spontaneous AMP payment flow
with valid and invalid reconstructions, as well as with single and
multiple HTLCs. This also asserts that spontaneous AMP is gated behind
the existing AcceptKeysend flag.
This commit is contained in:
Conner Fromknecht
2021-03-24 19:52:18 -07:00
parent 90a255078d
commit ea934e1be9
3 changed files with 262 additions and 0 deletions

View File

@@ -180,6 +180,23 @@ func (f FailResolutionResult) FailureString() string {
}
}
// IsSetFailure returns true if this failure should result in the entire HTLC
// set being failed with the same result.
func (f FailResolutionResult) IsSetFailure() bool {
switch f {
case
ResultAmpReconstruction,
ResultHtlcSetTotalTooLow,
ResultHtlcSetTotalMismatch,
ResultHtlcSetOverpayment:
return true
default:
return false
}
}
// SettleResolutionResult provides metadata which about a htlc that was failed
// by the registry. It can be used to take custom actions on resolution of the
// htlc.