@@ -1838,8 +1838,8 @@ func (h *HarnessTest) AssertNotInGraph(hn *node.HarnessNode, chanID uint64) {
1838
1838
"found in graph" )
1839
1839
}
1840
1840
1841
- // AssertChannelInGraph asserts that a given channel is found in the graph.
1842
- func (h * HarnessTest ) AssertChannelInGraph (hn * node.HarnessNode ,
1841
+ // AssertChannelInGraphDB asserts that a given channel is found in the graph db .
1842
+ func (h * HarnessTest ) AssertChannelInGraphDB (hn * node.HarnessNode ,
1843
1843
chanPoint * lnrpc.ChannelPoint ) * lnrpc.ChannelEdge {
1844
1844
1845
1845
ctxt , cancel := context .WithCancel (h .runCtx )
@@ -1875,12 +1875,72 @@ func (h *HarnessTest) AssertChannelInGraph(hn *node.HarnessNode,
1875
1875
1876
1876
return nil
1877
1877
}, DefaultTimeout )
1878
+
1878
1879
require .NoError (h , err , "%s: timeout finding channel in graph" ,
1879
1880
hn .Name ())
1880
1881
1881
1882
return edge
1882
1883
}
1883
1884
1885
+ // AssertChannelInGraphCache asserts a given channel is found in the graph
1886
+ // cache.
1887
+ func (h * HarnessTest ) AssertChannelInGraphCache (hn * node.HarnessNode ,
1888
+ chanPoint * lnrpc.ChannelPoint ) * lnrpc.ChannelEdge {
1889
+
1890
+ var edge * lnrpc.ChannelEdge
1891
+
1892
+ req := & lnrpc.ChannelGraphRequest {IncludeUnannounced : true }
1893
+ cpStr := channelPointStr (chanPoint )
1894
+
1895
+ err := wait .NoError (func () error {
1896
+ chanGraph := hn .RPC .DescribeGraph (req )
1897
+
1898
+ // Iterate all the known edges, and make sure the edge policies
1899
+ // are populated when a matched edge is found.
1900
+ for _ , e := range chanGraph .Edges {
1901
+ if e .ChanPoint != cpStr {
1902
+ continue
1903
+ }
1904
+
1905
+ if e .Node1Policy == nil {
1906
+ return fmt .Errorf ("no policy for node1 %v" ,
1907
+ e .Node1Pub )
1908
+ }
1909
+
1910
+ if e .Node2Policy == nil {
1911
+ return fmt .Errorf ("no policy for node2 %v" ,
1912
+ e .Node1Pub )
1913
+ }
1914
+
1915
+ edge = e
1916
+
1917
+ return nil
1918
+ }
1919
+
1920
+ // If we've iterated over all the known edges and we weren't
1921
+ // able to find this specific one, then we'll fail.
1922
+ return fmt .Errorf ("no edge found for channel point: %s" , cpStr )
1923
+ }, DefaultTimeout )
1924
+
1925
+ require .NoError (h , err , "%s: timeout finding channel %v in graph cache" ,
1926
+ cpStr , hn .Name ())
1927
+
1928
+ return edge
1929
+ }
1930
+
1931
+ // AssertChannelInGraphDB asserts that a given channel is found both in the
1932
+ // graph db (GetChanInfo) and the graph cache (DescribeGraph).
1933
+ func (h * HarnessTest ) AssertChannelInGraph (hn * node.HarnessNode ,
1934
+ chanPoint * lnrpc.ChannelPoint ) * lnrpc.ChannelEdge {
1935
+
1936
+ // Make sure the channel is found in the db first.
1937
+ h .AssertChannelInGraphDB (hn , chanPoint )
1938
+
1939
+ // Assert the channel is also found in the graph cache, which refreshes
1940
+ // every `--caches.rpc-graph-cache-duration`.
1941
+ return h .AssertChannelInGraphCache (hn , chanPoint )
1942
+ }
1943
+
1884
1944
// AssertTxAtHeight gets all of the transactions that a node's wallet has a
1885
1945
// record of at the target height, and finds and returns the tx with the target
1886
1946
// txid, failing if it is not found.
0 commit comments