mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
lntest: assert CustomRecords
fields on channel policy
Make sure the `CustomRecords` field is asserted.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user