routing: add private key map to test graph instance
This commit is contained in:
1 file changed
+13
-4
@@ -336,6 +336,10 @@ type testGraphInstance struct {
|
|||||||
// provided in order to allow easily look up from the human memorable alias
|
// provided in order to allow easily look up from the human memorable alias
|
||||||
// to an exact node's public key.
|
// to an exact node's public key.
|
||||||
aliasMap map[string]*btcec.PublicKey
|
aliasMap map[string]*btcec.PublicKey
|
||||||
|
|
||||||
|
// privKeyMap maps a node alias to its private key. This is used to be
|
||||||
|
// able to mock a remote node's signing behaviour.
|
||||||
|
privKeyMap map[string]*btcec.PrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// createTestGraphFromChannels returns a fully populated ChannelGraph based on a set of
|
// createTestGraphFromChannels returns a fully populated ChannelGraph based on a set of
|
||||||
@@ -361,6 +365,7 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
}
|
}
|
||||||
|
|
||||||
aliasMap := make(map[string]*btcec.PublicKey)
|
aliasMap := make(map[string]*btcec.PublicKey)
|
||||||
|
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||||
|
|
||||||
nodeIndex := byte(0)
|
nodeIndex := byte(0)
|
||||||
addNodeWithAlias := func(alias string) (*channeldb.LightningNode, error) {
|
addNodeWithAlias := func(alias string) (*channeldb.LightningNode, error) {
|
||||||
@@ -372,7 +377,7 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
0, 0, 0, 0, 0, 0, 0, nodeIndex + 1,
|
0, 0, 0, 0, 0, 0, 0, nodeIndex + 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, pubKey := btcec.PrivKeyFromBytes(btcec.S256(),
|
privKey, pubKey := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||||
keyBytes)
|
keyBytes)
|
||||||
|
|
||||||
dbNode := &channeldb.LightningNode{
|
dbNode := &channeldb.LightningNode{
|
||||||
@@ -386,6 +391,8 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
|
|
||||||
copy(dbNode.PubKeyBytes[:], pubKey.SerializeCompressed())
|
copy(dbNode.PubKeyBytes[:], pubKey.SerializeCompressed())
|
||||||
|
|
||||||
|
privKeyMap[alias] = privKey
|
||||||
|
|
||||||
// With the node fully parsed, add it as a vertex within the
|
// With the node fully parsed, add it as a vertex within the
|
||||||
// graph.
|
// graph.
|
||||||
if err := graph.AddLightningNode(dbNode); err != nil {
|
if err := graph.AddLightningNode(dbNode); err != nil {
|
||||||
@@ -482,9 +489,11 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &testGraphInstance{
|
return &testGraphInstance{
|
||||||
graph: graph,
|
graph: graph,
|
||||||
cleanUp: cleanUp,
|
cleanUp: cleanUp,
|
||||||
aliasMap: aliasMap}, nil
|
aliasMap: aliasMap,
|
||||||
|
privKeyMap: privKeyMap,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFindLowestFeePath tests that out of two routes with identical total
|
// TestFindLowestFeePath tests that out of two routes with identical total
|
||||||
|
|||||||
Reference in new issue
Block a user