From 083b574fd800bc218477f29b9b7a3f8554347034 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 1 Nov 2019 19:30:21 -0700 Subject: [PATCH] autopilot: fix race condition in new test --- autopilot/agent_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/autopilot/agent_test.go b/autopilot/agent_test.go index 26e63bf38..9cc9366e6 100644 --- a/autopilot/agent_test.go +++ b/autopilot/agent_test.go @@ -338,6 +338,11 @@ func TestAgentHeuristicUpdateSignal(t *testing.T) { testCtx, cleanup := setup(t, nil) defer cleanup() + pub, err := testCtx.graph.addRandNode() + if err != nil { + t.Fatalf("unable to generate key: %v", err) + } + // We'll send an initial "no" response to advance the agent past its // initial check. respondMoreChans(t, testCtx, moreChansResp{0, 0}) @@ -356,10 +361,6 @@ func TestAgentHeuristicUpdateSignal(t *testing.T) { // At this point, the agent should now be querying the heuristic for // scores. We'll respond. - pub, err := testCtx.graph.addRandNode() - if err != nil { - t.Fatalf("unable to generate key: %v", err) - } nodeID := NewNodeID(pub) scores := map[NodeID]*NodeScore{ nodeID: {