@@ -797,8 +797,9 @@ impl<T: SimNetwork, C: Clock> LightningNode for SimNode<T, C> {
797797 Ok ( self . network . lock ( ) . await . lookup_node ( node_id) ?. 0 )
798798 }
799799
800- async fn list_channels ( & self ) -> Result < Vec < u64 > , LightningError > {
801- Ok ( self . network . lock ( ) . await . lookup_node ( & self . info . pubkey ) ?. 1 )
800+ async fn channel_capacities ( & self ) -> Result < u64 , LightningError > {
801+ let channels = self . network . lock ( ) . await . lookup_node ( & self . info . pubkey ) ?;
802+ Ok ( channels. 1 . iter ( ) . sum ( ) )
802803 }
803804
804805 async fn get_graph ( & self ) -> Result < Graph , LightningError > {
@@ -1965,31 +1966,16 @@ mod tests {
19651966 . await
19661967 . unwrap ( ) ;
19671968
1968- let node_1_channels = nodes
1969- . get ( & pk1)
1970- . unwrap ( )
1971- . lock ( )
1972- . await
1973- . list_channels ( )
1974- . await
1975- . unwrap ( ) ;
1969+ let node_1 = nodes. get ( & pk1) . unwrap ( ) . lock ( ) . await ;
1970+ let node_1_capacity = node_1. channel_capacities ( ) . await . unwrap ( ) ;
19761971
19771972 // Node 1 has 2 channels but one was excluded so here we should only have the one that was
19781973 // not excluded.
1979- assert ! ( node_1_channels. len( ) == 1 ) ;
1980- assert ! ( node_1_channels[ 0 ] == capacity_1) ;
1981-
1982- let node_2_channels = nodes
1983- . get ( & pk2)
1984- . unwrap ( )
1985- . lock ( )
1986- . await
1987- . list_channels ( )
1988- . await
1989- . unwrap ( ) ;
1974+ assert ! ( node_1_capacity == capacity_1) ;
19901975
1991- assert ! ( node_2_channels. len( ) == 1 ) ;
1992- assert ! ( node_2_channels[ 0 ] == capacity_1) ;
1976+ let node_2 = nodes. get ( & pk2) . unwrap ( ) . lock ( ) . await ;
1977+ let node_2_capacity = node_2. channel_capacities ( ) . await . unwrap ( ) ;
1978+ assert ! ( node_2_capacity == capacity_1) ;
19931979
19941980 // Node 3's only channel was excluded so it won't be present here.
19951981 assert ! ( !nodes. contains_key( & pk3) ) ;
@@ -2103,12 +2089,17 @@ mod tests {
21032089 . lock ( )
21042090 . await
21052091 . expect_lookup_node ( )
2106- . returning ( move |_| Ok ( ( node_info ( lookup_pk, String :: default ( ) ) , vec ! [ 1 , 2 , 3 ] ) ) ) ;
2092+ . returning ( move |_| {
2093+ Ok ( (
2094+ node_info ( lookup_pk, String :: default ( ) ) ,
2095+ vec ! [ 10_000 , 20_000 , 10_000 ] ,
2096+ ) )
2097+ } ) ;
21072098
21082099 // Assert that we get three channels from the mock.
21092100 let node_info = node. get_node_info ( & lookup_pk) . await . unwrap ( ) ;
21102101 assert_eq ! ( lookup_pk, node_info. pubkey) ;
2111- assert_eq ! ( node. list_channels ( ) . await . unwrap( ) . len ( ) , 3 ) ;
2102+ assert_eq ! ( node. channel_capacities ( ) . await . unwrap( ) , 40_000 ) ;
21122103
21132104 // Next, we're going to test handling of in-flight payments. To do this, we'll mock out calls to our dispatch
21142105 // function to send different results depending on the destination.
0 commit comments