routing: make test channel policies optional
This commit is contained in:
parent
5173ef6f85
commit
29664c9704
@ -307,13 +307,13 @@ type testChannelPolicy struct {
|
|||||||
|
|
||||||
type testChannelEnd struct {
|
type testChannelEnd struct {
|
||||||
Alias string
|
Alias string
|
||||||
testChannelPolicy
|
*testChannelPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultTestChannelEnd(alias string, capacity btcutil.Amount) *testChannelEnd {
|
func defaultTestChannelEnd(alias string, capacity btcutil.Amount) *testChannelEnd {
|
||||||
return &testChannelEnd{
|
return &testChannelEnd{
|
||||||
Alias: alias,
|
Alias: alias,
|
||||||
testChannelPolicy: testChannelPolicy{
|
testChannelPolicy: &testChannelPolicy{
|
||||||
Expiry: 144,
|
Expiry: 144,
|
||||||
MinHTLC: lnwire.MilliSatoshi(1000),
|
MinHTLC: lnwire.MilliSatoshi(1000),
|
||||||
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
|
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
|
||||||
@ -337,11 +337,11 @@ func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
|||||||
Capacity: capacity,
|
Capacity: capacity,
|
||||||
Node1: &testChannelEnd{
|
Node1: &testChannelEnd{
|
||||||
Alias: alias1,
|
Alias: alias1,
|
||||||
testChannelPolicy: *policy,
|
testChannelPolicy: policy,
|
||||||
},
|
},
|
||||||
Node2: &testChannelEnd{
|
Node2: &testChannelEnd{
|
||||||
Alias: alias2,
|
Alias: alias2,
|
||||||
testChannelPolicy: *policy,
|
testChannelPolicy: policy,
|
||||||
},
|
},
|
||||||
ChannelID: id,
|
ChannelID: id,
|
||||||
}
|
}
|
||||||
@ -490,6 +490,7 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if testChannel.Node1.testChannelPolicy != nil {
|
||||||
var msgFlags lnwire.ChanUpdateMsgFlags
|
var msgFlags lnwire.ChanUpdateMsgFlags
|
||||||
if testChannel.Node1.MaxHTLC != 0 {
|
if testChannel.Node1.MaxHTLC != 0 {
|
||||||
msgFlags = 1
|
msgFlags = 1
|
||||||
@ -509,12 +510,14 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
if err := graph.UpdateEdgePolicy(edgePolicy); err != nil {
|
if err := graph.UpdateEdgePolicy(edgePolicy); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
msgFlags = 0
|
if testChannel.Node2.testChannelPolicy != nil {
|
||||||
|
var msgFlags lnwire.ChanUpdateMsgFlags
|
||||||
if testChannel.Node2.MaxHTLC != 0 {
|
if testChannel.Node2.MaxHTLC != 0 {
|
||||||
msgFlags = 1
|
msgFlags = 1
|
||||||
}
|
}
|
||||||
edgePolicy = &channeldb.ChannelEdgePolicy{
|
edgePolicy := &channeldb.ChannelEdgePolicy{
|
||||||
SigBytes: testSig.Serialize(),
|
SigBytes: testSig.Serialize(),
|
||||||
MessageFlags: msgFlags,
|
MessageFlags: msgFlags,
|
||||||
ChannelFlags: lnwire.ChanUpdateDirection,
|
ChannelFlags: lnwire.ChanUpdateDirection,
|
||||||
@ -526,10 +529,10 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
FeeBaseMSat: testChannel.Node2.FeeBaseMsat,
|
FeeBaseMSat: testChannel.Node2.FeeBaseMsat,
|
||||||
FeeProportionalMillionths: testChannel.Node2.FeeRate,
|
FeeProportionalMillionths: testChannel.Node2.FeeRate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := graph.UpdateEdgePolicy(edgePolicy); err != nil {
|
if err := graph.UpdateEdgePolicy(edgePolicy); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
channelID++
|
channelID++
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user