diff options
author | Ferenc Szabo <frncmx@gmail.com> | 2019-01-11 17:23:45 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2019-01-11 17:23:45 +0800 |
commit | 2eb838ed9776c9c3ec922e1116a5d50babda31c5 (patch) | |
tree | 1ad75862e2c0e7bcff2ec898c1f757c58eaaa650 /swarm/network | |
parent | 38cce9ac333d674616047be14c270d7cfbd43641 (diff) | |
download | dexon-2eb838ed9776c9c3ec922e1116a5d50babda31c5.tar.gz dexon-2eb838ed9776c9c3ec922e1116a5d50babda31c5.tar.zst dexon-2eb838ed9776c9c3ec922e1116a5d50babda31c5.zip |
p2p/simulations: eliminate concept of pivot (#18426)
Diffstat (limited to 'swarm/network')
-rw-r--r-- | swarm/network/simulation/node.go | 21 | ||||
-rw-r--r-- | swarm/network/simulation/node_test.go | 39 | ||||
-rw-r--r-- | swarm/network/simulation/simulation.go | 1 |
3 files changed, 1 insertions, 60 deletions
diff --git a/swarm/network/simulation/node.go b/swarm/network/simulation/node.go index e8d4d6d94..08eb83524 100644 --- a/swarm/network/simulation/node.go +++ b/swarm/network/simulation/node.go @@ -188,7 +188,7 @@ func (s *Simulation) AddNodesAndConnectStar(count int, opts ...AddNodeOption) (i if err != nil { return nil, err } - err = s.Net.ConnectNodesStar(ids[0], ids[1:]) + err = s.Net.ConnectNodesStar(ids[1:], ids[0]) if err != nil { return nil, err } @@ -241,25 +241,6 @@ func (s *Simulation) UploadSnapshot(snapshotFile string, opts ...AddNodeOption) return nil } -// SetPivotNode sets the NodeID of the network's pivot node. -// Pivot node is just a specific node that should be treated -// differently then other nodes in test. SetPivotNode and -// PivotNodeID are just a convenient functions to set and -// retrieve it. -func (s *Simulation) SetPivotNode(id enode.ID) { - s.mu.Lock() - defer s.mu.Unlock() - s.pivotNodeID = &id -} - -// PivotNodeID returns NodeID of the pivot node set by -// Simulation.SetPivotNode method. -func (s *Simulation) PivotNodeID() (id *enode.ID) { - s.mu.Lock() - defer s.mu.Unlock() - return s.pivotNodeID -} - // StartNode starts a node by NodeID. func (s *Simulation) StartNode(id enode.ID) (err error) { return s.Net.Start(id) diff --git a/swarm/network/simulation/node_test.go b/swarm/network/simulation/node_test.go index 8da32cf37..dc9189c91 100644 --- a/swarm/network/simulation/node_test.go +++ b/swarm/network/simulation/node_test.go @@ -314,45 +314,6 @@ func TestUploadSnapshot(t *testing.T) { log.Debug("Done.") } -func TestPivotNode(t *testing.T) { - sim := New(noopServiceFuncMap) - defer sim.Close() - - id, err := sim.AddNode() - if err != nil { - t.Fatal(err) - } - - id2, err := sim.AddNode() - if err != nil { - t.Fatal(err) - } - - if sim.PivotNodeID() != nil { - t.Error("expected no pivot node") - } - - sim.SetPivotNode(id) - - pid := sim.PivotNodeID() - - if pid == nil { - t.Error("pivot node not set") - } else if *pid != id { - t.Errorf("expected pivot node %s, got %s", id, *pid) - } - - sim.SetPivotNode(id2) - - pid = sim.PivotNodeID() - - if pid == nil { - t.Error("pivot node not set") - } else if *pid != id2 { - t.Errorf("expected pivot node %s, got %s", id2, *pid) - } -} - func TestStartStopNode(t *testing.T) { sim := New(noopServiceFuncMap) defer sim.Close() diff --git a/swarm/network/simulation/simulation.go b/swarm/network/simulation/simulation.go index 13c5b1c57..e18d19a67 100644 --- a/swarm/network/simulation/simulation.go +++ b/swarm/network/simulation/simulation.go @@ -46,7 +46,6 @@ type Simulation struct { serviceNames []string cleanupFuncs []func() buckets map[enode.ID]*sync.Map - pivotNodeID *enode.ID shutdownWG sync.WaitGroup done chan struct{} mu sync.RWMutex |