routing: add option to specify explicit id for test channels
This commit is contained in:
parent
c5c580ab54
commit
47d2e1e024
@ -308,7 +308,15 @@ func defaultTestChannelEnd(alias string) *testChannelEnd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
||||||
policy *testChannelPolicy) *testChannel {
|
policy *testChannelPolicy, chanID ...uint64) *testChannel {
|
||||||
|
|
||||||
|
// Leaving id zero will result in auto-generation of a channel id during
|
||||||
|
// graph construction.
|
||||||
|
var id uint64
|
||||||
|
if len(chanID) > 0 {
|
||||||
|
id = chanID[0]
|
||||||
|
}
|
||||||
|
|
||||||
return &testChannel{
|
return &testChannel{
|
||||||
Capacity: capacity,
|
Capacity: capacity,
|
||||||
Node1: &testChannelEnd{
|
Node1: &testChannelEnd{
|
||||||
@ -319,13 +327,15 @@ func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
|||||||
Alias: alias2,
|
Alias: alias2,
|
||||||
testChannelPolicy: *policy,
|
testChannelPolicy: *policy,
|
||||||
},
|
},
|
||||||
|
ChannelID: id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type testChannel struct {
|
type testChannel struct {
|
||||||
Node1 *testChannelEnd
|
Node1 *testChannelEnd
|
||||||
Node2 *testChannelEnd
|
Node2 *testChannelEnd
|
||||||
Capacity btcutil.Amount
|
Capacity btcutil.Amount
|
||||||
|
ChannelID uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type testGraphInstance struct {
|
type testGraphInstance struct {
|
||||||
@ -415,7 +425,10 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
channelID := uint64(0)
|
// Initialize variable that keeps track of the next channel id to assign
|
||||||
|
// if none is specified.
|
||||||
|
nextUnassignedChannelID := uint64(100000)
|
||||||
|
|
||||||
for _, testChannel := range testChannels {
|
for _, testChannel := range testChannels {
|
||||||
for _, alias := range []string{
|
for _, alias := range []string{
|
||||||
testChannel.Node1.Alias, testChannel.Node2.Alias} {
|
testChannel.Node1.Alias, testChannel.Node2.Alias} {
|
||||||
@ -426,6 +439,14 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channelID := testChannel.ChannelID
|
||||||
|
|
||||||
|
// If no channel id is specified, generate an id.
|
||||||
|
if channelID == 0 {
|
||||||
|
channelID = nextUnassignedChannelID
|
||||||
|
nextUnassignedChannelID++
|
||||||
|
}
|
||||||
|
|
||||||
var hash [sha256.Size]byte
|
var hash [sha256.Size]byte
|
||||||
hash[len(hash)-1] = byte(channelID)
|
hash[len(hash)-1] = byte(channelID)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user