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
5c17b2f5
Commit
5c17b2f5
authored
Apr 15, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2460 from fjl/whisper-expiration-test-delay
whisper: deflake Test*MessageExpiration
parents
fdc5a7dc
3a5bdef9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
9 deletions
+5
-9
whisper.go
whisper/whisper.go
+1
-2
whisper_test.go
whisper/whisper_test.go
+4
-7
No files found.
whisper/whisper.go
View file @
5c17b2f5
...
@@ -255,7 +255,7 @@ func (self *Whisper) add(envelope *Envelope) error {
...
@@ -255,7 +255,7 @@ func (self *Whisper) add(envelope *Envelope) error {
defer
self
.
poolMu
.
Unlock
()
defer
self
.
poolMu
.
Unlock
()
// short circuit when a received envelope has already expired
// short circuit when a received envelope has already expired
if
envelope
.
Expiry
<
=
uint32
(
time
.
Now
()
.
Unix
())
{
if
envelope
.
Expiry
<
uint32
(
time
.
Now
()
.
Unix
())
{
return
nil
return
nil
}
}
...
@@ -278,7 +278,6 @@ func (self *Whisper) add(envelope *Envelope) error {
...
@@ -278,7 +278,6 @@ func (self *Whisper) add(envelope *Envelope) error {
go
self
.
postEvent
(
envelope
)
go
self
.
postEvent
(
envelope
)
}
}
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"cached whisper envelope %x
\n
"
,
envelope
)
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"cached whisper envelope %x
\n
"
,
envelope
)
return
nil
return
nil
}
}
...
...
whisper/whisper_test.go
View file @
5c17b2f5
...
@@ -179,9 +179,7 @@ func TestMessageExpiration(t *testing.T) {
...
@@ -179,9 +179,7 @@ func TestMessageExpiration(t *testing.T) {
node
:=
startTestCluster
(
1
)[
0
]
node
:=
startTestCluster
(
1
)[
0
]
message
:=
NewMessage
([]
byte
(
"expiring message"
))
message
:=
NewMessage
([]
byte
(
"expiring message"
))
envelope
,
err
:=
message
.
Wrap
(
DefaultPoW
,
Options
{
envelope
,
err
:=
message
.
Wrap
(
DefaultPoW
,
Options
{
TTL
:
time
.
Second
})
TTL
:
time
.
Second
,
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
t
.
Fatalf
(
"failed to wrap message: %v"
,
err
)
}
}
...
@@ -197,17 +195,17 @@ func TestMessageExpiration(t *testing.T) {
...
@@ -197,17 +195,17 @@ func TestMessageExpiration(t *testing.T) {
t
.
Fatalf
(
"message not found in cache"
)
t
.
Fatalf
(
"message not found in cache"
)
}
}
// Wait for expiration and check cache again
// Wait for expiration and check cache again
time
.
Sleep
(
time
.
Second
)
// wait for expiration
time
.
Sleep
(
time
.
Second
)
// wait for expiration
time
.
Sleep
(
expirationCycle
)
// wait for cleanup cycle
time
.
Sleep
(
2
*
expirationCycle
)
// wait for cleanup cycle
node
.
poolMu
.
RLock
()
node
.
poolMu
.
RLock
()
_
,
found
=
node
.
messages
[
envelope
.
Hash
()]
_
,
found
=
node
.
messages
[
envelope
.
Hash
()]
node
.
poolMu
.
RUnlock
()
node
.
poolMu
.
RUnlock
()
if
found
{
if
found
{
t
.
Fatalf
(
"message not expired from cache"
)
t
.
Fatalf
(
"message not expired from cache"
)
}
}
// Check that adding an expired envelope doesn't do anything.
node
.
add
(
envelope
)
node
.
add
(
envelope
)
node
.
poolMu
.
RLock
()
node
.
poolMu
.
RLock
()
_
,
found
=
node
.
messages
[
envelope
.
Hash
()]
_
,
found
=
node
.
messages
[
envelope
.
Hash
()]
...
@@ -215,5 +213,4 @@ func TestMessageExpiration(t *testing.T) {
...
@@ -215,5 +213,4 @@ func TestMessageExpiration(t *testing.T) {
if
found
{
if
found
{
t
.
Fatalf
(
"message was added to cache"
)
t
.
Fatalf
(
"message was added to cache"
)
}
}
}
}
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