diff --git a/lntest/node/watcher.go b/lntest/node/watcher.go index b075c08ab..08f1facfe 100644 --- a/lntest/node/watcher.go +++ b/lntest/node/watcher.go @@ -1,6 +1,7 @@ package node import ( + "bytes" "context" "encoding/json" "errors" @@ -725,5 +726,27 @@ func CheckChannelPolicy(policy, expectedPolicy *lnrpc.RoutingPolicy) error { return errors.New("edge should be disabled but isn't") } + // We now validate custom records. + records := policy.CustomRecords + + if len(records) != len(expectedPolicy.CustomRecords) { + return fmt.Errorf("expected %v CustomRecords, got %v, "+ + "records: %v", len(expectedPolicy.CustomRecords), + len(records), records) + } + + expectedRecords := expectedPolicy.CustomRecords + for k, record := range records { + expected, found := expectedRecords[k] + if !found { + return fmt.Errorf("CustomRecords %v not found", k) + } + + if !bytes.Equal(record, expected) { + return fmt.Errorf("want CustomRecords(%v) %s, got %s", + k, expected, record) + } + } + return nil }