channeldb/test: make hop record comparison stricter

This commit is contained in:
Joost Jager 2019-09-10 15:40:10 +02:00
parent 5d016f8c62
commit 7f4af8f9ae
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -228,10 +228,21 @@ func TestSentPaymentSerialization(t *testing.T) {
}
func assertRouteHopRecordsEqual(r1, r2 *route.Route) error {
if len(r1.Hops) != len(r2.Hops) {
return errors.New("route hop count mismatch")
}
for i := 0; i < len(r1.Hops); i++ {
for j := 0; j < len(r1.Hops[i].TLVRecords); j++ {
expectedRecord := r1.Hops[i].TLVRecords[j]
newRecord := r2.Hops[i].TLVRecords[j]
records1 := r1.Hops[i].TLVRecords
records2 := r2.Hops[i].TLVRecords
if len(records1) != len(records2) {
return fmt.Errorf("route record count for hop %v "+
"mismatch", i)
}
for j := 0; j < len(records1); j++ {
expectedRecord := records1[j]
newRecord := records2[j]
err := assertHopRecordsEqual(expectedRecord, newRecord)
if err != nil {