Skip to content

Commit

Permalink
htlcswitch/test: add forward mock result
Browse files Browse the repository at this point in the history
  • Loading branch information
joostjager committed Oct 23, 2019
1 parent cb85095 commit 4ea8927
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions htlcswitch/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,9 @@ type mockChannelLink struct {

htlcID uint64

htlcSatifiesPolicyLocalResult lnwire.FailureMessage
checkHtlcTransitResult lnwire.FailureMessage

checkHtlcForwardResult lnwire.FailureMessage
}

// completeCircuit is a helper method for adding the finalized payment circuit
Expand Down Expand Up @@ -701,14 +703,15 @@ func (f *mockChannelLink) UpdateForwardingPolicy(_ ForwardingPolicy) {
}
func (f *mockChannelLink) CheckHtlcForward([32]byte, lnwire.MilliSatoshi,
lnwire.MilliSatoshi, uint32, uint32, uint32) lnwire.FailureMessage {
return nil

return f.checkHtlcForwardResult
}

func (f *mockChannelLink) CheckHtlcTransit(payHash [32]byte,
amt lnwire.MilliSatoshi, timeout uint32,
heightNow uint32) lnwire.FailureMessage {

return f.htlcSatifiesPolicyLocalResult
return f.checkHtlcTransitResult
}

func (f *mockChannelLink) Stats() (uint64, lnwire.MilliSatoshi, lnwire.MilliSatoshi) {
Expand Down
2 changes: 1 addition & 1 deletion htlcswitch/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ func testSkipLinkLocalForward(t *testing.T, eligible bool,
aliceChannelLink := newMockChannelLink(
s, chanID1, aliceChanID, alicePeer, eligible,
)
aliceChannelLink.htlcSatifiesPolicyLocalResult = policyResult
aliceChannelLink.checkHtlcTransitResult = policyResult
if err := s.AddLink(aliceChannelLink); err != nil {
t.Fatalf("unable to add alice link: %v", err)
}
Expand Down

0 comments on commit 4ea8927

Please sign in to comment.