htlcswitch: add new TestUpdateFailMalformedHTLCErrorConversion test
In this commit, we add a new test to ensure that we're able to properly convert malformed HTLC errors that are sourced from multiple hops away, or our direct channel peers. In order to test this effectively, we force the onion decryptors of various peers to always fail which will trigger the malformed HTLC logic.
This commit is contained in:
3 files changed
+96
-8
No files matched your search
@@ -368,7 +368,10 @@ func (o *mockObfuscator) EncryptFirstHop(failure lnwire.FailureMessage) (
|
||||
|
||||
func (o *mockObfuscator) IntermediateEncrypt(reason lnwire.OpaqueReason) lnwire.OpaqueReason {
|
||||
return reason
|
||||
}
|
||||
|
||||
func (o *mockObfuscator) EncryptMalformedError(reason lnwire.OpaqueReason) lnwire.OpaqueReason {
|
||||
return reason
|
||||
}
|
||||
|
||||
// mockDeobfuscator mock implementation of the failure deobfuscator which
|
||||
@@ -400,6 +403,8 @@ type mockIteratorDecoder struct {
|
||||
mu sync.RWMutex
|
||||
|
||||
responses map[[32]byte][]DecodeHopIteratorResponse
|
||||
|
||||
decodeFail bool
|
||||
}
|
||||
|
||||
func newMockIteratorDecoder() *mockIteratorDecoder {
|
||||
@@ -451,6 +456,10 @@ func (p *mockIteratorDecoder) DecodeHopIterators(id []byte,
|
||||
req.OnionReader, req.RHash, req.IncomingCltv,
|
||||
)
|
||||
|
||||
if p.decodeFail {
|
||||
failcode = lnwire.CodeTemporaryChannelFailure
|
||||
}
|
||||
|
||||
resp := DecodeHopIteratorResponse{
|
||||
HopIterator: iterator,
|
||||
FailCode: failcode,
|
||||
|
||||
Reference in new issue
Block a user