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.
This commit is contained in:
Conner Fromknecht 2020-04-07 11:56:22 -07:00
parent 5a057de5c4
commit 68d1753dcb
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

View File

@ -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(),
)