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
8e2bf42c
Commit
8e2bf42c
authored
Nov 05, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/filter: fix data race in the test
parent
e3f36d97
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
filter_test.go
event/filter/filter_test.go
+17
-12
No files found.
event/filter/filter_test.go
View file @
8e2bf42c
...
...
@@ -21,35 +21,40 @@ import (
"time"
)
// Simple test to check if baseline matching/mismatching filtering works.
func
TestFilters
(
t
*
testing
.
T
)
{
var
success
bool
var
failure
bool
fm
:=
New
()
fm
.
Start
()
// Register two filters to catch posted data
first
:=
make
(
chan
struct
{})
fm
.
Install
(
Generic
{
Str1
:
"hello"
,
Fn
:
func
(
data
interface
{})
{
success
=
data
.
(
bool
)
first
<-
struct
{}{}
},
})
second
:=
make
(
chan
struct
{})
fm
.
Install
(
Generic
{
Str1
:
"hello1"
,
Str2
:
"hello"
,
Fn
:
func
(
data
interface
{})
{
failure
=
true
second
<-
struct
{}{}
},
})
// Post an event that should only match the first filter
fm
.
Notify
(
Generic
{
Str1
:
"hello"
},
true
)
fm
.
Stop
()
time
.
Sleep
(
10
*
time
.
Millisecond
)
// yield to the notifier
if
!
success
{
t
.
Error
(
"expected 'hello' to be posted"
)
// Ensure only the mathcing filters fire
select
{
case
<-
first
:
case
<-
time
.
After
(
100
*
time
.
Millisecond
)
:
t
.
Error
(
"matching filter timed out"
)
}
if
failure
{
t
.
Error
(
"hello1 was triggered"
)
select
{
case
<-
second
:
t
.
Error
(
"mismatching filter fired"
)
case
<-
time
.
After
(
100
*
time
.
Millisecond
)
:
}
}
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