diff options
author | Viktor TrĂ³n <viktor.tron@gmail.com> | 2019-01-17 14:29:34 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-19 19:55:07 +0800 |
commit | 1f1c751b6e4388f4534f294cd13250f1eb871de5 (patch) | |
tree | f0108a306777fd24c1d2ab9c14746934d48a870b /swarm/network/simulations | |
parent | a3f31f51f38040e0aef76f4da95ae462fb649f81 (diff) | |
download | dexon-1f1c751b6e4388f4534f294cd13250f1eb871de5.tar.gz dexon-1f1c751b6e4388f4534f294cd13250f1eb871de5.tar.zst dexon-1f1c751b6e4388f4534f294cd13250f1eb871de5.zip |
swarm/network: rewrite of peer suggestion engine, fix skipped tests (#18404)
* swarm/network: fix skipped tests related to suggestPeer
* swarm/network: rename depth to radius
* swarm/network: uncomment assertHealth and improve comments
* swarm/network: remove commented code
* swarm/network: kademlia suggestPeer algo correction
* swarm/network: kademlia suggest peer
* simplify suggest Peer code
* improve peer suggestion algo
* add comments
* kademlia testing improvements
* assertHealth -> checkHealth (test helper)
* testSuggestPeer -> checkSuggestPeer (test helper)
* remove testSuggestPeerBug and TestKademliaCase
* swarm/network: kademlia suggestPeer cleanup, improved comments
* swarm/network: minor comment, discovery test default arg
(cherry picked from commit bcb2594151c849d65108dd94e54b69067d117d7d)
Diffstat (limited to 'swarm/network/simulations')
-rw-r--r-- | swarm/network/simulations/discovery/discovery_test.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/swarm/network/simulations/discovery/discovery_test.go b/swarm/network/simulations/discovery/discovery_test.go index 7d0378987..e695bc4ac 100644 --- a/swarm/network/simulations/discovery/discovery_test.go +++ b/swarm/network/simulations/discovery/discovery_test.go @@ -82,7 +82,7 @@ func getDbStore(nodeID string) (*state.DBStore, error) { } var ( - nodeCount = flag.Int("nodes", 10, "number of nodes to create (default 10)") + nodeCount = flag.Int("nodes", 32, "number of nodes to create (default 32)") initCount = flag.Int("conns", 1, "number of originally connected peers (default 1)") loglevel = flag.Int("loglevel", 3, "verbosity of logs") rawlog = flag.Bool("rawlog", false, "remove terminal formatting from logs") @@ -151,7 +151,6 @@ func testDiscoverySimulationSimAdapter(t *testing.T, nodes, conns int) { } func testDiscoverySimulation(t *testing.T, nodes, conns int, adapter adapters.NodeAdapter) { - t.Skip("discovery tests depend on suggestpeer, which is unreliable after kademlia depth change.") startedAt := time.Now() result, err := discoverySimulation(nodes, conns, adapter) if err != nil { @@ -179,7 +178,6 @@ func testDiscoverySimulation(t *testing.T, nodes, conns int, adapter adapters.No } func testDiscoveryPersistenceSimulation(t *testing.T, nodes, conns int, adapter adapters.NodeAdapter) map[int][]byte { - t.Skip("discovery tests depend on suggestpeer, which is unreliable after kademlia depth change.") persistenceEnabled = true discoveryEnabled = true @@ -269,10 +267,10 @@ func discoverySimulation(nodes, conns int, adapter adapters.NodeAdapter) (*simul } healthy := &network.Health{} - if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil { + if err := client.Call(&healthy, "hive_healthy", ppmap[common.Bytes2Hex(id.Bytes())]); err != nil { return false, fmt.Errorf("error getting node health: %s", err) } - log.Info(fmt.Sprintf("node %4s healthy: connected nearest neighbours: %v, know nearest neighbours: %v,\n\n%v", id, healthy.ConnectNN, healthy.KnowNN, healthy.Hive)) + log.Debug(fmt.Sprintf("node %4s healthy: connected nearest neighbours: %v, know nearest neighbours: %v,\n\n%v", id, healthy.ConnectNN, healthy.KnowNN, healthy.Hive)) return healthy.KnowNN && healthy.ConnectNN, nil } @@ -354,7 +352,7 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt healthy := &network.Health{} addr := id.String() ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, addrs) - if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil { + if err := client.Call(&healthy, "hive_healthy", ppmap[common.Bytes2Hex(id.Bytes())]); err != nil { return fmt.Errorf("error getting node health: %s", err) } @@ -427,7 +425,7 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt healthy := &network.Health{} ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, addrs) - if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil { + if err := client.Call(&healthy, "hive_healthy", ppmap[common.Bytes2Hex(id.Bytes())]); err != nil { return false, fmt.Errorf("error getting node health: %s", err) } log.Info(fmt.Sprintf("node %4s healthy: got nearest neighbours: %v, know nearest neighbours: %v", id, healthy.ConnectNN, healthy.KnowNN)) |