From 68d1753dcbff3fba4a28a7eaa0660869a4e755cf Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 7 Apr 2020 11:56:22 -0700 Subject: [PATCH] htlcswitch/test_utils: send htlcs before waiting for result This commit is preparation for the test added in the subsequent commit. We modify makeHoldPayment to return any failures direectly when trying to add an HTLC to the switch. This lets us know that the HTLC was indeed sent without failure when the method returns. --- htlcswitch/test_utils.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 0d6f3b4db..c997c4f90 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -1345,15 +1345,13 @@ func (n *twoHopNetwork) makeHoldPayment(sendingPeer, receivingPeer lnpeer.Peer, } // Send payment and expose err channel. - go func() { - err := sender.htlcSwitch.SendHTLC( - firstHop, pid, htlc, - ) - if err != nil { - paymentErr <- err - return - } + err = sender.htlcSwitch.SendHTLC(firstHop, pid, htlc) + if err != nil { + paymentErr <- err + return paymentErr + } + go func() { resultChan, err := sender.htlcSwitch.GetPaymentResult( pid, rhash, newMockDeobfuscator(), )