diff --git a/rendezvous/client_test.go b/rendezvous/client_test.go index 2c990f22..44dcb013 100644 --- a/rendezvous/client_test.go +++ b/rendezvous/client_test.go @@ -33,7 +33,7 @@ func TestBasicClient(t *testing.T) { gotAgents := ts.Agents() expectAgents := [][]string{ - []string{version.AgentString, version.AgentVersion}, + {version.AgentString, version.AgentVersion}, } if !reflect.DeepEqual(gotAgents, expectAgents) { @@ -131,7 +131,7 @@ func TestCustomUserAgent(t *testing.T) { gotAgents := ts.Agents() expectAgents := [][]string{ - []string{agentString, agentVersion}, + {agentString, agentVersion}, } if !reflect.DeepEqual(gotAgents, expectAgents) { diff --git a/rendezvous/rendezvousservertest/rendezvousservertest.go b/rendezvous/rendezvousservertest/rendezvousservertest.go index 1001464c..fe83a0eb 100644 --- a/rendezvous/rendezvousservertest/rendezvousservertest.go +++ b/rendezvous/rendezvousservertest/rendezvousservertest.go @@ -42,6 +42,8 @@ func NewServer() *TestServer { } func (ts *TestServer) Agents() [][]string { + ts.mu.Lock() + defer ts.mu.Unlock() return ts.agents } @@ -229,14 +231,14 @@ func (ts *TestServer) handleWS(w http.ResponseWriter, r *http.Request) { switch m := msg.(type) { case *msgs.Bind: - ackMsg(m.ID) - if sideID != "" { + ackMsg(m.ID) errMsg(m.ID, m, fmt.Errorf("already bound")) continue } if m.Side == "" { + ackMsg(m.ID) errMsg(m.ID, m, fmt.Errorf("bind requires 'side'")) continue } @@ -244,8 +246,9 @@ func (ts *TestServer) handleWS(w http.ResponseWriter, r *http.Request) { ts.mu.Lock() ts.agents = append(ts.agents, m.ClientVersion) ts.mu.Unlock() - sideID = m.Side + + ackMsg(m.ID) case *msgs.Allocate: ackMsg(m.ID)