Skip to content

Commit cc5559d

Browse files
committed
address review comments
1 parent 69b7fed commit cc5559d

7 files changed

+48
-38
lines changed

client/proposer/BUILD.bazel

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ go_test(
4141
# by default gazelle tries to add all the test files to the first
4242
# go_test; we need to exclude the tests that we want to configure
4343
# in a particular way
44-
# gazelle:exclude racy_test.go
44+
# gazelle:exclude service_norace_test.go
4545

4646
go_test(
47-
name = "go_racy_test",
48-
srcs = ["racy_test.go"],
47+
name = "go_norace_test",
48+
srcs = ["service_norace_test.go"],
4949
embed = [":go_default_library"],
5050
race = "off", # TODO(#377): fix issues with race detection testing.
5151
deps = [
File renamed without changes.

client/syncer/BUILD.bazel

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ go_test(
5252
# by default gazelle tries to add all the test files to the first
5353
# go_test; we need to exclude the tests that we want to configure
5454
# in a particular way
55-
# gazelle:exclude racy_test.go
55+
# gazelle:exclude service_norace_test.go
5656

5757
go_test(
58-
name = "go_racy_test",
59-
srcs = ["racy_test.go"],
58+
name = "go_norace_test",
59+
srcs = ["service_norace_test.go"],
6060
embed = [":go_default_library"],
6161
race = "off", # TODO(#377): fix issues with race detection testing.
6262
deps = [
File renamed without changes.

shared/p2p/BUILD.bazel

+7-3
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ go_test(
5555
# by default gazelle tries to add all the test files to the first
5656
# go_test; we need to exclude the tests that we want to configure
5757
# in a particular way
58-
# gazelle:exclude racy_test.go
58+
# gazelle:exclude discovery_norace_test.go
59+
# gazelle:exclude service_norace_test.go
5960

6061
go_test(
61-
name = "go_racy_test",
62-
srcs = ["racy_test.go"],
62+
name = "go_norace_test",
63+
srcs = [
64+
"discovery_norace_test.go",
65+
"service_norace_test.go",
66+
],
6367
embed = [":go_default_library"],
6468
race = "off", # TODO(#377): fix issues with race detection testing.
6569
deps = [

shared/p2p/racy_test.go shared/p2p/discovery_norace_test.go

-29
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
1111
mdns "github.com/libp2p/go-libp2p/p2p/discovery"
1212
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
13-
logTest "github.com/sirupsen/logrus/hooks/test"
1413
)
1514

1615
var _ = mdns.Notifee(&discovery{})
@@ -63,31 +62,3 @@ func TestStartDiscovery_HandlePeerFound(t *testing.T) {
6362
expectPeers(t, a, 2)
6463
expectPeers(t, b, 2)
6564
}
66-
67-
func TestLifecycle(t *testing.T) {
68-
hook := logTest.NewGlobal()
69-
70-
s, err := NewServer()
71-
if err != nil {
72-
t.Fatalf("Could not start a new server: %v", err)
73-
}
74-
75-
s.Start()
76-
msg := hook.Entries[0].Message
77-
want := "Starting service"
78-
if msg != want {
79-
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
80-
}
81-
82-
s.Stop()
83-
msg = hook.LastEntry().Message
84-
want = "Stopping service"
85-
if msg != want {
86-
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
87-
}
88-
89-
// The context should have been cancelled.
90-
if s.ctx.Err() == nil {
91-
t.Error("Context was not cancelled")
92-
}
93-
}

shared/p2p/service_norace_test.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p2p
2+
3+
import (
4+
"testing"
5+
6+
logTest "github.com/sirupsen/logrus/hooks/test"
7+
)
8+
9+
func TestLifecycle(t *testing.T) {
10+
hook := logTest.NewGlobal()
11+
12+
s, err := NewServer()
13+
if err != nil {
14+
t.Fatalf("Could not start a new server: %v", err)
15+
}
16+
17+
s.Start()
18+
msg := hook.Entries[0].Message
19+
want := "Starting service"
20+
if msg != want {
21+
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
22+
}
23+
24+
s.Stop()
25+
msg = hook.LastEntry().Message
26+
want = "Stopping service"
27+
if msg != want {
28+
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
29+
}
30+
31+
// The context should have been cancelled.
32+
if s.ctx.Err() == nil {
33+
t.Error("Context was not cancelled")
34+
}
35+
}

0 commit comments

Comments
 (0)