@@ -25,12 +25,15 @@ use crate::gossipsub::subscription_filter::WhitelistSubscriptionFilter;
2525use crate :: gossipsub:: transform:: { DataTransform , IdentityTransform } ;
2626use crate :: gossipsub:: types:: { RpcOut , RpcReceiver } ;
2727use crate :: gossipsub:: ValidationError ;
28- use crate :: gossipsub:: { config:: ConfigBuilder , types:: Rpc , IdentTopic as Topic , TopicScoreParams } ;
28+ use crate :: gossipsub:: {
29+ config:: Config , config:: ConfigBuilder , types:: Rpc , IdentTopic as Topic , TopicScoreParams ,
30+ } ;
2931use async_std:: net:: Ipv4Addr ;
3032use byteorder:: { BigEndian , ByteOrder } ;
31- use libp2p:: core:: ConnectedPoint ;
33+ use libp2p:: core:: { ConnectedPoint , Endpoint } ;
3234use rand:: Rng ;
3335use std:: thread:: sleep;
36+ use std:: time:: Duration ;
3437
3538#[ derive( Default , Debug ) ]
3639struct InjectNodes < D , F >
@@ -424,7 +427,7 @@ fn test_subscribe() {
424427 . create_network ( ) ;
425428
426429 assert ! (
427- gs. mesh. contains_key ( & topic_hashes[ 0 ] ) ,
430+ gs. mesh. get ( & topic_hashes[ 0 ] ) . is_some ( ) ,
428431 "Subscribe should add a new entry to the mesh[topic] hashmap"
429432 ) ;
430433
@@ -474,7 +477,7 @@ fn test_unsubscribe() {
474477 "Topic_peers contain a topic entry"
475478 ) ;
476479 assert ! (
477- gs. mesh. contains_key ( topic_hash) ,
480+ gs. mesh. get ( topic_hash) . is_some ( ) ,
478481 "mesh should contain a topic entry"
479482 ) ;
480483 }
@@ -508,7 +511,7 @@ fn test_unsubscribe() {
508511 // check we clean up internal structures
509512 for topic_hash in & topic_hashes {
510513 assert ! (
511- ! gs. mesh. contains_key ( topic_hash) ,
514+ gs. mesh. get ( topic_hash) . is_none ( ) ,
512515 "All topics should have been removed from the mesh"
513516 ) ;
514517 }
@@ -691,7 +694,7 @@ fn test_publish_without_flood_publishing() {
691694 . create_network ( ) ;
692695
693696 assert ! (
694- gs. mesh. contains_key ( & topic_hashes[ 0 ] ) ,
697+ gs. mesh. get ( & topic_hashes[ 0 ] ) . is_some ( ) ,
695698 "Subscribe should add a new entry to the mesh[topic] hashmap"
696699 ) ;
697700
@@ -771,7 +774,7 @@ fn test_fanout() {
771774 . create_network ( ) ;
772775
773776 assert ! (
774- gs. mesh. contains_key ( & topic_hashes[ 0 ] ) ,
777+ gs. mesh. get ( & topic_hashes[ 0 ] ) . is_some ( ) ,
775778 "Subscribe should add a new entry to the mesh[topic] hashmap"
776779 ) ;
777780 // Unsubscribe from topic
@@ -943,7 +946,7 @@ fn test_handle_received_subscriptions() {
943946 ) ;
944947
945948 assert ! (
946- ! gs. connected_peers. contains_key ( & unknown_peer) ,
949+ gs. connected_peers. get ( & unknown_peer) . is_none ( ) ,
947950 "Unknown peer should not have been added"
948951 ) ;
949952
@@ -1344,7 +1347,7 @@ fn test_handle_graft_multiple_topics() {
13441347 }
13451348
13461349 assert ! (
1347- ! gs. mesh. contains_key ( & topic_hashes[ 2 ] ) ,
1350+ gs. mesh. get ( & topic_hashes[ 2 ] ) . is_none ( ) ,
13481351 "Expected the second topic to not be in the mesh"
13491352 ) ;
13501353}
@@ -5225,7 +5228,7 @@ fn test_graft_without_subscribe() {
52255228 . create_network ( ) ;
52265229
52275230 assert ! (
5228- gs. mesh. contains_key ( & topic_hashes[ 0 ] ) ,
5231+ gs. mesh. get ( & topic_hashes[ 0 ] ) . is_some ( ) ,
52295232 "Subscribe should add a new entry to the mesh[topic] hashmap"
52305233 ) ;
52315234
0 commit comments