mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-03 08:41:33 +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
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -725,5 +726,27 @@ func CheckChannelPolicy(policy, expectedPolicy *lnrpc.RoutingPolicy) error {
|
|||||||
return errors.New("edge should be disabled but isn't")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user