@@ -765,7 +765,6 @@ mod tests {
765
765
use secp256k1:: Secp256k1 ;
766
766
767
767
use std:: sync:: Arc ;
768
- use std:: collections:: btree_map:: Entry as BtreeEntry ;
769
768
770
769
fn create_net_graph_msg_handler ( ) -> ( Secp256k1 < All > , PublicKey , NetGraphMsgHandler ) {
771
770
let secp_ctx = Secp256k1 :: new ( ) ;
@@ -944,14 +943,16 @@ mod tests {
944
943
Ok ( res) => assert ! ( res) ,
945
944
_ => panic ! ( )
946
945
} ;
946
+
947
947
{
948
- let network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
949
- match network. channels . get ( & unsigned_announcement. short_channel_id ) {
948
+ let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
949
+ match network. get_channels ( ) . get ( & unsigned_announcement. short_channel_id ) {
950
950
None => panic ! ( ) ,
951
951
Some ( _) => ( )
952
952
}
953
953
}
954
954
955
+
955
956
// If we receive announcement for the same channel (with UTXO lookups disabled),
956
957
// drop new one on the floor, since we can't see any changes.
957
958
match net_graph_msg_handler. handle_channel_announcement ( & valid_announcement) {
@@ -995,9 +996,10 @@ mod tests {
995
996
Ok ( res) => assert ! ( res) ,
996
997
_ => panic ! ( )
997
998
} ;
999
+
998
1000
{
999
- let network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
1000
- match network. channels . get ( & unsigned_announcement. short_channel_id ) {
1001
+ let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1002
+ match network. get_channels ( ) . get ( & unsigned_announcement. short_channel_id ) {
1001
1003
None => panic ! ( ) ,
1002
1004
Some ( _) => ( )
1003
1005
}
@@ -1027,10 +1029,10 @@ mod tests {
1027
1029
_ => panic ! ( )
1028
1030
} ;
1029
1031
{
1030
- let mut network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
1031
- match network. channels . entry ( unsigned_announcement. short_channel_id ) {
1032
- BtreeEntry :: Occupied ( channel_entry) => {
1033
- assert_eq ! ( channel_entry. get ( ) . features, ChannelFeatures :: empty( ) ) ;
1032
+ let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1033
+ match network. get_channels ( ) . get ( & unsigned_announcement. short_channel_id ) {
1034
+ Some ( channel_entry) => {
1035
+ assert_eq ! ( channel_entry. features, ChannelFeatures :: empty( ) ) ;
1034
1036
} ,
1035
1037
_ => panic ! ( )
1036
1038
}
@@ -1144,8 +1146,8 @@ mod tests {
1144
1146
} ;
1145
1147
1146
1148
{
1147
- let network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
1148
- match network. channels . get ( & short_channel_id) {
1149
+ let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1150
+ match network. get_channels ( ) . get ( & short_channel_id) {
1149
1151
None => panic ! ( ) ,
1150
1152
Some ( channel_info) => {
1151
1153
assert_eq ! ( channel_info. one_to_two. cltv_expiry_delta, 144 ) ;
@@ -1225,8 +1227,8 @@ mod tests {
1225
1227
{
1226
1228
// There is only local node in the table at the beginning.
1227
1229
let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1228
- assert_eq ! ( network. nodes . len( ) , 1 ) ;
1229
- assert_eq ! ( network. nodes . contains_key( & our_id) , true ) ;
1230
+ assert_eq ! ( network. get_nodes ( ) . len( ) , 1 ) ;
1231
+ assert_eq ! ( network. get_nodes ( ) . contains_key( & our_id) , true ) ;
1230
1232
}
1231
1233
1232
1234
{
@@ -1264,10 +1266,10 @@ mod tests {
1264
1266
1265
1267
net_graph_msg_handler. handle_htlc_fail_channel_update ( & channel_close_msg) ;
1266
1268
1269
+ // Non-permanent closing just disables a channel
1267
1270
{
1268
- // Non-permanent closing just disables a channel
1269
- let network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
1270
- match network. channels . get ( & short_channel_id) {
1271
+ let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1272
+ match network. get_channels ( ) . get ( & short_channel_id) {
1271
1273
None => panic ! ( ) ,
1272
1274
Some ( channel_info) => {
1273
1275
assert ! ( !channel_info. one_to_two. enabled) ;
@@ -1283,16 +1285,15 @@ mod tests {
1283
1285
1284
1286
net_graph_msg_handler. handle_htlc_fail_channel_update ( & channel_close_msg) ;
1285
1287
1288
+ // Permanent closing deletes a channel
1286
1289
{
1287
- // Permanent closing deletes a channel
1288
1290
let network = net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) ;
1289
- assert_eq ! ( network. channels . len( ) , 0 ) ;
1291
+ assert_eq ! ( network. get_channels ( ) . len( ) , 0 ) ;
1290
1292
// Nodes are also deleted because there are no associated channels anymore
1291
1293
// Only the local node remains in the table.
1292
- assert_eq ! ( network. nodes . len( ) , 1 ) ;
1293
- assert_eq ! ( network. nodes . contains_key( & our_id) , true ) ;
1294
+ assert_eq ! ( network. get_nodes ( ) . len( ) , 1 ) ;
1295
+ assert_eq ! ( network. get_nodes ( ) . contains_key( & our_id) , true ) ;
1294
1296
}
1295
-
1296
1297
// TODO: Test HTLCFailChannelUpdate::NodeFailure, which is not implemented yet.
1297
1298
}
1298
1299
@@ -1606,8 +1607,8 @@ mod tests {
1606
1607
1607
1608
let network = net_graph_msg_handler. network_graph . write ( ) . unwrap ( ) ;
1608
1609
let mut w = test_utils:: TestVecWriter ( Vec :: new ( ) ) ;
1609
- assert ! ( !network. channels . is_empty( ) ) ;
1610
- assert ! ( !network. nodes . is_empty( ) ) ;
1610
+ assert ! ( !network. get_nodes ( ) . is_empty( ) ) ;
1611
+ assert ! ( !network. get_channels ( ) . is_empty( ) ) ;
1611
1612
network. write ( & mut w) . unwrap ( ) ;
1612
1613
assert ! ( <NetworkGraph >:: read( & mut :: std:: io:: Cursor :: new( & w. 0 ) ) . unwrap( ) == * network) ;
1613
1614
}
0 commit comments