swarm/network/simulation: fix New function for-loop scope (#18161)
This commit is contained in:
committed by
Anton Evangelatov
parent
f0515800e6
commit
93854bbad4
@@ -160,6 +160,41 @@ func TestAddNodeWithService(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddNodeMultipleServices(t *testing.T) {
|
||||
sim := New(map[string]ServiceFunc{
|
||||
"noop1": noopServiceFunc,
|
||||
"noop2": noopService2Func,
|
||||
})
|
||||
defer sim.Close()
|
||||
|
||||
id, err := sim.AddNode()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
n := sim.Net.GetNode(id).Node.(*adapters.SimNode)
|
||||
if n.Service("noop1") == nil {
|
||||
t.Error("service noop1 not found on node")
|
||||
}
|
||||
if n.Service("noop2") == nil {
|
||||
t.Error("service noop2 not found on node")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddNodeDuplicateServiceError(t *testing.T) {
|
||||
sim := New(map[string]ServiceFunc{
|
||||
"noop1": noopServiceFunc,
|
||||
"noop2": noopServiceFunc,
|
||||
})
|
||||
defer sim.Close()
|
||||
|
||||
wantErr := "duplicate service: *simulation.noopService"
|
||||
_, err := sim.AddNode()
|
||||
if err.Error() != wantErr {
|
||||
t.Errorf("got error %q, want %q", err, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddNodes(t *testing.T) {
|
||||
sim := New(noopServiceFuncMap)
|
||||
defer sim.Close()
|
||||
|
Reference in New Issue
Block a user