routing: fix node ordering in test graph
There is the general assumption that channel edge policy nodes are ordered such that the node1 pubkey is smaller than the key of node 2. In the test graph, this assumption didn't hold. This commit fixes the test graph and also adds a check to prevent this from happening again.
This commit is contained in:
parent
349551373d
commit
42debc6c12
@ -7,6 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
@ -232,6 +233,13 @@ func parseTestGraph(path string) (*testGraphInstance, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bytes.Compare(node1Bytes, node2Bytes) == 1 {
|
||||
return nil, fmt.Errorf(
|
||||
"channel %v node order incorrect",
|
||||
edge.ChannelID,
|
||||
)
|
||||
}
|
||||
|
||||
fundingTXID := strings.Split(edge.ChannelPoint, ":")[0]
|
||||
txidBytes, err := chainhash.NewHashFromStr(fundingTXID)
|
||||
if err != nil {
|
||||
|
24
routing/testdata/basic_graph.json
vendored
24
routing/testdata/basic_graph.json
vendored
@ -142,11 +142,11 @@
|
||||
"capacity": 120000
|
||||
},
|
||||
{
|
||||
"node_1": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"node_2": "032b480de5d002f1a8fd1fe1bbf0a0f1b07760f65f052e66d56f15d71097c01add",
|
||||
"node_1": "032b480de5d002f1a8fd1fe1bbf0a0f1b07760f65f052e66d56f15d71097c01add",
|
||||
"node_2": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"channel_id": 12345,
|
||||
"channel_point": "89dc56859c6a082d15ba1a7f6cb6be3fea62e1746e2cb8497b1189155c21a233:0",
|
||||
"flags": 0,
|
||||
"flags": 1,
|
||||
"expiry": 1,
|
||||
"min_htlc": 1000,
|
||||
"fee_base_msat": 10,
|
||||
@ -154,11 +154,11 @@
|
||||
"capacity": 100000
|
||||
},
|
||||
{
|
||||
"node_1": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"node_2": "032b480de5d002f1a8fd1fe1bbf0a0f1b07760f65f052e66d56f15d71097c01add",
|
||||
"node_1": "032b480de5d002f1a8fd1fe1bbf0a0f1b07760f65f052e66d56f15d71097c01add",
|
||||
"node_2": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"channel_id": 12345,
|
||||
"channel_point": "89dc56859c6a082d15ba1a7f6cb6be3fea62e1746e2cb8497b1189155c21a233:0",
|
||||
"flags": 1,
|
||||
"flags": 0,
|
||||
"expiry": 1,
|
||||
"min_htlc": 1,
|
||||
"fee_base_msat": 10,
|
||||
@ -214,11 +214,11 @@
|
||||
"capacity": 10000
|
||||
},
|
||||
{
|
||||
"node_1": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"node_2": "02e7b1aaac10977c38e9c61c74dc66840de211bcec3021603e7977bc5e28edabfd",
|
||||
"node_1": "02e7b1aaac10977c38e9c61c74dc66840de211bcec3021603e7977bc5e28edabfd",
|
||||
"node_2": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"channel_id": 689530843,
|
||||
"channel_point": "25376aa6cb81913ad30416bd22d4083241bd6d68e811d0284d3c3a17795c458a:0",
|
||||
"flags": 0,
|
||||
"flags": 1,
|
||||
"expiry": 10,
|
||||
"min_htlc": 1,
|
||||
"fee_base_msat": 10,
|
||||
@ -226,11 +226,11 @@
|
||||
"capacity": 100000
|
||||
},
|
||||
{
|
||||
"node_1": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"node_2": "02e7b1aaac10977c38e9c61c74dc66840de211bcec3021603e7977bc5e28edabfd",
|
||||
"node_1": "02e7b1aaac10977c38e9c61c74dc66840de211bcec3021603e7977bc5e28edabfd",
|
||||
"node_2": "0367cec75158a4129177bfb8b269cb586efe93d751b43800d456485e81c2620ca6",
|
||||
"channel_id": 689530843,
|
||||
"channel_point": "25376aa6cb81913ad30416bd22d4083241bd6d68e811d0284d3c3a17795c458a:0",
|
||||
"flags": 1,
|
||||
"flags": 0,
|
||||
"expiry": 1,
|
||||
"min_htlc": 1,
|
||||
"fee_base_msat": 10,
|
||||
|
Loading…
Reference in New Issue
Block a user