diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index e1888ca85c..d2200a6d42 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -17,7 +17,6 @@ package network import ( - "bytes" "fmt" "math/rand" "strings" @@ -183,9 +182,9 @@ func (k *Kademlia) Register(peers []OverlayAddr) error { for _, p := range peers { // error if self received, peer should know better // and should be punished for this - if bytes.Equal(p.Address(), k.base) { - return fmt.Errorf("add peers: %x is self", k.base) - } + //if bytes.Equal(p.Address(), k.base) { + //return fmt.Errorf("add peers: %x is self", k.base) + //} var found bool k.addrs, _, found, _ = pot.Swap(k.addrs, p, pof, func(v pot.Val) pot.Val { // if not found diff --git a/swarm/pss/pss_test.go b/swarm/pss/pss_test.go index e26a7e600a..f689b683e5 100644 --- a/swarm/pss/pss_test.go +++ b/swarm/pss/pss_test.go @@ -635,7 +635,7 @@ func worker(id int, jobs <-chan Job, rpcs map[discover.NodeID]*rpc.Client, pubke // params in run name: // nodes/msgs/addrbytes/adaptertype // if adaptertype is exec uses execadapter, simadapter otherwise -func XTestNetwork(t *testing.T) { +func TestNetwork(t *testing.T) { t.Run("3/2000/4/sock", testNetwork) t.Run("4/2000/4/sock", testNetwork) t.Run("8/2000/4/sock", testNetwork) @@ -706,6 +706,8 @@ func testNetwork(t *testing.T) { t.Fatal(err) } + time.Sleep(1 * time.Second) + triggerChecks := func(trigger chan discover.NodeID, id discover.NodeID, rpcclient *rpc.Client, topic string) error { msgC := make(chan APIMsg) ctx, cancel := context.WithTimeout(context.Background(), time.Second) @@ -764,12 +766,16 @@ func testNetwork(t *testing.T) { } } + time.Sleep(1 * time.Second) + // setup workers jobs := make(chan Job, 10) for w := 1; w <= 10; w++ { go worker(w, jobs, rpcs, pubkeys, topic) } + time.Sleep(1 * time.Second) + for i := 0; i < int(msgcount); i++ { sendnodeidx := rand.Intn(int(nodecount)) recvnodeidx := rand.Intn(int(nodecount - 1))