Skip to content

Commit

Permalink
routing/route: fix TestMPPHop comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Jan 28, 2020
1 parent 0cb2715 commit 9fc197d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions routing/route/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,47 @@ func TestMPPHop(t *testing.T) {
}
}

// TestAMPHop asserts that a Hop will encode a non-nil AMP to final nodes of an
// MPP record is also present, and fail otherwise.
func TestAMPHop(t *testing.T) {
t.Parallel()

hop := Hop{
ChannelID: 1,
OutgoingTimeLock: 44,
AmtToForward: testAmt,
LegacyPayload: false,
AMP: record.NewAMP([32]byte{}, [32]byte{}, 3),
}

// Encoding an AMP record to an intermediate hop w/o an MPP record
// should result in a failure.
var b bytes.Buffer
err := hop.PackHopPayload(&b, 2)
if err != ErrAMPMissingMPP {
t.Fatalf("expected err: %v, got: %v",
ErrAMPMissingMPP, err)
}

// Encoding an AMP record to a final hop w/o an MPP record should result
// in a failure.
b.Reset()
err = hop.PackHopPayload(&b, 0)
if err != ErrAMPMissingMPP {
t.Fatalf("expected err: %v, got: %v",
ErrAMPMissingMPP, err)
}

// Encoding an AMP record to a final hop w/ an MPP record should be
// successful.
hop.MPP = record.NewMPP(testAmt, testAddr)
b.Reset()
err = hop.PackHopPayload(&b, 0)
if err != nil {
t.Fatalf("expected err: %v, got: %v", nil, err)
}
}

// TestPayloadSize tests the payload size calculation that is provided by Hop
// structs.
func TestPayloadSize(t *testing.T) {
Expand Down

0 comments on commit 9fc197d

Please sign in to comment.