mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: fixed data race in tests
Due to the reuse of error channels throughout the tests, the golang race tester complains to test use `go test -count=1 -run=TestForkIDSplit ./... -race`
This commit is contained in:
parent
eb2fd823b2
commit
ddc173f801
1 changed files with 8 additions and 8 deletions
|
|
@ -211,12 +211,12 @@ func TestForkIDSplit(t *testing.T) {
|
|||
peerNoFork = newPeer(64, p2p.NewPeer(enode.ID{1}, "", nil), p2pNoFork, nil)
|
||||
peerProFork = newPeer(64, p2p.NewPeer(enode.ID{2}, "", nil), p2pProFork, nil)
|
||||
|
||||
errc = make(chan error, 2)
|
||||
go func() { errc <- ethNoFork.handle(peerProFork) }()
|
||||
go func() { errc <- ethProFork.handle(peerNoFork) }()
|
||||
errc2 := make(chan error, 2)
|
||||
go func() { errc2 <- ethNoFork.handle(peerProFork) }()
|
||||
go func() { errc2 <- ethProFork.handle(peerNoFork) }()
|
||||
|
||||
select {
|
||||
case err := <-errc:
|
||||
case err := <-errc2:
|
||||
t.Fatalf("homestead nofork <-> profork failed: %v", err)
|
||||
case <-time.After(250 * time.Millisecond):
|
||||
p2pNoFork.Close()
|
||||
|
|
@ -230,12 +230,12 @@ func TestForkIDSplit(t *testing.T) {
|
|||
peerNoFork = newPeer(64, p2p.NewPeer(enode.ID{1}, "", nil), p2pNoFork, nil)
|
||||
peerProFork = newPeer(64, p2p.NewPeer(enode.ID{2}, "", nil), p2pProFork, nil)
|
||||
|
||||
errc = make(chan error, 2)
|
||||
go func() { errc <- ethNoFork.handle(peerProFork) }()
|
||||
go func() { errc <- ethProFork.handle(peerNoFork) }()
|
||||
errc3 := make(chan error, 2)
|
||||
go func() { errc3 <- ethNoFork.handle(peerProFork) }()
|
||||
go func() { errc3 <- ethProFork.handle(peerNoFork) }()
|
||||
|
||||
select {
|
||||
case err := <-errc:
|
||||
case err := <-errc3:
|
||||
if want := errResp(ErrForkIDRejected, forkid.ErrLocalIncompatibleOrStale.Error()); err.Error() != want.Error() {
|
||||
t.Fatalf("fork ID rejection error mismatch: have %v, want %v", err, want)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue