mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
brontide: remove handshake helper function
Move the functionality directly into completeHandshake instead. If a failure does happen at any point during the handshake, it is beneficial to know which line it happens on for debugging. The helper function was hiding this information.
This commit is contained in:
parent
6397497bb6
commit
eb31d47094
1 changed files with 8 additions and 16 deletions
|
@ -59,43 +59,35 @@ var (
|
|||
// and completes the brontide handshake between them. If any part of the
|
||||
// handshake fails, this function will panic.
|
||||
func completeHandshake(t *testing.T, initiator, responder *Machine) {
|
||||
t.Helper()
|
||||
|
||||
if err := handshake(initiator, responder); err != nil {
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
}
|
||||
|
||||
// handshake actually completes the brontide handshake and bubbles up
|
||||
// an error to the calling function.
|
||||
func handshake(initiator, responder *Machine) error {
|
||||
// Generate ActOne and send to the responder.
|
||||
actOne, err := initiator.GenActOne()
|
||||
if err != nil {
|
||||
return err
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
|
||||
if err := responder.RecvActOne(actOne); err != nil {
|
||||
return err
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
|
||||
// Generate ActTwo and send to initiator.
|
||||
actTwo, err := responder.GenActTwo()
|
||||
if err != nil {
|
||||
return err
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
|
||||
if err := initiator.RecvActTwo(actTwo); err != nil {
|
||||
return err
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
|
||||
// Generate ActThree and send to responder.
|
||||
actThree, err := initiator.GenActThree()
|
||||
if err != nil {
|
||||
return err
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
|
||||
return responder.RecvActThree(actThree)
|
||||
if err := responder.RecvActThree(actThree); err != nil {
|
||||
dumpAndFail(t, initiator, responder, err)
|
||||
}
|
||||
}
|
||||
|
||||
// dumpAndFail dumps the initiator and responder Machines and fails.
|
||||
|
|
Loading…
Add table
Reference in a new issue