routing: update test edge policy fields to include max htlc + new flags

Since the MaxHTLC field was recently added to the ChannelEdgePolicy struct,
and the Flags field was broken into ChannelFlags and MessageFlags, the
test edge policies should be updated accordingly.
This commit is contained in:
Valentine Wallace committed 2019-03-01 08:05:27 -08:00
1 parent a2dafdef37
commit 348a66ed13
5 files changed
+215 -99

No files matched your search

+26 -6
View File
@@ -89,9 +89,11 @@ type testChan struct {
Node2 string `json:"node_2"`
ChannelID uint64 `json:"channel_id"`
ChannelPoint string `json:"channel_point"`
Flags uint16 `json:"flags"`
ChannelFlags uint8 `json:"channel_flags"`
MessageFlags uint8 `json:"message_flags"`
Expiry uint16 `json:"expiry"`
MinHTLC int64 `json:"min_htlc"`
MaxHTLC int64 `json:"max_htlc"`
FeeBaseMsat int64 `json:"fee_base_msat"`
FeeRate int64 `json:"fee_rate"`
Capacity int64 `json:"capacity"`
@@ -271,12 +273,13 @@ func parseTestGraph(path string) (*testGraphInstance, error) {
edgePolicy := &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
MessageFlags: lnwire.ChanUpdateMsgFlags(edge.Flags >> 8),
ChannelFlags: lnwire.ChanUpdateChanFlags(edge.Flags),
MessageFlags: lnwire.ChanUpdateMsgFlags(edge.MessageFlags),
ChannelFlags: lnwire.ChanUpdateChanFlags(edge.ChannelFlags),
ChannelID: edge.ChannelID,
LastUpdate: testTime,
TimeLockDelta: edge.Expiry,
MinHTLC: lnwire.MilliSatoshi(edge.MinHTLC),
MaxHTLC: lnwire.MilliSatoshi(edge.MaxHTLC),
FeeBaseMSat: lnwire.MilliSatoshi(edge.FeeBaseMsat),
FeeProportionalMillionths: lnwire.MilliSatoshi(edge.FeeRate),
}
@@ -295,6 +298,7 @@ func parseTestGraph(path string) (*testGraphInstance, error) {
type testChannelPolicy struct {
Expiry uint16
MinHTLC lnwire.MilliSatoshi
MaxHTLC lnwire.MilliSatoshi
FeeBaseMsat lnwire.MilliSatoshi
FeeRate lnwire.MilliSatoshi
}
@@ -304,12 +308,13 @@ type testChannelEnd struct {
testChannelPolicy
}
func defaultTestChannelEnd(alias string) *testChannelEnd {
func defaultTestChannelEnd(alias string, capacity btcutil.Amount) *testChannelEnd {
return &testChannelEnd{
Alias: alias,
testChannelPolicy: testChannelPolicy{
Expiry: 144,
MinHTLC: lnwire.MilliSatoshi(1000),
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
FeeBaseMsat: lnwire.MilliSatoshi(1000),
FeeRate: lnwire.MilliSatoshi(1),
},
@@ -486,14 +491,19 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
return nil, err
}
var msgFlags lnwire.ChanUpdateMsgFlags
if testChannel.Node1.MaxHTLC != 0 {
msgFlags = 1
}
edgePolicy := &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
MessageFlags: 0,
MessageFlags: msgFlags,
ChannelFlags: 0,
ChannelID: channelID,
LastUpdate: testTime,
TimeLockDelta: testChannel.Node1.Expiry,
MinHTLC: testChannel.Node1.MinHTLC,
MaxHTLC: testChannel.Node1.MaxHTLC,
FeeBaseMSat: testChannel.Node1.FeeBaseMsat,
FeeProportionalMillionths: testChannel.Node1.FeeRate,
}
@@ -501,14 +511,19 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
return nil, err
}
msgFlags = 0
if testChannel.Node2.MaxHTLC != 0 {
msgFlags = 1
}
edgePolicy = &channeldb.ChannelEdgePolicy{
SigBytes: testSig.Serialize(),
MessageFlags: 0,
MessageFlags: msgFlags,
ChannelFlags: lnwire.ChanUpdateDirection,
ChannelID: channelID,
LastUpdate: testTime,
TimeLockDelta: testChannel.Node2.Expiry,
MinHTLC: testChannel.Node2.MinHTLC,
MaxHTLC: testChannel.Node2.MaxHTLC,
FeeBaseMSat: testChannel.Node2.FeeBaseMsat,
FeeProportionalMillionths: testChannel.Node2.FeeRate,
}
@@ -543,26 +558,31 @@ func TestFindLowestFeePath(t *testing.T) {
Expiry: 144,
FeeRate: 400,
MinHTLC: 1,
MaxHTLC: 100000000,
}),
symmetricTestChannel("first", "a", 100000, &testChannelPolicy{
Expiry: 144,
FeeRate: 400,
MinHTLC: 1,
MaxHTLC: 100000000,
}),
symmetricTestChannel("a", "target", 100000, &testChannelPolicy{
Expiry: 144,
FeeRate: 400,
MinHTLC: 1,
MaxHTLC: 100000000,
}),
symmetricTestChannel("first", "b", 100000, &testChannelPolicy{
Expiry: 144,
FeeRate: 100,
MinHTLC: 1,
MaxHTLC: 100000000,
}),
symmetricTestChannel("b", "target", 100000, &testChannelPolicy{
Expiry: 144,
FeeRate: 600,
MinHTLC: 1,
MaxHTLC: 100000000,
}),
}