Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
cf52d5c9
Unverified
Commit
cf52d5c9
authored
Feb 28, 2018
by
b00ris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: fixed datarace
parent
b574b577
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
peer_test.go
whisper/whisperv6/peer_test.go
+11
-7
No files found.
whisper/whisperv6/peer_test.go
View file @
cf52d5c9
...
...
@@ -23,6 +23,7 @@ import (
mrand
"math/rand"
"net"
"sync"
"sync/atomic"
"testing"
"time"
...
...
@@ -71,7 +72,7 @@ var keys = []string{
}
type
TestData
struct
{
started
int
started
int
64
counter
[
NumNodes
]
int
mutex
sync
.
RWMutex
}
...
...
@@ -240,9 +241,7 @@ func startServer(t *testing.T, s *p2p.Server) {
t
.
Fatalf
(
"failed to start the fisrt server."
)
}
result
.
mutex
.
Lock
()
defer
result
.
mutex
.
Unlock
()
result
.
started
++
atomic
.
AddInt64
(
&
result
.
started
,
1
)
}
func
stopServers
()
{
...
...
@@ -472,7 +471,10 @@ func checkPowExchange(t *testing.T) {
func
checkBloomFilterExchangeOnce
(
t
*
testing
.
T
,
mustPass
bool
)
bool
{
for
i
,
node
:=
range
nodes
{
for
peer
:=
range
node
.
shh
.
peers
{
if
!
bytes
.
Equal
(
peer
.
bloomFilter
,
masterBloomFilter
)
{
peer
.
bloomMu
.
Lock
()
eqals
:=
bytes
.
Equal
(
peer
.
bloomFilter
,
masterBloomFilter
)
peer
.
bloomMu
.
Unlock
()
if
!
eqals
{
if
mustPass
{
t
.
Fatalf
(
"node %d: failed to exchange bloom filter requirement in round %d.
\n
%x expected
\n
%x got"
,
i
,
round
,
masterBloomFilter
,
peer
.
bloomFilter
)
...
...
@@ -500,11 +502,13 @@ func checkBloomFilterExchange(t *testing.T) {
func
waitForServersToStart
(
t
*
testing
.
T
)
{
const
iterations
=
200
var
started
int64
for
j
:=
0
;
j
<
iterations
;
j
++
{
time
.
Sleep
(
50
*
time
.
Millisecond
)
if
result
.
started
==
NumNodes
{
started
=
atomic
.
LoadInt64
(
&
result
.
started
)
if
started
==
NumNodes
{
return
}
}
t
.
Fatalf
(
"Failed to start all the servers, running: %d"
,
result
.
started
)
t
.
Fatalf
(
"Failed to start all the servers, running: %d"
,
started
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment